From b9cd4441c25279e82f30828fc031ddcb574b3b44 Mon Sep 17 00:00:00 2001 From: Ajay-sops Date: Mon, 5 May 2025 15:55:07 +0530 Subject: [PATCH 1/4] grafana alloy integration --- examples/complete/helm/alloy-values.yaml | 85 +++ examples/complete/helm/loki.yaml | 1 + examples/complete/helm/promtail.yaml | 21 - examples/complete/main.tf | 29 +- grafana/dashboards/analytics_nginx_logs.json | 2 +- grafana/dashboards/ingress_nginx.json | 2 +- grafana/dashboards/k8s_view_namespace.json | 2 +- grafana/dashboards/k8s_view_pods.json | 2 +- grafana/dashboards/nodegroup.json | 2 +- helm/values/alloy/alloy-values.yaml | 546 +++++++++++++++++++ main.tf | 39 +- variables.tf | 18 +- 12 files changed, 696 insertions(+), 53 deletions(-) create mode 100644 examples/complete/helm/alloy-values.yaml delete mode 100644 examples/complete/helm/promtail.yaml create mode 100644 helm/values/alloy/alloy-values.yaml diff --git a/examples/complete/helm/alloy-values.yaml b/examples/complete/helm/alloy-values.yaml new file mode 100644 index 0000000..b080de8 --- /dev/null +++ b/examples/complete/helm/alloy-values.yaml @@ -0,0 +1,85 @@ +alloy: + configMap: + create: true + content: | + logging { + level = "info" + format = "logfmt" + } + + loki.write "default" { + endpoint { + url = "http://loki.monitoring.svc.cluster.local:3100/loki/api/v1/push" + } + } + + discovery.kubernetes "pod" { + role = "pod" + } + + discovery.relabel "pod_logs" { + targets = discovery.kubernetes.pod.targets + + rule { + source_labels = ["__meta_kubernetes_namespace"] + action = "replace" + target_label = "namespace" + } + + rule { + source_labels = ["__meta_kubernetes_pod_name"] + action = "replace" + target_label = "pod" + } + + rule { + source_labels = ["__meta_kubernetes_pod_container_name"] + action = "replace" + target_label = "container" + } + + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + action = "replace" + target_label = "app" + } + + rule { + source_labels = ["__meta_kubernetes_namespace", "__meta_kubernetes_pod_container_name"] + action = "replace" + target_label = "job" + separator = "/" + replacement = "$1" + } + + rule { + source_labels = ["__meta_kubernetes_pod_uid", "__meta_kubernetes_pod_container_name"] + action = "replace" + target_label = "__path__" + separator = "/" + replacement = "/var/log/pods/$1/$2/*.log" + } + + rule { + source_labels = ["__meta_kubernetes_pod_container_id"] + action = "replace" + target_label = "container_runtime" + regex = "^(\\S+):\\/\\/.+$" + replacement = "$1" + } + } + + loki.source.kubernetes "pod_logs" { + targets = discovery.relabel.pod_logs.output + forward_to = [loki.process.pod_logs.receiver] + } + + loki.process "pod_logs" { + stage.static_labels { + values = { + cluster = "stage-pvc", + } + } + + forward_to = [loki.write.default.receiver] + } \ No newline at end of file diff --git a/examples/complete/helm/loki.yaml b/examples/complete/helm/loki.yaml index ef3dc7b..2f8aec9 100644 --- a/examples/complete/helm/loki.yaml +++ b/examples/complete/helm/loki.yaml @@ -19,6 +19,7 @@ loki: size: "50Gi" promtail: + enabled: false config: snippets: pipelineStages: diff --git a/examples/complete/helm/promtail.yaml b/examples/complete/helm/promtail.yaml deleted file mode 100644 index eaec1fb..0000000 --- a/examples/complete/helm/promtail.yaml +++ /dev/null @@ -1,21 +0,0 @@ -config: - clients: - - url: http://loki-scalable-gateway.monitoring.svc.cluster.local/loki/api/v1/push - -resources: - limits: - cpu: 500m - memory: 512Mi - requests: - cpu: 100m - memory: 128Mi - -# affinity: -# nodeAffinity: -# requiredDuringSchedulingIgnoredDuringExecution: -# nodeSelectorTerms: -# - matchExpressions: -# - key: "Addons-Services" -# operator: In -# values: -# - "true" diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 4ad7611..fe6aa2f 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -1,12 +1,12 @@ locals { - name = "" - region = "" - environment = "" + name = "alloy" + region = "us-east-1" + environment = "test" additional_tags = { Owner = "organization_name" Expires = "Never" Department = "Engineering" - Product = "" + Product = "alloy" Environment = local.environment } } @@ -16,29 +16,31 @@ module "pgl" { version = "3.1.0" cluster_name = "" kube_prometheus_stack_enabled = true - loki_enabled = false - loki_scalable_enabled = true - grafana_mimir_enabled = true + loki_enabled = true + grafana_alloy_enabled = true + loki_scalable_enabled = false + grafana_mimir_enabled = false cloudwatch_enabled = true tempo_enabled = false deployment_config = { - hostname = "grafana.squareops.com" + hostname = "grafana-alloy.rnd.squareops.in" storage_class_name = "infra-service-sc" prometheus_values_yaml = file("./helm/prometheus.yaml") loki_values_yaml = file("./helm/loki.yaml") + alloy_values_yaml = file("./helm/alloy-values.yaml") blackbox_values_yaml = file("./helm/blackbox.yaml") grafana_mimir_values_yaml = file("./helm/mimir.yaml") tempo_values_yaml = file("./helm/tempo.yaml") - dashboard_refresh_interval = "" + dashboard_refresh_interval = "120s" grafana_enabled = true - prometheus_hostname = "prometheus.com" + prometheus_hostname = "prometheus-alloy.rnd.squareops.in" prometheus_internal_ingress_enabled = false grafana_ingress_load_balancer = "nlb" ##Choose your load balancer type (e.g., NLB or ALB). If using ALB, ensure you provide the ACM certificate ARN for SSL. ingress_class_name = "nginx" # enter ingress class name according to your requirement (example: "nginx", "internal-ingress", "private-nginx") alb_acm_certificate_arn = "" #"arn:aws:acm:${local.region}:444455556666:certificate/certificate_ID" private_alb_enabled = false # Set to true, when wanted to deploy PGL on ALB internal loki_internal_ingress_enabled = false - loki_hostname = "loki.com" + loki_hostname = "loki-alloy.rnd.squareops.in" mimir_s3_bucket_config = { s3_bucket_name = "${local.environment}-${local.name}-mimir-bucket" versioning_enabled = "false" @@ -52,9 +54,8 @@ module "pgl" { versioning_enabled = "false" s3_bucket_region = "${local.region}" } - promtail_config = { - promtail_version = "6.16.3" - promtail_values = file("./helm/promtail.yaml") + alloy_config = { + alloy_values = file("./helm/alloy-values.yaml") } tempo_config = { s3_bucket_name = "${local.environment}-${local.name}-tempo-skaf" diff --git a/grafana/dashboards/analytics_nginx_logs.json b/grafana/dashboards/analytics_nginx_logs.json index 36aca4d..b283574 100644 --- a/grafana/dashboards/analytics_nginx_logs.json +++ b/grafana/dashboards/analytics_nginx_logs.json @@ -2019,4 +2019,4 @@ "uid": "fgc-nginx-web-analytics", "version": 3, "weekStart": "" - } \ No newline at end of file + } diff --git a/grafana/dashboards/ingress_nginx.json b/grafana/dashboards/ingress_nginx.json index 6cbb4cd..e74a583 100644 --- a/grafana/dashboards/ingress_nginx.json +++ b/grafana/dashboards/ingress_nginx.json @@ -2366,4 +2366,4 @@ "uid": "k8s-nginx-ingress-prometheus-ng", "version": 5, "weekStart": "" -} \ No newline at end of file +} diff --git a/grafana/dashboards/k8s_view_namespace.json b/grafana/dashboards/k8s_view_namespace.json index 8986b25..c8f31a6 100644 --- a/grafana/dashboards/k8s_view_namespace.json +++ b/grafana/dashboards/k8s_view_namespace.json @@ -2304,4 +2304,4 @@ "uid": "k8s_views_ns", "version": 35, "weekStart": "" - } \ No newline at end of file + } diff --git a/grafana/dashboards/k8s_view_pods.json b/grafana/dashboards/k8s_view_pods.json index f12d928..4251b71 100644 --- a/grafana/dashboards/k8s_view_pods.json +++ b/grafana/dashboards/k8s_view_pods.json @@ -2696,4 +2696,4 @@ "uid": "k8s_views_pods", "version": 28, "weekStart": "" - } \ No newline at end of file + } diff --git a/grafana/dashboards/nodegroup.json b/grafana/dashboards/nodegroup.json index c0a2d16..918ef4d 100644 --- a/grafana/dashboards/nodegroup.json +++ b/grafana/dashboards/nodegroup.json @@ -1371,4 +1371,4 @@ "uid": "K8s-CR-Nodesgroups", "version": 7, "weekStart": "" -} \ No newline at end of file +} diff --git a/helm/values/alloy/alloy-values.yaml b/helm/values/alloy/alloy-values.yaml new file mode 100644 index 0000000..92f5a55 --- /dev/null +++ b/helm/values/alloy/alloy-values.yaml @@ -0,0 +1,546 @@ +# -- Overrides the chart's name. Used to change the infix in the resource names. +nameOverride: null + +# -- Overrides the chart's namespace. +namespaceOverride: null + +# -- Overrides the chart's computed fullname. Used to change the full prefix of +# resource names. +fullnameOverride: null + +## Global properties for image pulling override the values defined under `image.registry` and `configReloader.image.registry`. +## If you want to override only one image registry, use the specific fields but if you want to override them all, use `global.image.registry` +global: + image: + # -- Global image registry to use if it needs to be overridden for some specific use cases (e.g local registries, custom images, ...) + registry: "" + + # -- Optional set of global image pull secrets. + pullSecrets: [] + + # -- Security context to apply to the Grafana Alloy pod. + podSecurityContext: {} + +crds: + # -- Whether to install CRDs for monitoring. + create: true + +## Various Alloy settings. For backwards compatibility with the grafana-agent +## chart, this field may also be called "agent". Naming this field "agent" is +## deprecated and will be removed in a future release. +alloy: + configMap: + create: true + content: | + logging { + level = "info" + format = "logfmt" + } + + loki.write "default" { + endpoint { + url = "http://loki.monitoring.svc.cluster.local:3100/loki/api/v1/push" + } + } + + discovery.kubernetes "pod" { + role = "pod" + } + + discovery.relabel "pod_logs" { + targets = discovery.kubernetes.pod.targets + + rule { + source_labels = ["__meta_kubernetes_namespace"] + action = "replace" + target_label = "namespace" + } + + rule { + source_labels = ["__meta_kubernetes_pod_name"] + action = "replace" + target_label = "pod" + } + + rule { + source_labels = ["__meta_kubernetes_pod_container_name"] + action = "replace" + target_label = "container" + } + + rule { + source_labels = ["__meta_kubernetes_pod_label_app_kubernetes_io_name"] + action = "replace" + target_label = "app" + } + + rule { + source_labels = ["__meta_kubernetes_namespace", "__meta_kubernetes_pod_container_name"] + action = "replace" + target_label = "job" + separator = "/" + replacement = "$1" + } + + rule { + source_labels = ["__meta_kubernetes_pod_uid", "__meta_kubernetes_pod_container_name"] + action = "replace" + target_label = "__path__" + separator = "/" + replacement = "/var/log/pods/$1/$2/*.log" + } + + rule { + source_labels = ["__meta_kubernetes_pod_container_id"] + action = "replace" + target_label = "container_runtime" + regex = "^(\\S+):\\/\\/.+$" + replacement = "$1" + } + } + + loki.source.kubernetes "pod_logs" { + targets = discovery.relabel.pod_logs.output + forward_to = [loki.process.pod_logs.receiver] + } + + loki.process "pod_logs" { + stage.static_labels { + values = { + cluster = "stage-pvc", + } + } + + forward_to = [loki.write.default.receiver] + } + + + # -- Name of existing ConfigMap to use. Used when create is false. + name: null + # -- Key in ConfigMap to get config from. + key: null + + clustering: + # -- Deploy Alloy in a cluster to allow for load distribution. + enabled: false + + # -- Name for the Alloy cluster. Used for differentiating between clusters. + name: "" + + # -- Name for the port used for clustering, useful if running inside an Istio Mesh + portName: http + + # -- Minimum stability level of components and behavior to enable. Must be + # one of "experimental", "public-preview", or "generally-available". + stabilityLevel: "generally-available" + + # -- Path to where Grafana Alloy stores data (for example, the Write-Ahead Log). + # By default, data is lost between reboots. + storagePath: /tmp/alloy + + # -- Address to listen for traffic on. 0.0.0.0 exposes the UI to other + # containers. + listenAddr: 0.0.0.0 + + # -- Port to listen for traffic on. + listenPort: 12345 + + # -- Scheme is needed for readiness probes. If enabling tls in your configs, set to "HTTPS" + listenScheme: HTTP + + # -- Base path where the UI is exposed. + uiPathPrefix: / + + # -- Enables sending Grafana Labs anonymous usage stats to help improve Grafana + # Alloy. + enableReporting: true + + # -- Extra environment variables to pass to the Alloy container. + extraEnv: [] + + # -- Maps all the keys on a ConfigMap or Secret as environment variables. https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#envfromsource-v1-core + envFrom: [] + + # -- Extra args to pass to `alloy run`: https://grafana.com/docs/alloy/latest/reference/cli/run/ + extraArgs: [] + + # -- Extra ports to expose on the Alloy container. + extraPorts: [] + # - name: "faro" + # port: 12347 + # targetPort: 12347 + # protocol: "TCP" + # appProtocol: "h2c" + + # -- Host aliases to add to the Alloy container. + hostAliases: [] + # - ip: "20.21.22.23" + # hostnames: + # - "company.grafana.net" + + mounts: + # -- Mount /var/log from the host into the container for log collection. + varlog: false + # -- Mount /var/lib/docker/containers from the host into the container for log + # collection. + dockercontainers: false + + # -- Extra volume mounts to add into the Grafana Alloy container. Does not + # affect the watch container. + extra: [] + + # -- Security context to apply to the Grafana Alloy container. + securityContext: {} + + # -- Resource requests and limits to apply to the Grafana Alloy container. + resources: {} + + # -- Set lifecycle hooks for the Grafana Alloy container. + lifecycle: {} + # preStop: + # exec: + # command: + # - /bin/sleep + # - "10" + + # -- Set livenessProbe for the Grafana Alloy container. + livenessProbe: {} + +image: + # -- Grafana Alloy image registry (defaults to docker.io) + registry: "docker.io" + # -- Grafana Alloy image repository. + repository: grafana/alloy + # -- (string) Grafana Alloy image tag. When empty, the Chart's appVersion is + # used. + tag: null + # -- Grafana Alloy image's SHA256 digest (either in format "sha256:XYZ" or "XYZ"). When set, will override `image.tag`. + digest: null + # -- Grafana Alloy image pull policy. + pullPolicy: IfNotPresent + # -- Optional set of image pull secrets. + pullSecrets: [] + +rbac: + # -- Whether to create RBAC resources for Alloy. + create: true + +serviceAccount: + # -- Whether to create a service account for the Grafana Alloy deployment. + create: true + # -- Additional labels to add to the created service account. + additionalLabels: {} + # -- Annotations to add to the created service account. + annotations: {} + # -- The name of the existing service account to use when + # serviceAccount.create is false. + name: null + # Whether the Alloy pod should automatically mount the service account token. + automountServiceAccountToken: true + +# Options for the extra controller used for config reloading. +configReloader: + # -- Enables automatically reloading when the Alloy config changes. + enabled: true + image: + # -- Config reloader image registry (defaults to docker.io) + registry: "quay.io" + # -- Repository to get config reloader image from. + repository: prometheus-operator/prometheus-config-reloader + # -- Tag of image to use for config reloading. + tag: v0.81.0 + # -- SHA256 digest of image to use for config reloading (either in format "sha256:XYZ" or "XYZ"). When set, will override `configReloader.image.tag` + digest: "" + # -- Override the args passed to the container. + customArgs: [] + # -- Resource requests and limits to apply to the config reloader container. + resources: + requests: + cpu: "10m" + memory: "50Mi" + # -- Security context to apply to the Grafana configReloader container. + securityContext: {} + +controller: + # -- Type of controller to use for deploying Grafana Alloy in the cluster. + # Must be one of 'daemonset', 'deployment', or 'statefulset'. + type: 'daemonset' + + # -- Number of pods to deploy. Ignored when controller.type is 'daemonset'. + replicas: 1 + + # -- Annotations to add to controller. + extraAnnotations: {} + + # -- Whether to deploy pods in parallel. Only used when controller.type is + # 'statefulset'. + parallelRollout: true + + # -- How many additional seconds to wait before considering a pod ready. + minReadySeconds: 10 + + # -- Configures Pods to use the host network. When set to true, the ports that will be used must be specified. + hostNetwork: false + + # -- Configures Pods to use the host PID namespace. + hostPID: false + + # -- Configures the DNS policy for the pod. https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-policy + dnsPolicy: ClusterFirst + + # -- Termination grace period in seconds for the Grafana Alloy pods. + # The default value used by Kubernetes if unspecifed is 30 seconds. + terminationGracePeriodSeconds: null + + # -- Update strategy for updating deployed Pods. + updateStrategy: {} + + # -- nodeSelector to apply to Grafana Alloy pods. + nodeSelector: {} + + # -- Tolerations to apply to Grafana Alloy pods. + tolerations: [] + + # -- Topology Spread Constraints to apply to Grafana Alloy pods. + topologySpreadConstraints: [] + + # -- priorityClassName to apply to Grafana Alloy pods. + priorityClassName: '' + + # -- Extra pod annotations to add. + podAnnotations: {} + + # -- Extra pod labels to add. + podLabels: {} + + # -- PodDisruptionBudget configuration. + podDisruptionBudget: + # -- Whether to create a PodDisruptionBudget for the controller. + enabled: false + # -- Minimum number of pods that must be available during a disruption. + # Note: Only one of minAvailable or maxUnavailable should be set. + minAvailable: null + # -- Maximum number of pods that can be unavailable during a disruption. + # Note: Only one of minAvailable or maxUnavailable should be set. + maxUnavailable: null + + # -- Whether to enable automatic deletion of stale PVCs due to a scale down operation, when controller.type is 'statefulset'. + enableStatefulSetAutoDeletePVC: false + + autoscaling: + # -- Creates a HorizontalPodAutoscaler for controller type deployment. + # Deprecated: Please use controller.autoscaling.horizontal instead + enabled: false + # -- The lower limit for the number of replicas to which the autoscaler can scale down. + minReplicas: 1 + # -- The upper limit for the number of replicas to which the autoscaler can scale up. + maxReplicas: 5 + # -- Average CPU utilization across all relevant pods, a percentage of the requested value of the resource for the pods. Setting `targetCPUUtilizationPercentage` to 0 will disable CPU scaling. + targetCPUUtilizationPercentage: 0 + # -- Average Memory utilization across all relevant pods, a percentage of the requested value of the resource for the pods. Setting `targetMemoryUtilizationPercentage` to 0 will disable Memory scaling. + targetMemoryUtilizationPercentage: 80 + + scaleDown: + # -- List of policies to determine the scale-down behavior. + policies: [] + # - type: Pods + # value: 4 + # periodSeconds: 60 + # -- Determines which of the provided scaling-down policies to apply if multiple are specified. + selectPolicy: Max + # -- The duration that the autoscaling mechanism should look back on to make decisions about scaling down. + stabilizationWindowSeconds: 300 + + scaleUp: + # -- List of policies to determine the scale-up behavior. + policies: [] + # - type: Pods + # value: 4 + # periodSeconds: 60 + # -- Determines which of the provided scaling-up policies to apply if multiple are specified. + selectPolicy: Max + # -- The duration that the autoscaling mechanism should look back on to make decisions about scaling up. + stabilizationWindowSeconds: 0 + + # -- Configures the Horizontal Pod Autoscaler for the controller. + horizontal: + # -- Enables the Horizontal Pod Autoscaler for the controller. + enabled: false + + # -- The lower limit for the number of replicas to which the autoscaler can scale down. + minReplicas: 1 + # -- The upper limit for the number of replicas to which the autoscaler can scale up. + maxReplicas: 5 + # -- Average CPU utilization across all relevant pods, a percentage of the requested value of the resource for the pods. Setting `targetCPUUtilizationPercentage` to 0 will disable CPU scaling. + targetCPUUtilizationPercentage: 0 + # -- Average Memory utilization across all relevant pods, a percentage of the requested value of the resource for the pods. Setting `targetMemoryUtilizationPercentage` to 0 will disable Memory scaling. + targetMemoryUtilizationPercentage: 80 + + scaleDown: + # -- List of policies to determine the scale-down behavior. + policies: [] + # - type: Pods + # value: 4 + # periodSeconds: 60 + # -- Determines which of the provided scaling-down policies to apply if multiple are specified. + selectPolicy: Max + # -- The duration that the autoscaling mechanism should look back on to make decisions about scaling down. + stabilizationWindowSeconds: 300 + + scaleUp: + # -- List of policies to determine the scale-up behavior. + policies: [] + # - type: Pods + # value: 4 + # periodSeconds: 60 + # -- Determines which of the provided scaling-up policies to apply if multiple are specified. + selectPolicy: Max + # -- The duration that the autoscaling mechanism should look back on to make decisions about scaling up. + stabilizationWindowSeconds: 0 + # -- Configures the Vertical Pod Autoscaler for the controller. + vertical: + # -- Enables the Vertical Pod Autoscaler for the controller. + enabled: false + + # -- List of recommenders to use for the Vertical Pod Autoscaler. + # Recommenders are responsible for generating recommendation for the object. + # List should be empty (then the default recommender will generate the recommendation) + # or contain exactly one recommender. + recommenders: [] + # recommenders: + # - name: custom-recommender-performance + + # -- Configures the resource policy for the Vertical Pod Autoscaler. + resourcePolicy: + # -- Configures the container policies for the Vertical Pod Autoscaler. + containerPolicies: + - containerName: alloy + # -- The controlled resources for the Vertical Pod Autoscaler. + controlledResources: + - cpu + - memory + # -- The controlled values for the Vertical Pod Autoscaler. Needs to be either RequestsOnly or RequestsAndLimits. + controlledValues: "RequestsAndLimits" + # -- The maximum allowed values for the pods. + maxAllowed: {} + # cpu: 200m + # memory: 100Mi + # -- Defines the min allowed resources for the pod + minAllowed: {} + # cpu: 200m + # memory: 100Mi + + # -- Configures the update policy for the Vertical Pod Autoscaler. + updatePolicy: + # -- Specifies minimal number of replicas which need to be alive for VPA Updater to attempt pod eviction + # minReplicas: 1 + # -- Specifies whether recommended updates are applied when a Pod is started and whether recommended updates + # are applied during the life of a Pod. Possible values are "Off", "Initial", "Recreate", and "Auto". + # updateMode: Auto + + # -- Affinity configuration for pods. + affinity: {} + + volumes: + # -- Extra volumes to add to the Grafana Alloy pod. + extra: [] + + # -- volumeClaimTemplates to add when controller.type is 'statefulset'. + volumeClaimTemplates: [] + + ## -- Additional init containers to run. + ## ref: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/ + ## + initContainers: [] + + # -- Additional containers to run alongside the Alloy container and initContainers. + extraContainers: [] + +service: + # -- Creates a Service for the controller's pods. + enabled: true + # -- Service type + type: ClusterIP + # -- NodePort port. Only takes effect when `service.type: NodePort` + nodePort: 31128 + # -- Cluster IP, can be set to None, empty "" or an IP address + clusterIP: '' + # -- Value for internal traffic policy. 'Cluster' or 'Local' + internalTrafficPolicy: Cluster + annotations: {} + # cloud.google.com/load-balancer-type: Internal + +serviceMonitor: + enabled: false + # -- Additional labels for the service monitor. + additionalLabels: {} + # -- Scrape interval. If not set, the Prometheus default scrape interval is used. + interval: "" + # -- MetricRelabelConfigs to apply to samples after scraping, but before ingestion. + # ref: https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#relabelconfig + metricRelabelings: [] + # - action: keep + # regex: 'kube_(daemonset|deployment|pod|namespace|node|statefulset).+' + # sourceLabels: [__name__] + + # -- Customize tls parameters for the service monitor + tlsConfig: {} + + # -- RelabelConfigs to apply to samples before scraping + # ref: https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#relabelconfig + relabelings: [] + # - sourceLabels: [__meta_kubernetes_pod_node_name] + # separator: ; + # regex: ^(.*)$ + # targetLabel: nodename + # replacement: $1 + # action: replace +ingress: + # -- Enables ingress for Alloy (Faro port) + enabled: false + # For Kubernetes >= 1.18 you should specify the ingress-controller via the field ingressClassName + # See https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/#specifying-the-class-of-an-ingress + # ingressClassName: nginx + # Values can be templated + annotations: + {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + labels: {} + path: / + faroPort: 12347 + + # pathType is only for k8s >= 1.1= + pathType: Prefix + + hosts: + - chart-example.local + ## Extra paths to prepend to every host configuration. This is useful when working with annotation based services. + extraPaths: [] + # - path: /* + # backend: + # serviceName: ssl-redirect + # servicePort: use-annotation + ## Or for k8s > 1.19 + # - path: /* + # pathType: Prefix + # backend: + # service: + # name: ssl-redirect + # port: + # name: use-annotation + + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +# -- Extra k8s manifests to deploy +extraObjects: [] +# - apiVersion: v1 +# kind: Secret +# metadata: +# name: grafana-cloud +# stringData: +# PROMETHEUS_HOST: 'https://prometheus-us-central1.grafana.net/api/prom/push' +# PROMETHEUS_USERNAME: '123456'install \ No newline at end of file diff --git a/main.tf b/main.tf index e8a2c51..d94885f 100644 --- a/main.tf +++ b/main.tf @@ -95,6 +95,25 @@ resource "helm_release" "loki" { ] } +#---------------------Grafana Alloy---------------------------------- + +resource "helm_release" "alloy" { + count = var.grafana_alloy_enabled ? 1 : 0 + depends_on = [kubernetes_namespace.monitoring, helm_release.loki] + name = "alloy" + atomic = true + chart = "alloy" + version = var.alloy_chart_version + namespace = var.pgl_namespace + repository = "https://grafana.github.io/helm-charts" + cleanup_on_fail = true + + values = [ + templatefile("${path.module}/helm/values/alloy/alloy-values.yaml", {}), + var.deployment_config.alloy_values_yaml + ] +} + #---------------------blackbox---------------------------------- resource "helm_release" "blackbox_exporter" { @@ -1201,16 +1220,16 @@ resource "time_sleep" "wait_180_sec" { create_duration = "180s" } -resource "null_resource" "grafana_homepage" { - count = var.deployment_config.grafana_enabled ? 1 : 0 - depends_on = [time_sleep.wait_180_sec] - provisioner "local-exec" { - interpreter = ["/bin/bash", "-c"] - command = < Date: Mon, 5 May 2025 15:57:21 +0530 Subject: [PATCH 2/4] made changes in example --- examples/complete/main.tf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/complete/main.tf b/examples/complete/main.tf index fe6aa2f..14ebe31 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -1,12 +1,12 @@ locals { - name = "alloy" - region = "us-east-1" - environment = "test" + name = "" + region = "" + environment = "" additional_tags = { Owner = "organization_name" Expires = "Never" Department = "Engineering" - Product = "alloy" + Product = "" Environment = local.environment } } From 2df2c281f24fe34036b5db874077ac50ba928949 Mon Sep 17 00:00:00 2001 From: Aman <146931382+amanravi-squareops@users.noreply.github.com> Date: Mon, 19 May 2025 12:58:46 +0530 Subject: [PATCH 3/4] Update main.tf --- examples/complete/main.tf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 14ebe31..8ce7398 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -23,7 +23,7 @@ module "pgl" { cloudwatch_enabled = true tempo_enabled = false deployment_config = { - hostname = "grafana-alloy.rnd.squareops.in" + hostname = "grafana.squareops.com" storage_class_name = "infra-service-sc" prometheus_values_yaml = file("./helm/prometheus.yaml") loki_values_yaml = file("./helm/loki.yaml") @@ -31,16 +31,16 @@ module "pgl" { blackbox_values_yaml = file("./helm/blackbox.yaml") grafana_mimir_values_yaml = file("./helm/mimir.yaml") tempo_values_yaml = file("./helm/tempo.yaml") - dashboard_refresh_interval = "120s" + dashboard_refresh_interval = "" grafana_enabled = true - prometheus_hostname = "prometheus-alloy.rnd.squareops.in" + prometheus_hostname = "prometheus.com" prometheus_internal_ingress_enabled = false grafana_ingress_load_balancer = "nlb" ##Choose your load balancer type (e.g., NLB or ALB). If using ALB, ensure you provide the ACM certificate ARN for SSL. ingress_class_name = "nginx" # enter ingress class name according to your requirement (example: "nginx", "internal-ingress", "private-nginx") alb_acm_certificate_arn = "" #"arn:aws:acm:${local.region}:444455556666:certificate/certificate_ID" private_alb_enabled = false # Set to true, when wanted to deploy PGL on ALB internal loki_internal_ingress_enabled = false - loki_hostname = "loki-alloy.rnd.squareops.in" + loki_hostname = "loki.com" mimir_s3_bucket_config = { s3_bucket_name = "${local.environment}-${local.name}-mimir-bucket" versioning_enabled = "false" From d01ddd64cb9c9766f6cce794fd694aa11681fb6b Mon Sep 17 00:00:00 2001 From: Aman <146931382+amanravi-squareops@users.noreply.github.com> Date: Mon, 19 May 2025 13:05:34 +0530 Subject: [PATCH 4/4] Update main.tf --- main.tf | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/main.tf b/main.tf index d94885f..b3dd15b 100644 --- a/main.tf +++ b/main.tf @@ -1220,16 +1220,16 @@ resource "time_sleep" "wait_180_sec" { create_duration = "180s" } -# resource "null_resource" "grafana_homepage" { -# count = var.deployment_config.grafana_enabled ? 1 : 0 -# depends_on = [time_sleep.wait_180_sec] -# provisioner "local-exec" { -# interpreter = ["/bin/bash", "-c"] -# command = <