diff --git a/alloy-modules/kubernetes/integrations/k8s-events.alloy b/alloy-modules/kubernetes/integrations/k8s-events.alloy deleted file mode 100644 index 48630bc4..00000000 --- a/alloy-modules/kubernetes/integrations/k8s-events.alloy +++ /dev/null @@ -1,56 +0,0 @@ -/* -Module Components: component_cluster_events -*/ - -declare "component_cluster_events" { - - /***************************************************************** - * ARGUMENTS - *****************************************************************/ - argument "forward_to" { - comment = "Must be a list(LogsReceiver) where collected logs should be forwarded to" - } - - argument "job_label" { - optional = true - default = "integrations/kubernetes/eventhandler" - } - - argument "cluster" { - optional = true - default = "k3d" - } - - loki.source.kubernetes_events "cluster_events" { - job_name = argument.job_label.value - log_format = "logfmt" - forward_to = [loki.process.logs_service.receiver] - } - - loki.process "logs_service" { - stage.static_labels { - values = { - cluster = argument.cluster.value, - } - } - forward_to = argument.forward_to.value - } - - // // Logs Service - // remote.kubernetes.secret "logs_service" { - // name = "loki-k8s-monitoring" - // namespace = "k8s-monitoring" - // } - // // Loki - // loki.write "logs_service" { - // endpoint { - // url = nonsensitive(remote.kubernetes.secret.logs_service.data["host"]) + "/loki/api/v1/push" - // tenant_id = nonsensitive(remote.kubernetes.secret.logs_service.data["tenantId"]) - - // basic_auth { - // username = nonsensitive(remote.kubernetes.secret.logs_service.data["username"]) - // password = remote.kubernetes.secret.logs_service.data["password"] - // } - // } - // } -} diff --git a/alloy-modules/kubernetes/integrations/kustomization.yaml b/alloy-modules/kubernetes/integrations/kustomization.yaml new file mode 100644 index 00000000..dd9ae8ad --- /dev/null +++ b/alloy-modules/kubernetes/integrations/kustomization.yaml @@ -0,0 +1,53 @@ +# ============================================================================ # +# Alloy Integrations Components +# ============================================================================ # + +# ---------------------------------------------------- +# apiVersion and kind of Kustomization +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +# Alloy Integrations Configs +configMapGenerator: +- name: alloy-integrations + namespace: monitoring-system + options: + disableNameSuffixHash: true + literals: + - MEMCACHED_K8S_SECRET_NAME=alloy-integrations-memcached + - REDIS_K8S_SECRET_NAME=alloy-integrations-redis + - MYSQL_K8S_SECRET_NAME=alloy-integrations-mysql + files: + - memcached.alloy + - redis.alloy + - mysql.alloy + +secretGenerator: +# integrations memcached credentials +- name: alloy-integrations-memcached + namespace: monitoring-system + options: + disableNameSuffixHash: true + literals: + - instance-name=primary + - instance-address=memcached.memcached-system.svc.cluster.local:11211 + - instance-timeout=5s +# integrations redis credentials +- name: alloy-integrations-redis + namespace: monitoring-system + options: + disableNameSuffixHash: true + literals: + - instance-name=primary + - instance-address=redis-master.redis-system.svc.cluster.local:6379 + - instance-password=VD538OYxSEiGD4I9mmFfqFMCGq1vIiGm +# integrations mysql credentials +- name: alloy-integrations-mysql + namespace: monitoring-system + options: + disableNameSuffixHash: true + literals: + - instance-name=primary + - mysql-host=mysql.mysql-system.svc.cluster.local + - mysql-username=lgtmp + - mysql-password=VD538OYxSEiGD4I9mmFfqFMCGq1vIiGm diff --git a/alloy-modules/kubernetes/integrations/memcached.alloy b/alloy-modules/kubernetes/integrations/memcached.alloy index b02b4681..f5117f50 100644 --- a/alloy-modules/kubernetes/integrations/memcached.alloy +++ b/alloy-modules/kubernetes/integrations/memcached.alloy @@ -2,7 +2,7 @@ Module Components: component_memcached */ -declare "component_memcached" { +declare "memcached_metrics_scrape" { /***************************************************************** * ARGUMENTS diff --git a/alloy-modules/kubernetes/integrations/mysql.alloy b/alloy-modules/kubernetes/integrations/mysql.alloy index b7848c56..9a7557b5 100644 --- a/alloy-modules/kubernetes/integrations/mysql.alloy +++ b/alloy-modules/kubernetes/integrations/mysql.alloy @@ -2,7 +2,7 @@ Module Components: component_mysql */ -declare "component_mysql" { +declare "mysql_metrics_scrape" { /***************************************************************** * ARGUMENTS diff --git a/alloy-modules/kubernetes/integrations/redis.alloy b/alloy-modules/kubernetes/integrations/redis.alloy index e3474652..9d61beab 100644 --- a/alloy-modules/kubernetes/integrations/redis.alloy +++ b/alloy-modules/kubernetes/integrations/redis.alloy @@ -2,7 +2,7 @@ Module Components: component_redis_exporter */ -declare "component_redis_exporter" { +declare "redis_exporter_metrics_scrape" { /***************************************************************** * ARGUMENTS diff --git a/alloy-modules/kubernetes/logs/k8s-events.alloy b/alloy-modules/kubernetes/logs/k8s-events.alloy new file mode 100644 index 00000000..8c5f3a2d --- /dev/null +++ b/alloy-modules/kubernetes/logs/k8s-events.alloy @@ -0,0 +1,36 @@ +/* +Module Components: component_cluster_events +*/ + +declare "kubernetes_cluster_events" { + + /***************************************************************** + * ARGUMENTS + *****************************************************************/ + argument "forward_to" { + comment = "Must be a list(LogsReceiver) where collected logs should be forwarded to" + } + + argument "job_label" { + optional = true + } + + argument "cluster" { + optional = true + } + + loki.source.kubernetes_events "cluster_events" { + job_name = coalesce(argument.job_label.value, "integrations/kubernetes/eventhandler") + log_format = "logfmt" + forward_to = [loki.process.logs_service.receiver] + } + + loki.process "logs_service" { + stage.static_labels { + values = { + cluster = coalesce(argument.cluster.value, "k3d"), + } + } + forward_to = argument.forward_to.value + } +} diff --git a/alloy-modules/kubernetes/metrics/integrations-scrape.alloy b/alloy-modules/kubernetes/metrics/integrations-scrape.alloy deleted file mode 100644 index 542f1bb0..00000000 --- a/alloy-modules/kubernetes/metrics/integrations-scrape.alloy +++ /dev/null @@ -1,79 +0,0 @@ -/* -Module Components: integrations_scrape -Description: Integrations Module Components Scrape - -Note: Every argument except for "forward_to" is optional, and does have a defined default value. However, the values for these - arguments are not defined using the default = " ... " argument syntax, but rather using the coalesce(argument.value, " ... "). - This is because if the argument passed in from another consuming module is set to null, the default = " ... " syntax will - does not override the value passed in, where coalesce() will return the first non-null value. -*/ - -declare "integrations_scrape" { - - /***************************************************************** - * ARGUMENTS - *****************************************************************/ - argument "forward_to" { - comment = "Must be a list(MetricssReceiver) where collected metrics should be forwarded to" - } - - argument "name" { - comment = "Name of the integrations config" - optional = true - } - - argument "namespace" { - comment = "Namespace of the integrations config" - optional = true - } - - /***************************************************************** - * Import Integrations Components - *****************************************************************/ - remote.kubernetes.configmap "integrations" { - namespace = coalesce(argument.namespace.value, "monitoring-system") - name = coalesce(argument.name.value, "alloy-integrations") - } - - /***************************************************************** - * Memcached Integrations - *****************************************************************/ - import.string "memcached" { - content = remote.kubernetes.configmap.integrations.data["memcached.alloy"] - } - - memcached.component_memcached "instance" { - forward_to = argument.forward_to.value - - namespace = argument.namespace.value - name = remote.kubernetes.configmap.integrations.data["MEMCACHED_K8S_SECRET_NAME"] - } - - // /***************************************************************** - // * Redis Integrations - // *****************************************************************/ - // import.string "redis" { - // content = remote.kubernetes.configmap.integrations.data["redis.alloy"] - // } - - // redis.component_redis_exporter "instance" { - // forward_to = argument.forward_to.value - - // namespace = argument.namespace.value - // name = remote.kubernetes.configmap.integrations.data["REDIS_K8S_SECRET_NAME"] - // } - - // /***************************************************************** - // * Mysql Integrations - // *****************************************************************/ - // import.string "mysql" { - // content = remote.kubernetes.configmap.integrations.data["mysql.alloy"] - // } - - // mysql.component_mysql "instance" { - // forward_to = argument.forward_to.value - - // namespace = argument.namespace.value - // name = remote.kubernetes.configmap.integrations.data["MYSQL_K8S_SECRET_NAME"] - // } -} diff --git a/kubernetes/common/alloy/configs/kubernetes/integrations/k8s-events.alloy b/kubernetes/common/alloy/configs/kubernetes/integrations/k8s-events.alloy deleted file mode 100644 index 48630bc4..00000000 --- a/kubernetes/common/alloy/configs/kubernetes/integrations/k8s-events.alloy +++ /dev/null @@ -1,56 +0,0 @@ -/* -Module Components: component_cluster_events -*/ - -declare "component_cluster_events" { - - /***************************************************************** - * ARGUMENTS - *****************************************************************/ - argument "forward_to" { - comment = "Must be a list(LogsReceiver) where collected logs should be forwarded to" - } - - argument "job_label" { - optional = true - default = "integrations/kubernetes/eventhandler" - } - - argument "cluster" { - optional = true - default = "k3d" - } - - loki.source.kubernetes_events "cluster_events" { - job_name = argument.job_label.value - log_format = "logfmt" - forward_to = [loki.process.logs_service.receiver] - } - - loki.process "logs_service" { - stage.static_labels { - values = { - cluster = argument.cluster.value, - } - } - forward_to = argument.forward_to.value - } - - // // Logs Service - // remote.kubernetes.secret "logs_service" { - // name = "loki-k8s-monitoring" - // namespace = "k8s-monitoring" - // } - // // Loki - // loki.write "logs_service" { - // endpoint { - // url = nonsensitive(remote.kubernetes.secret.logs_service.data["host"]) + "/loki/api/v1/push" - // tenant_id = nonsensitive(remote.kubernetes.secret.logs_service.data["tenantId"]) - - // basic_auth { - // username = nonsensitive(remote.kubernetes.secret.logs_service.data["username"]) - // password = remote.kubernetes.secret.logs_service.data["password"] - // } - // } - // } -} diff --git a/kubernetes/common/alloy/configs/kubernetes/integrations/kustomization.yaml b/kubernetes/common/alloy/configs/kubernetes/integrations/kustomization.yaml new file mode 100644 index 00000000..dd9ae8ad --- /dev/null +++ b/kubernetes/common/alloy/configs/kubernetes/integrations/kustomization.yaml @@ -0,0 +1,53 @@ +# ============================================================================ # +# Alloy Integrations Components +# ============================================================================ # + +# ---------------------------------------------------- +# apiVersion and kind of Kustomization +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +# Alloy Integrations Configs +configMapGenerator: +- name: alloy-integrations + namespace: monitoring-system + options: + disableNameSuffixHash: true + literals: + - MEMCACHED_K8S_SECRET_NAME=alloy-integrations-memcached + - REDIS_K8S_SECRET_NAME=alloy-integrations-redis + - MYSQL_K8S_SECRET_NAME=alloy-integrations-mysql + files: + - memcached.alloy + - redis.alloy + - mysql.alloy + +secretGenerator: +# integrations memcached credentials +- name: alloy-integrations-memcached + namespace: monitoring-system + options: + disableNameSuffixHash: true + literals: + - instance-name=primary + - instance-address=memcached.memcached-system.svc.cluster.local:11211 + - instance-timeout=5s +# integrations redis credentials +- name: alloy-integrations-redis + namespace: monitoring-system + options: + disableNameSuffixHash: true + literals: + - instance-name=primary + - instance-address=redis-master.redis-system.svc.cluster.local:6379 + - instance-password=VD538OYxSEiGD4I9mmFfqFMCGq1vIiGm +# integrations mysql credentials +- name: alloy-integrations-mysql + namespace: monitoring-system + options: + disableNameSuffixHash: true + literals: + - instance-name=primary + - mysql-host=mysql.mysql-system.svc.cluster.local + - mysql-username=lgtmp + - mysql-password=VD538OYxSEiGD4I9mmFfqFMCGq1vIiGm diff --git a/kubernetes/common/alloy/configs/kubernetes/integrations/memcached.alloy b/kubernetes/common/alloy/configs/kubernetes/integrations/memcached.alloy index b02b4681..f5117f50 100644 --- a/kubernetes/common/alloy/configs/kubernetes/integrations/memcached.alloy +++ b/kubernetes/common/alloy/configs/kubernetes/integrations/memcached.alloy @@ -2,7 +2,7 @@ Module Components: component_memcached */ -declare "component_memcached" { +declare "memcached_metrics_scrape" { /***************************************************************** * ARGUMENTS diff --git a/kubernetes/common/alloy/configs/kubernetes/integrations/mysql.alloy b/kubernetes/common/alloy/configs/kubernetes/integrations/mysql.alloy index b7848c56..9a7557b5 100644 --- a/kubernetes/common/alloy/configs/kubernetes/integrations/mysql.alloy +++ b/kubernetes/common/alloy/configs/kubernetes/integrations/mysql.alloy @@ -2,7 +2,7 @@ Module Components: component_mysql */ -declare "component_mysql" { +declare "mysql_metrics_scrape" { /***************************************************************** * ARGUMENTS diff --git a/kubernetes/common/alloy/configs/kubernetes/integrations/redis.alloy b/kubernetes/common/alloy/configs/kubernetes/integrations/redis.alloy index e3474652..9d61beab 100644 --- a/kubernetes/common/alloy/configs/kubernetes/integrations/redis.alloy +++ b/kubernetes/common/alloy/configs/kubernetes/integrations/redis.alloy @@ -2,7 +2,7 @@ Module Components: component_redis_exporter */ -declare "component_redis_exporter" { +declare "redis_exporter_metrics_scrape" { /***************************************************************** * ARGUMENTS diff --git a/kubernetes/common/alloy/configs/kubernetes/logs/k8s-events.alloy b/kubernetes/common/alloy/configs/kubernetes/logs/k8s-events.alloy new file mode 100644 index 00000000..8c5f3a2d --- /dev/null +++ b/kubernetes/common/alloy/configs/kubernetes/logs/k8s-events.alloy @@ -0,0 +1,36 @@ +/* +Module Components: component_cluster_events +*/ + +declare "kubernetes_cluster_events" { + + /***************************************************************** + * ARGUMENTS + *****************************************************************/ + argument "forward_to" { + comment = "Must be a list(LogsReceiver) where collected logs should be forwarded to" + } + + argument "job_label" { + optional = true + } + + argument "cluster" { + optional = true + } + + loki.source.kubernetes_events "cluster_events" { + job_name = coalesce(argument.job_label.value, "integrations/kubernetes/eventhandler") + log_format = "logfmt" + forward_to = [loki.process.logs_service.receiver] + } + + loki.process "logs_service" { + stage.static_labels { + values = { + cluster = coalesce(argument.cluster.value, "k3d"), + } + } + forward_to = argument.forward_to.value + } +} diff --git a/kubernetes/common/alloy/configs/kubernetes/metrics/integrations-scrape.alloy b/kubernetes/common/alloy/configs/kubernetes/metrics/integrations-scrape.alloy deleted file mode 100644 index 542f1bb0..00000000 --- a/kubernetes/common/alloy/configs/kubernetes/metrics/integrations-scrape.alloy +++ /dev/null @@ -1,79 +0,0 @@ -/* -Module Components: integrations_scrape -Description: Integrations Module Components Scrape - -Note: Every argument except for "forward_to" is optional, and does have a defined default value. However, the values for these - arguments are not defined using the default = " ... " argument syntax, but rather using the coalesce(argument.value, " ... "). - This is because if the argument passed in from another consuming module is set to null, the default = " ... " syntax will - does not override the value passed in, where coalesce() will return the first non-null value. -*/ - -declare "integrations_scrape" { - - /***************************************************************** - * ARGUMENTS - *****************************************************************/ - argument "forward_to" { - comment = "Must be a list(MetricssReceiver) where collected metrics should be forwarded to" - } - - argument "name" { - comment = "Name of the integrations config" - optional = true - } - - argument "namespace" { - comment = "Namespace of the integrations config" - optional = true - } - - /***************************************************************** - * Import Integrations Components - *****************************************************************/ - remote.kubernetes.configmap "integrations" { - namespace = coalesce(argument.namespace.value, "monitoring-system") - name = coalesce(argument.name.value, "alloy-integrations") - } - - /***************************************************************** - * Memcached Integrations - *****************************************************************/ - import.string "memcached" { - content = remote.kubernetes.configmap.integrations.data["memcached.alloy"] - } - - memcached.component_memcached "instance" { - forward_to = argument.forward_to.value - - namespace = argument.namespace.value - name = remote.kubernetes.configmap.integrations.data["MEMCACHED_K8S_SECRET_NAME"] - } - - // /***************************************************************** - // * Redis Integrations - // *****************************************************************/ - // import.string "redis" { - // content = remote.kubernetes.configmap.integrations.data["redis.alloy"] - // } - - // redis.component_redis_exporter "instance" { - // forward_to = argument.forward_to.value - - // namespace = argument.namespace.value - // name = remote.kubernetes.configmap.integrations.data["REDIS_K8S_SECRET_NAME"] - // } - - // /***************************************************************** - // * Mysql Integrations - // *****************************************************************/ - // import.string "mysql" { - // content = remote.kubernetes.configmap.integrations.data["mysql.alloy"] - // } - - // mysql.component_mysql "instance" { - // forward_to = argument.forward_to.value - - // namespace = argument.namespace.value - // name = remote.kubernetes.configmap.integrations.data["MYSQL_K8S_SECRET_NAME"] - // } -} diff --git a/kubernetes/common/alloy/kustomization.yaml b/kubernetes/common/alloy/kustomization.yaml index 47a3ff13..85bd3691 100644 --- a/kubernetes/common/alloy/kustomization.yaml +++ b/kubernetes/common/alloy/kustomization.yaml @@ -22,17 +22,13 @@ configMapGenerator: - name: alloy-modules-kubernetes-metrics namespace: monitoring-system files: - - configs/kubernetes/metrics/integrations-scrape.alloy - configs/kubernetes/metrics/podmonitors-scrape.alloy - configs/kubernetes/metrics/servicemonitors-scrape.alloy -- name: alloy-modules-kubernetes-integrations - namespace: monitoring-system - files: - - configs/kubernetes/integrations/k8s-events.alloy - name: alloy-modules-kubernetes-logs namespace: monitoring-system files: - configs/kubernetes/logs/annotations-scrape.alloy + - configs/kubernetes/logs/k8s-events.alloy - configs/kubernetes/logs/keep-labels.alloy - name: alloy-modules-kubernetes-traces namespace: monitoring-system @@ -43,49 +39,7 @@ configMapGenerator: files: - configs/kubernetes/profiles/annotations-scrape.alloy -# Agent Integrations Config -- name: alloy-integrations - namespace: monitoring-system - options: - disableNameSuffixHash: true - literals: - - MEMCACHED_K8S_SECRET_NAME=alloy-integrations-memcached - # - REDIS_K8S_SECRET_NAME=alloy-integrations-redis - # - MYSQL_K8S_SECRET_NAME=alloy-integrations-mysql - files: - - configs/kubernetes/integrations/memcached.alloy - # - configs/kubernetes/integrations/redis.alloy - # - configs/kubernetes/integrations/mysql.alloy - secretGenerator: - name: alloy-env literals: - ALLOY_LOG_LEVEL=warn -# integrations memcached credentials -- name: alloy-integrations-memcached - namespace: monitoring-system - options: - disableNameSuffixHash: true - literals: - - instance-name=primary - - instance-address=memcached.memcached-system.svc.cluster.local:11211 - - instance-timeout=5s -# # integrations redis credentials -# - name: alloy-integrations-redis -# namespace: monitoring-system -# options: -# disableNameSuffixHash: true -# literals: -# - instance-name=primary -# - instance-address=redis-master.redis-system.svc.cluster.local:6379 -# - instance-password=VD538OYxSEiGD4I9mmFfqFMCGq1vIiGm -# # integrations mysql credentials -# - name: alloy-integrations-mysql -# namespace: monitoring-system -# options: -# disableNameSuffixHash: true -# literals: -# - instance-name=primary -# - mysql-host=mysql.mysql-system.svc.cluster.local -# - mysql-username=lgtmp -# - mysql-password=VD538OYxSEiGD4I9mmFfqFMCGq1vIiGm diff --git a/kubernetes/common/alloy/manifests/k8s-all-in-one.yaml b/kubernetes/common/alloy/manifests/k8s-all-in-one.yaml index 61875b5d..df229540 100644 --- a/kubernetes/common/alloy/manifests/k8s-all-in-one.yaml +++ b/kubernetes/common/alloy/manifests/k8s-all-in-one.yaml @@ -141,76 +141,6 @@ metadata: namespace: monitoring-system --- apiVersion: v1 -data: - MEMCACHED_K8S_SECRET_NAME: alloy-integrations-memcached - memcached.alloy: "/*\nModule Components: component_memcached\n*/\n\ndeclare \"component_memcached\" - {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\tcomment - \ = \"job label (default: integrations/kubernetes/memcached)\"\n\t\toptional = - true\n\t}\n\n\targument \"namespace\" {\n\t\tcomment = \"kubernetes secret name - (default: monitoring-system)\"\n\t\toptional = true\n\t}\n\n\targument \"name\" - {\n\t\tcomment = \"kubernetes secret name (default: alloy-integrations-redis)\"\n\t\toptional - = true\n\t}\n\n\targument \"keep_metrics\" {\n\t\toptional = true\n\t\tdefault - \ = \"(up|memcached_commands_total|memcached_connections_total|memcached_current_bytes|memcached_current_connections|memcached_current_items|memcached_items_evicted_total|memcached_items_total|memcached_max_connections|memcached_read_bytes_total|memcached_up|memcached_uptime_seconds|memcached_version|memcached_written_bytes_total)\"\n\t}\n\n\targument - \"scrape_interval\" {\n\t\tcomment = \"How often to scrape metrics from the targets - (default: 60s)\"\n\t\toptional = true\n\t}\n\n\targument \"scrape_timeout\" {\n\t\tcomment - \ = \"How long before a scrape times out (default: 10s)\"\n\t\toptional = true\n\t}\n\n\tremote.kubernetes.secret - \"memcached\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname - \ = coalesce(argument.name.value, \"alloy-integrations-memcached\")\n\t}\n\n\t/***************************************************************\n\t* - Integrations Memcached\n\t****************************************************************/\n\t// - https://grafana.com/docs/alloy/latest/reference/components/prometheus.exporter.memcached/\n\tprometheus.exporter.memcached - \"integrations_memcached_exporter\" {\n\t\taddress = nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-address\"])\n\t\ttimeout - = nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-timeout\"])\n\t}\n\n\t/***************************************************************\n\t* - Discovery Relabelings (pre-scrape)\n\t****************************************************************/\n\tdiscovery.relabel - \"integrations_memcached_exporter\" {\n\t\ttargets = prometheus.exporter.memcached.integrations_memcached_exporter.targets\n\n\t\trule - {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = coalesce(argument.job_label.value, - \"integrations/kubernetes/memcached\")\n\t\t}\n\n\t\trule {\n\t\t\ttarget_label - = \"instance\"\n\t\t\treplacement = coalesce(nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-name\"]), - constants.hostname)\n\t\t}\n\t}\n\n\t/***************************************************************\n\t* - Prometheus Scrape Integrations Targets\n\t****************************************************************/\n\tprometheus.scrape - \"integrations_memcached_exporter\" {\n\t\ttargets = concat(\n\t\t\tdiscovery.relabel.integrations_memcached_exporter.output,\n\t\t)\n\n\t\tenable_protobuf_negotiation - = true\n\t\tscrape_classic_histograms = true\n\n\t\tscrape_interval = coalesce(argument.scrape_interval.value, - \"60s\")\n\t\tscrape_timeout = coalesce(argument.scrape_timeout.value, \"10s\")\n\n\t\tclustering - {\n\t\t\tenabled = true\n\t\t}\n\n\t\tforward_to = [prometheus.relabel.integrations_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* - Prometheus Metric Relabelings (post-scrape)\n\t****************************************************************/\n\tprometheus.relabel - \"integrations_memcached_exporter\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\t// - keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels - = [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction - \ = \"keep\"\n\t\t}\n\t}\n}\n" -kind: ConfigMap -metadata: - name: alloy-integrations - namespace: monitoring-system ---- -apiVersion: v1 -data: - k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare - \"component_cluster_events\" {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected - logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/eventhandler\"\n\t}\n\n\targument - \"cluster\" {\n\t\toptional = true\n\t\tdefault = \"k3d\"\n\t}\n\n\tloki.source.kubernetes_events - \"cluster_events\" {\n\t\tjob_name = argument.job_label.value\n\t\tlog_format - = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process - \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster - = argument.cluster.value,\n\t\t\t}\n\t\t}\n\t\tforward_to = argument.forward_to.value\n\t}\n\n\t// - // Logs Service\n\t// remote.kubernetes.secret \"logs_service\" {\n\t// \tname - \ = \"loki-k8s-monitoring\"\n\t// \tnamespace = \"k8s-monitoring\"\n\t// }\n\t// - // Loki\n\t// loki.write \"logs_service\" {\n\t// \tendpoint {\n\t// \t\turl = - nonsensitive(remote.kubernetes.secret.logs_service.data[\"host\"]) + \"/loki/api/v1/push\"\n\t// - \t\ttenant_id = nonsensitive(remote.kubernetes.secret.logs_service.data[\"tenantId\"])\n\n\t// - \t\tbasic_auth {\n\t// \t\t\tusername = nonsensitive(remote.kubernetes.secret.logs_service.data[\"username\"])\n\t// - \t\t\tpassword = remote.kubernetes.secret.logs_service.data[\"password\"]\n\t// - \t\t}\n\t// \t}\n\t// }\n}\n" -kind: ConfigMap -metadata: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 - namespace: monitoring-system ---- -apiVersion: v1 data: annotations-scrape.alloy: "/*\nModule Components: annotations_scrape\nDescription: Scrapes targets for logs based on kubernetes Pod annotations\n\n Annotations:\n @@ -304,6 +234,17 @@ data: = {\n\t\t\t\t\tstream = \"\",\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// drop the temporary container runtime label as it is no longer needed\n\t\tstage.label_drop {\n\t\t\tvalues = [\"tmp_container_runtime\"]\n\t\t}\n\t}\n}\n" + k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare + \"kubernetes_cluster_events\" {\n\n\t/*****************************************************************\n\t* + ARGUMENTS\n\t*****************************************************************/\n\targument + \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected + logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional + = true\n\t}\n\n\targument \"cluster\" {\n\t\toptional = true\n\t}\n\n\tloki.source.kubernetes_events + \"cluster_events\" {\n\t\tjob_name = coalesce(argument.job_label.value, \"integrations/kubernetes/eventhandler\")\n\t\tlog_format + = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process + \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster + = coalesce(argument.cluster.value, \"k3d\"),\n\t\t\t}\n\t\t}\n\t\tforward_to = + argument.forward_to.value\n\t}\n}\n" keep-labels.alloy: "/*\nModule Components: keep_labels\nDescription: Pre-defined set of labels to keep, this stage should always be in-place as the previous relabeing\n \ stages make every pod label and annotation a label in the pipeline, @@ -327,42 +268,11 @@ data: \"receiver\" {\n\t\tvalue = loki.process.keep_labels.receiver\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h namespace: monitoring-system --- apiVersion: v1 data: - integrations-scrape.alloy: "/*\nModule Components: integrations_scrape\nDescription: - Integrations Module Components Scrape\n\nNote: Every argument except for \"forward_to\" - is optional, and does have a defined default value. However, the values for these\n - \ arguments are not defined using the default = \" ... \" argument syntax, - but rather using the coalesce(argument.value, \" ... \").\n This is because - if the argument passed in from another consuming module is set to null, the default - = \" ... \" syntax will\n does not override the value passed in, where coalesce() - will return the first non-null value.\n*/\n\ndeclare \"integrations_scrape\" {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"name\" {\n\t\tcomment = - \"Name of the integrations config\"\n\t\toptional = true\n\t}\n\n\targument \"namespace\" - {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional = true\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\tremote.kubernetes.configmap - \"integrations\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname - \ = coalesce(argument.name.value, \"alloy-integrations\")\n\t}\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\timport.string - \"memcached\" {\n\t\tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t}\n\n\tmemcached.component_memcached - \"instance\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tnamespace = - argument.namespace.value\n\t\tname = remote.kubernetes.configmap.integrations.data[\"MEMCACHED_K8S_SECRET_NAME\"]\n\t}\n\n\t// - /*****************************************************************\n\t// * Redis - Integrations\n\t// *****************************************************************/\n\t// - import.string \"redis\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"redis.alloy\"]\n\t// - }\n\n\t// redis.component_redis_exporter \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"REDIS_K8S_SECRET_NAME\"]\n\t// - }\n\n\t// /*****************************************************************\n\t// - * Mysql Integrations\n\t// *****************************************************************/\n\t// - import.string \"mysql\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"mysql.alloy\"]\n\t// - }\n\n\t// mysql.component_mysql \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"MYSQL_K8S_SECRET_NAME\"]\n\t// - }\n}\n" podmonitors-scrape.alloy: "/*\nModule Components: podmonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.podmonitors\n*/\n\ndeclare \"podmonitors_scrape\" {\n\n\t/*****************************************************************\n\t* @@ -395,7 +305,7 @@ data: {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 namespace: monitoring-system --- apiVersion: v1 @@ -728,17 +638,6 @@ metadata: type: Opaque --- apiVersion: v1 -data: - instance-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= - instance-name: cHJpbWFyeQ== - instance-timeout: NXM= -kind: Secret -metadata: - name: alloy-integrations-memcached - namespace: monitoring-system -type: Opaque ---- -apiVersion: v1 kind: Service metadata: labels: @@ -844,7 +743,6 @@ spec: annotations: kubectl.kubernetes.io/default-container: alloy logs.agent.grafana.com/scrape: "true" - logs.agent.grafana.com/scrub-level: debug profiles.grafana.com/cpu.port_name: http-metrics profiles.grafana.com/cpu.scrape: "false" profiles.grafana.com/goroutine.port_name: http-metrics @@ -908,8 +806,6 @@ spec: name: config - mountPath: /etc/alloy/modules/kubernetes/metrics name: modules-kubernetes-metrics - - mountPath: /etc/alloy/modules/kubernetes/integrations - name: modules-kubernetes-integrations - mountPath: /etc/alloy/modules/kubernetes/logs name: modules-kubernetes-logs - mountPath: /etc/alloy/modules/kubernetes/traces @@ -925,13 +821,10 @@ spec: name: alloy-config-ftt29f8k85 name: config - configMap: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 - name: modules-kubernetes-integrations - - configMap: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h name: modules-kubernetes-logs - configMap: name: alloy-modules-kubernetes-traces-8mgm8th9m5 diff --git a/kubernetes/common/alloy/values-k3d-k3s.yaml b/kubernetes/common/alloy/values-k3d-k3s.yaml index 6575fc77..899c9a86 100644 --- a/kubernetes/common/alloy/values-k3d-k3s.yaml +++ b/kubernetes/common/alloy/values-k3d-k3s.yaml @@ -21,8 +21,6 @@ alloy: extra: - name: modules-kubernetes-metrics mountPath: /etc/alloy/modules/kubernetes/metrics - - name: modules-kubernetes-integrations - mountPath: /etc/alloy/modules/kubernetes/integrations - name: modules-kubernetes-logs mountPath: /etc/alloy/modules/kubernetes/logs - name: modules-kubernetes-traces @@ -65,9 +63,6 @@ controller: - name: modules-kubernetes-metrics configMap: name: alloy-modules-kubernetes-metrics - - name: modules-kubernetes-integrations - configMap: - name: alloy-modules-kubernetes-integrations - name: modules-kubernetes-logs configMap: name: alloy-modules-kubernetes-logs @@ -78,9 +73,8 @@ controller: configMap: name: alloy-modules-kubernetes-profiles podAnnotations: - # https://github.com/grafana/agent-modules/tree/main/modules/kubernetes + # https://github.com/qclaogui/codelab-monitoring/blob/main/alloy-modules/compose/README.md logs.agent.grafana.com/scrape: "true" - logs.agent.grafana.com/scrub-level: "debug" # Boolean whether or not the level should be dropped from the log message (as it is a label). # logs.agent.grafana.com/tenant: ".*" # Allow a pod to override the tenant for its logs. pyroscope.io/service_name: alloy profiles.grafana.com/memory.scrape: "false" diff --git a/kubernetes/microservices-mode/logs/k8s-all-in-one.yaml b/kubernetes/microservices-mode/logs/k8s-all-in-one.yaml index ce3e3841..dffdfa16 100644 --- a/kubernetes/microservices-mode/logs/k8s-all-in-one.yaml +++ b/kubernetes/microservices-mode/logs/k8s-all-in-one.yaml @@ -346,19 +346,33 @@ data: = [provider.self_hosted_stack.kubernetes.logs_receiver]\n}\n\n/********************************************\n * Metrics\n ********************************************/\nimport.file \"metrics\" {\n\tfilename = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") - + \"/kubernetes/metrics\"\n}\n\nmetrics.integrations_scrape \"kubernetes\" {\n\tforward_to - = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.podmonitors_scrape - \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape - \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n" + + \"/kubernetes/metrics\"\n}\n\nmetrics.podmonitors_scrape \"kubernetes\" {\n\tforward_to + = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape + \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\n/*****************************************************************\n* + Alloy Integrations\n*****************************************************************/\nremote.kubernetes.configmap + \"integrations\" {\n\tnamespace = \"monitoring-system\"\n\tname = \"alloy-integrations\"\n}\n\n// + Memcached Integrations\nimport.string \"memcached\" {\n\tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n}\n\nmemcached.memcached_metrics_scrape + \"instance\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n\n\tnamespace + = \"monitoring-system\"\n\tname = remote.kubernetes.configmap.integrations.data[\"MEMCACHED_K8S_SECRET_NAME\"]\n}\n\n// + // Redis Integrations\n// import.string \"redis\" {\n// \tcontent = remote.kubernetes.configmap.integrations.data[\"redis.alloy\"]\n// + }\n\n// redis.redis_exporter_metrics_scrape \"instance\" {\n// \tforward_to = + [provider.self_hosted_stack.kubernetes.metrics_receiver]\n\n// \tnamespace = \"monitoring-system\"\n// + \tname = remote.kubernetes.configmap.integrations.data[\"REDIS_K8S_SECRET_NAME\"]\n// + }\n\n// // Mysql Integrations\n// import.string \"mysql\" {\n// \tcontent = remote.kubernetes.configmap.integrations.data[\"mysql.alloy\"]\n// + }\n\n// mysql.mysql_metrics_scrape \"instance\" {\n// \tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n\n// + \tnamespace = \"monitoring-system\"\n// \tname = remote.kubernetes.configmap.integrations.data[\"MYSQL_K8S_SECRET_NAME\"]\n// + }\n" kind: ConfigMap metadata: - name: alloy-config-8t9d8htff7 + name: alloy-config-72927d7k99 namespace: monitoring-system --- apiVersion: v1 data: MEMCACHED_K8S_SECRET_NAME: alloy-integrations-memcached - memcached.alloy: "/*\nModule Components: component_memcached\n*/\n\ndeclare \"component_memcached\" + MYSQL_K8S_SECRET_NAME: alloy-integrations-mysql + REDIS_K8S_SECRET_NAME: alloy-integrations-redis + memcached.alloy: "/*\nModule Components: component_memcached\n*/\n\ndeclare \"memcached_metrics_scrape\" {\n\n\t/*****************************************************************\n\t* ARGUMENTS\n\t*****************************************************************/\n\targument \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected @@ -394,35 +408,81 @@ data: keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels = [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction \ = \"keep\"\n\t\t}\n\t}\n}\n" -kind: ConfigMap -metadata: - name: alloy-integrations - namespace: monitoring-system ---- -apiVersion: v1 -data: - k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare - \"component_cluster_events\" {\n\n\t/*****************************************************************\n\t* + mysql.alloy: "/*\nModule Components: component_mysql\n*/\n\ndeclare \"mysql_metrics_scrape\" + {\n\n\t/*****************************************************************\n\t* ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected - logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/eventhandler\"\n\t}\n\n\targument - \"cluster\" {\n\t\toptional = true\n\t\tdefault = \"k3d\"\n\t}\n\n\tloki.source.kubernetes_events - \"cluster_events\" {\n\t\tjob_name = argument.job_label.value\n\t\tlog_format - = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process - \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster - = argument.cluster.value,\n\t\t\t}\n\t\t}\n\t\tforward_to = argument.forward_to.value\n\t}\n\n\t// - // Logs Service\n\t// remote.kubernetes.secret \"logs_service\" {\n\t// \tname - \ = \"loki-k8s-monitoring\"\n\t// \tnamespace = \"k8s-monitoring\"\n\t// }\n\t// - // Loki\n\t// loki.write \"logs_service\" {\n\t// \tendpoint {\n\t// \t\turl = - nonsensitive(remote.kubernetes.secret.logs_service.data[\"host\"]) + \"/loki/api/v1/push\"\n\t// - \t\ttenant_id = nonsensitive(remote.kubernetes.secret.logs_service.data[\"tenantId\"])\n\n\t// - \t\tbasic_auth {\n\t// \t\t\tusername = nonsensitive(remote.kubernetes.secret.logs_service.data[\"username\"])\n\t// - \t\t\tpassword = remote.kubernetes.secret.logs_service.data[\"password\"]\n\t// - \t\t}\n\t// \t}\n\t// }\n}\n" + \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected + metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\tcomment + \ = \"job label (default: integrations/kubernetes/mysql)\"\n\t\toptional = true\n\t}\n\n\targument + \"namespace\" {\n\t\tcomment = \"kubernetes secret name (default: monitoring-system)\"\n\t\toptional + = true\n\t}\n\n\targument \"name\" {\n\t\tcomment = \"kubernetes secret name + (default: alloy-integrations-mysql)\"\n\t\toptional = true\n\t}\n\n\targument + \"keep_metrics\" {\n\t\toptional = true\n\t\tdefault = \"(up|instance:mysql_heartbeat_lag_seconds|instance:mysql_slave_lag_seconds|mysql_global_status_aborted_clients|mysql_global_status_aborted_connects|mysql_global_status_buffer_pool_pages|mysql_global_status_bytes_received|mysql_global_status_bytes_sent|mysql_global_status_commands_total|mysql_global_status_created_tmp_disk_tables|mysql_global_status_created_tmp_files|mysql_global_status_created_tmp_tables|mysql_global_status_handlers_total|mysql_global_status_innodb_log_waits|mysql_global_status_innodb_mem_adaptive_hash|mysql_global_status_innodb_mem_dictionary|mysql_global_status_innodb_num_open_files|mysql_global_status_innodb_page_size|mysql_global_status_max_used_connections|mysql_global_status_open_files|mysql_global_status_open_table_definitions|mysql_global_status_open_tables|mysql_global_status_opened_files|mysql_global_status_opened_table_definitions|mysql_global_status_opened_tables|mysql_global_status_qcache_free_memory|mysql_global_status_qcache_hits|mysql_global_status_qcache_inserts|mysql_global_status_qcache_lowmem_prunes|mysql_global_status_qcache_not_cached|mysql_global_status_qcache_queries_in_cache|mysql_global_status_queries|mysql_global_status_questions|mysql_global_status_select_full_join|mysql_global_status_select_full_range_join|mysql_global_status_select_range|mysql_global_status_select_range_check|mysql_global_status_select_scan|mysql_global_status_slow_queries|mysql_global_status_sort_merge_passes|mysql_global_status_sort_range|mysql_global_status_sort_rows|mysql_global_status_sort_scan|mysql_global_status_table_locks_immediate|mysql_global_status_table_locks_waited|mysql_global_status_table_open_cache_hits|mysql_global_status_table_open_cache_misses|mysql_global_status_table_open_cache_overflows|mysql_global_status_threads_cached|mysql_global_status_threads_connected|mysql_global_status_threads_created|mysql_global_status_threads_running|mysql_global_status_uptime|mysql_global_status_wsrep_local_recv_queue|mysql_global_status_wsrep_local_state|mysql_global_status_wsrep_ready|mysql_global_variables_innodb_additional_mem_pool_size|mysql_global_variables_innodb_buffer_pool_size|mysql_global_variables_innodb_log_buffer_size|mysql_global_variables_key_buffer_size|mysql_global_variables_max_connections|mysql_global_variables_open_files_limit|mysql_global_variables_query_cache_size|mysql_global_variables_table_definition_cache|mysql_global_variables_table_open_cache|mysql_global_variables_thread_cache_size|mysql_global_variables_tokudb_cache_size|mysql_global_variables_wsrep_desync|mysql_heartbeat_now_timestamp_seconds|mysql_heartbeat_stored_timestamp_seconds|mysql_info_schema_processlist_threads|mysql_slave_status_seconds_behind_master|mysql_slave_status_slave_io_running|mysql_slave_status_slave_sql_running|mysql_slave_status_sql_delay|mysql_up)\"\n\t}\n\n\targument + \"scrape_interval\" {\n\t\tcomment = \"How often to scrape metrics from the targets + (default: 60s)\"\n\t\toptional = true\n\t}\n\n\targument \"scrape_timeout\" {\n\t\tcomment + \ = \"How long before a scrape times out (default: 10s)\"\n\t\toptional = true\n\t}\n\n\tremote.kubernetes.secret + \"mysql\" {\n\t\tname = coalesce(argument.name.value, \"alloy-integrations-mysql\")\n\t\tnamespace + = coalesce(argument.namespace.value, \"monitoring-system\")\n\t}\n\n\t/***************************************************************\n\t* + Integrations Mysql\n\t****************************************************************/\n\tprometheus.exporter.mysql + \"integrations_mysqld_exporter\" {\n\t\tdata_source_name = nonsensitive(remote.kubernetes.secret.mysql.data[\"mysql-username\"]) + + \":\" + nonsensitive(remote.kubernetes.secret.mysql.data[\"mysql-password\"]) + + \"@(\" + nonsensitive(remote.kubernetes.secret.mysql.data[\"mysql-host\"]) + + \")/\"\n\t}\n\n\t/***************************************************************\n\t* + Discovery Relabelings (pre-scrape)\n\t****************************************************************/\n\tdiscovery.relabel + \"integrations_mysqld_exporter\" {\n\t\ttargets = prometheus.exporter.mysql.integrations_mysqld_exporter.targets\n\n\t\trule + {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = coalesce(argument.job_label.value, + \"integrations/kubernetes/mysql\")\n\t\t}\n\n\t\trule {\n\t\t\ttarget_label = + \"instance\"\n\t\t\treplacement = coalesce(nonsensitive(remote.kubernetes.secret.mysql.data[\"instance-name\"]), + constants.hostname)\n\t\t}\n\t}\n\n\t/***************************************************************\n\t* + Prometheus Scrape Integrations Targets\n\t****************************************************************/\n\tprometheus.scrape + \"integrations_mysqld_exporter\" {\n\t\ttargets = concat(\n\t\t\tdiscovery.relabel.integrations_mysqld_exporter.output,\n\t\t)\n\n\t\tenable_protobuf_negotiation + = true\n\t\tscrape_classic_histograms = true\n\n\t\tscrape_interval = coalesce(argument.scrape_interval.value, + \"60s\")\n\t\tscrape_timeout = coalesce(argument.scrape_timeout.value, \"10s\")\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\n\t\tforward_to = [prometheus.relabel.integrations_mysqld_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* + Prometheus Metric Relabelings (post-scrape)\n\t****************************************************************/\n\tprometheus.relabel + \"integrations_mysqld_exporter\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\t// + keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels + = [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction + \ = \"keep\"\n\t\t}\n\t}\n}\n" + redis.alloy: "/*\nModule Components: component_redis_exporter\n*/\n\ndeclare \"redis_exporter_metrics_scrape\" + {\n\n\t/*****************************************************************\n\t* + ARGUMENTS\n\t*****************************************************************/\n\targument + \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected + metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\tcomment + \ = \"job label (default: integrations/kubernetes/redis_exporter)\"\n\t\toptional + = true\n\t}\n\n\targument \"namespace\" {\n\t\tcomment = \"kubernetes secret + name (default: monitoring-system)\"\n\t\toptional = true\n\t}\n\n\targument \"name\" + {\n\t\tcomment = \"kubernetes secret name (default: alloy-integrations-redis)\"\n\t\toptional + = true\n\t}\n\n\targument \"keep_metrics\" {\n\t\toptional = true\n\t\tdefault + \ = \"(up|redis_blocked_clients|redis_cluster_slots_fail|redis_cluster_slots_pfail|redis_cluster_state|redis_commands_duration_seconds_total|redis_commands_total|redis_connected_clients|redis_connected_slaves|redis_db_keys|redis_db_keys_expiring|redis_evicted_keys_total|redis_keyspace_hits_total|redis_keyspace_misses_total|redis_master_last_io_seconds_ago|redis_memory_fragmentation_ratio|redis_memory_max_bytes|redis_memory_used_bytes|redis_memory_used_rss_bytes|redis_total_system_memory_bytes|redis_up)\"\n\t}\n\n\targument + \"scrape_interval\" {\n\t\tcomment = \"How often to scrape metrics from the targets + (default: 60s)\"\n\t\toptional = true\n\t\tdefault = \"60s\"\n\t}\n\n\targument + \"scrape_timeout\" {\n\t\tcomment = \"How long before a scrape times out (default: + 10s)\"\n\t\toptional = true\n\t\tdefault = \"10s\"\n\t}\n\n\tremote.kubernetes.secret + \"redis\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname + \ = coalesce(argument.name.value, \"alloy-integrations-redis\")\n\t}\n\n\t/***************************************************************\n\t* + Integrations Redis\n\t****************************************************************/\n\tprometheus.exporter.redis + \"integrations_redis_exporter\" {\n\t\tredis_addr = nonsensitive(remote.kubernetes.secret.redis.data[\"instance-address\"])\n\t\tredis_password + = nonsensitive(remote.kubernetes.secret.redis.data[\"instance-password\"])\n\t}\n\n\t/***************************************************************\n\t* + Discovery Relabelings (pre-scrape)\n\t****************************************************************/\n\tdiscovery.relabel + \"integrations_redis_exporter\" {\n\t\ttargets = prometheus.exporter.redis.integrations_redis_exporter.targets\n\n\t\trule + {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = coalesce(argument.job_label.value, + \"integrations/kubernetes/redis_exporter\")\n\t\t}\n\n\t\trule {\n\t\t\ttarget_label + = \"instance\"\n\t\t\treplacement = coalesce(nonsensitive(remote.kubernetes.secret.redis.data[\"instance-name\"]), + constants.hostname)\n\t\t}\n\t}\n\n\t/***************************************************************\n\t* + Prometheus Scrape Integrations Targets\n\t****************************************************************/\n\tprometheus.scrape + \"integrations_redis_exporter\" {\n\t\ttargets = concat(\n\t\t\tdiscovery.relabel.integrations_redis_exporter.output,\n\t\t)\n\n\t\tenable_protobuf_negotiation + = true\n\t\tscrape_classic_histograms = true\n\n\t\tscrape_interval = argument.scrape_interval.value\n\t\tscrape_timeout + \ = argument.scrape_timeout.value\n\n\t\tclustering {\n\t\t\tenabled = true\n\t\t}\n\n\t\tforward_to + = [prometheus.relabel.integrations_redis_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* + Prometheus Metric Relabelings (post-scrape)\n\t****************************************************************/\n\tprometheus.relabel + \"integrations_redis_exporter\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\t// + keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels + = [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction + \ = \"keep\"\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 + name: alloy-integrations namespace: monitoring-system --- apiVersion: v1 @@ -519,6 +579,17 @@ data: = {\n\t\t\t\t\tstream = \"\",\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// drop the temporary container runtime label as it is no longer needed\n\t\tstage.label_drop {\n\t\t\tvalues = [\"tmp_container_runtime\"]\n\t\t}\n\t}\n}\n" + k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare + \"kubernetes_cluster_events\" {\n\n\t/*****************************************************************\n\t* + ARGUMENTS\n\t*****************************************************************/\n\targument + \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected + logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional + = true\n\t}\n\n\targument \"cluster\" {\n\t\toptional = true\n\t}\n\n\tloki.source.kubernetes_events + \"cluster_events\" {\n\t\tjob_name = coalesce(argument.job_label.value, \"integrations/kubernetes/eventhandler\")\n\t\tlog_format + = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process + \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster + = coalesce(argument.cluster.value, \"k3d\"),\n\t\t\t}\n\t\t}\n\t\tforward_to = + argument.forward_to.value\n\t}\n}\n" keep-labels.alloy: "/*\nModule Components: keep_labels\nDescription: Pre-defined set of labels to keep, this stage should always be in-place as the previous relabeing\n \ stages make every pod label and annotation a label in the pipeline, @@ -542,42 +613,11 @@ data: \"receiver\" {\n\t\tvalue = loki.process.keep_labels.receiver\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h namespace: monitoring-system --- apiVersion: v1 data: - integrations-scrape.alloy: "/*\nModule Components: integrations_scrape\nDescription: - Integrations Module Components Scrape\n\nNote: Every argument except for \"forward_to\" - is optional, and does have a defined default value. However, the values for these\n - \ arguments are not defined using the default = \" ... \" argument syntax, - but rather using the coalesce(argument.value, \" ... \").\n This is because - if the argument passed in from another consuming module is set to null, the default - = \" ... \" syntax will\n does not override the value passed in, where coalesce() - will return the first non-null value.\n*/\n\ndeclare \"integrations_scrape\" {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"name\" {\n\t\tcomment = - \"Name of the integrations config\"\n\t\toptional = true\n\t}\n\n\targument \"namespace\" - {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional = true\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\tremote.kubernetes.configmap - \"integrations\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname - \ = coalesce(argument.name.value, \"alloy-integrations\")\n\t}\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\timport.string - \"memcached\" {\n\t\tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t}\n\n\tmemcached.component_memcached - \"instance\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tnamespace = - argument.namespace.value\n\t\tname = remote.kubernetes.configmap.integrations.data[\"MEMCACHED_K8S_SECRET_NAME\"]\n\t}\n\n\t// - /*****************************************************************\n\t// * Redis - Integrations\n\t// *****************************************************************/\n\t// - import.string \"redis\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"redis.alloy\"]\n\t// - }\n\n\t// redis.component_redis_exporter \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"REDIS_K8S_SECRET_NAME\"]\n\t// - }\n\n\t// /*****************************************************************\n\t// - * Mysql Integrations\n\t// *****************************************************************/\n\t// - import.string \"mysql\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"mysql.alloy\"]\n\t// - }\n\n\t// mysql.component_mysql \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"MYSQL_K8S_SECRET_NAME\"]\n\t// - }\n}\n" podmonitors-scrape.alloy: "/*\nModule Components: podmonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.podmonitors\n*/\n\ndeclare \"podmonitors_scrape\" {\n\n\t/*****************************************************************\n\t* @@ -610,7 +650,7 @@ data: {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 namespace: monitoring-system --- apiVersion: v1 @@ -1104,6 +1144,29 @@ metadata: type: Opaque --- apiVersion: v1 +data: + instance-name: cHJpbWFyeQ== + mysql-host: bXlzcWwubXlzcWwtc3lzdGVtLnN2Yy5jbHVzdGVyLmxvY2Fs + mysql-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= + mysql-username: bGd0bXA= +kind: Secret +metadata: + name: alloy-integrations-mysql + namespace: monitoring-system +type: Opaque +--- +apiVersion: v1 +data: + instance-address: cmVkaXMtbWFzdGVyLnJlZGlzLXN5c3RlbS5zdmMuY2x1c3Rlci5sb2NhbDo2Mzc5 + instance-name: cHJpbWFyeQ== + instance-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= +kind: Secret +metadata: + name: alloy-integrations-redis + namespace: monitoring-system +type: Opaque +--- +apiVersion: v1 data: MIMIR_S3_SECRET_ACCESS_KEY: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= kind: Secret @@ -2908,7 +2971,6 @@ spec: annotations: kubectl.kubernetes.io/default-container: alloy logs.agent.grafana.com/scrape: "true" - logs.agent.grafana.com/scrub-level: debug profiles.grafana.com/cpu.port_name: http-metrics profiles.grafana.com/cpu.scrape: "false" profiles.grafana.com/goroutine.port_name: http-metrics @@ -2972,8 +3034,6 @@ spec: name: config - mountPath: /etc/alloy/modules/kubernetes/metrics name: modules-kubernetes-metrics - - mountPath: /etc/alloy/modules/kubernetes/integrations - name: modules-kubernetes-integrations - mountPath: /etc/alloy/modules/kubernetes/logs name: modules-kubernetes-logs - mountPath: /etc/alloy/modules/kubernetes/traces @@ -2986,16 +3046,13 @@ spec: serviceAccountName: alloy volumes: - configMap: - name: alloy-config-8t9d8htff7 + name: alloy-config-72927d7k99 name: config - configMap: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 - name: modules-kubernetes-integrations - - configMap: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h name: modules-kubernetes-logs - configMap: name: alloy-modules-kubernetes-traces-8mgm8th9m5 diff --git a/kubernetes/microservices-mode/logs/kustomization.yaml b/kubernetes/microservices-mode/logs/kustomization.yaml index 94625eb6..518db9ea 100644 --- a/kubernetes/microservices-mode/logs/kustomization.yaml +++ b/kubernetes/microservices-mode/logs/kustomization.yaml @@ -9,6 +9,7 @@ kind: Kustomization resources: - ../../common/alloy +- ../../common/alloy/configs/kubernetes/integrations - loki # optional diff --git a/kubernetes/microservices-mode/logs/logs.alloy b/kubernetes/microservices-mode/logs/logs.alloy index 1915e1ac..514a59e7 100644 --- a/kubernetes/microservices-mode/logs/logs.alloy +++ b/kubernetes/microservices-mode/logs/logs.alloy @@ -41,14 +41,54 @@ import.file "metrics" { filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/kubernetes/metrics" } -metrics.integrations_scrape "kubernetes" { +metrics.podmonitors_scrape "kubernetes" { forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] } -metrics.podmonitors_scrape "kubernetes" { +metrics.servicemonitors_scrape "kubernetes" { forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] } -metrics.servicemonitors_scrape "kubernetes" { +/***************************************************************** +* Alloy Integrations +*****************************************************************/ +remote.kubernetes.configmap "integrations" { + namespace = "monitoring-system" + name = "alloy-integrations" +} + +// Memcached Integrations +import.string "memcached" { + content = remote.kubernetes.configmap.integrations.data["memcached.alloy"] +} + +memcached.memcached_metrics_scrape "instance" { forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] + + namespace = "monitoring-system" + name = remote.kubernetes.configmap.integrations.data["MEMCACHED_K8S_SECRET_NAME"] } + +// // Redis Integrations +// import.string "redis" { +// content = remote.kubernetes.configmap.integrations.data["redis.alloy"] +// } + +// redis.redis_exporter_metrics_scrape "instance" { +// forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] + +// namespace = "monitoring-system" +// name = remote.kubernetes.configmap.integrations.data["REDIS_K8S_SECRET_NAME"] +// } + +// // Mysql Integrations +// import.string "mysql" { +// content = remote.kubernetes.configmap.integrations.data["mysql.alloy"] +// } + +// mysql.mysql_metrics_scrape "instance" { +// forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] + +// namespace = "monitoring-system" +// name = remote.kubernetes.configmap.integrations.data["MYSQL_K8S_SECRET_NAME"] +// } diff --git a/kubernetes/microservices-mode/metrics/k8s-all-in-one.yaml b/kubernetes/microservices-mode/metrics/k8s-all-in-one.yaml index 40e6feea..10998a43 100644 --- a/kubernetes/microservices-mode/metrics/k8s-all-in-one.yaml +++ b/kubernetes/microservices-mode/metrics/k8s-all-in-one.yaml @@ -166,86 +166,15 @@ data: = coalesce(env(\"SELF_HOSTED_METRICS_ENDPOINT_URL\"), \"http://nginx.gateway.svc:8080/api/v1/push\")\n}\n\n/********************************************\n * Metrics\n ********************************************/\nimport.file \"metrics\" {\n\tfilename = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") - + \"/kubernetes/metrics\"\n}\n\nmetrics.integrations_scrape \"kubernetes\" {\n\tforward_to - = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.podmonitors_scrape - \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape + + \"/kubernetes/metrics\"\n}\n\nmetrics.podmonitors_scrape \"kubernetes\" {\n\tforward_to + = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\n// metrics.annotations_scrape \"kubernetes\" {\n// \tlabel_prefix = \"metrics.grafana.com\"\n// \tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n// \tscrape_interval = \"15s\"\n// }\n" kind: ConfigMap metadata: - name: alloy-config-m6chdfm49m - namespace: monitoring-system ---- -apiVersion: v1 -data: - MEMCACHED_K8S_SECRET_NAME: alloy-integrations-memcached - memcached.alloy: "/*\nModule Components: component_memcached\n*/\n\ndeclare \"component_memcached\" - {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\tcomment - \ = \"job label (default: integrations/kubernetes/memcached)\"\n\t\toptional = - true\n\t}\n\n\targument \"namespace\" {\n\t\tcomment = \"kubernetes secret name - (default: monitoring-system)\"\n\t\toptional = true\n\t}\n\n\targument \"name\" - {\n\t\tcomment = \"kubernetes secret name (default: alloy-integrations-redis)\"\n\t\toptional - = true\n\t}\n\n\targument \"keep_metrics\" {\n\t\toptional = true\n\t\tdefault - \ = \"(up|memcached_commands_total|memcached_connections_total|memcached_current_bytes|memcached_current_connections|memcached_current_items|memcached_items_evicted_total|memcached_items_total|memcached_max_connections|memcached_read_bytes_total|memcached_up|memcached_uptime_seconds|memcached_version|memcached_written_bytes_total)\"\n\t}\n\n\targument - \"scrape_interval\" {\n\t\tcomment = \"How often to scrape metrics from the targets - (default: 60s)\"\n\t\toptional = true\n\t}\n\n\targument \"scrape_timeout\" {\n\t\tcomment - \ = \"How long before a scrape times out (default: 10s)\"\n\t\toptional = true\n\t}\n\n\tremote.kubernetes.secret - \"memcached\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname - \ = coalesce(argument.name.value, \"alloy-integrations-memcached\")\n\t}\n\n\t/***************************************************************\n\t* - Integrations Memcached\n\t****************************************************************/\n\t// - https://grafana.com/docs/alloy/latest/reference/components/prometheus.exporter.memcached/\n\tprometheus.exporter.memcached - \"integrations_memcached_exporter\" {\n\t\taddress = nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-address\"])\n\t\ttimeout - = nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-timeout\"])\n\t}\n\n\t/***************************************************************\n\t* - Discovery Relabelings (pre-scrape)\n\t****************************************************************/\n\tdiscovery.relabel - \"integrations_memcached_exporter\" {\n\t\ttargets = prometheus.exporter.memcached.integrations_memcached_exporter.targets\n\n\t\trule - {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = coalesce(argument.job_label.value, - \"integrations/kubernetes/memcached\")\n\t\t}\n\n\t\trule {\n\t\t\ttarget_label - = \"instance\"\n\t\t\treplacement = coalesce(nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-name\"]), - constants.hostname)\n\t\t}\n\t}\n\n\t/***************************************************************\n\t* - Prometheus Scrape Integrations Targets\n\t****************************************************************/\n\tprometheus.scrape - \"integrations_memcached_exporter\" {\n\t\ttargets = concat(\n\t\t\tdiscovery.relabel.integrations_memcached_exporter.output,\n\t\t)\n\n\t\tenable_protobuf_negotiation - = true\n\t\tscrape_classic_histograms = true\n\n\t\tscrape_interval = coalesce(argument.scrape_interval.value, - \"60s\")\n\t\tscrape_timeout = coalesce(argument.scrape_timeout.value, \"10s\")\n\n\t\tclustering - {\n\t\t\tenabled = true\n\t\t}\n\n\t\tforward_to = [prometheus.relabel.integrations_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* - Prometheus Metric Relabelings (post-scrape)\n\t****************************************************************/\n\tprometheus.relabel - \"integrations_memcached_exporter\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\t// - keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels - = [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction - \ = \"keep\"\n\t\t}\n\t}\n}\n" -kind: ConfigMap -metadata: - name: alloy-integrations - namespace: monitoring-system ---- -apiVersion: v1 -data: - k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare - \"component_cluster_events\" {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected - logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/eventhandler\"\n\t}\n\n\targument - \"cluster\" {\n\t\toptional = true\n\t\tdefault = \"k3d\"\n\t}\n\n\tloki.source.kubernetes_events - \"cluster_events\" {\n\t\tjob_name = argument.job_label.value\n\t\tlog_format - = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process - \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster - = argument.cluster.value,\n\t\t\t}\n\t\t}\n\t\tforward_to = argument.forward_to.value\n\t}\n\n\t// - // Logs Service\n\t// remote.kubernetes.secret \"logs_service\" {\n\t// \tname - \ = \"loki-k8s-monitoring\"\n\t// \tnamespace = \"k8s-monitoring\"\n\t// }\n\t// - // Loki\n\t// loki.write \"logs_service\" {\n\t// \tendpoint {\n\t// \t\turl = - nonsensitive(remote.kubernetes.secret.logs_service.data[\"host\"]) + \"/loki/api/v1/push\"\n\t// - \t\ttenant_id = nonsensitive(remote.kubernetes.secret.logs_service.data[\"tenantId\"])\n\n\t// - \t\tbasic_auth {\n\t// \t\t\tusername = nonsensitive(remote.kubernetes.secret.logs_service.data[\"username\"])\n\t// - \t\t\tpassword = remote.kubernetes.secret.logs_service.data[\"password\"]\n\t// - \t\t}\n\t// \t}\n\t// }\n}\n" -kind: ConfigMap -metadata: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 + name: alloy-config-55dd47md5f namespace: monitoring-system --- apiVersion: v1 @@ -342,6 +271,17 @@ data: = {\n\t\t\t\t\tstream = \"\",\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// drop the temporary container runtime label as it is no longer needed\n\t\tstage.label_drop {\n\t\t\tvalues = [\"tmp_container_runtime\"]\n\t\t}\n\t}\n}\n" + k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare + \"kubernetes_cluster_events\" {\n\n\t/*****************************************************************\n\t* + ARGUMENTS\n\t*****************************************************************/\n\targument + \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected + logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional + = true\n\t}\n\n\targument \"cluster\" {\n\t\toptional = true\n\t}\n\n\tloki.source.kubernetes_events + \"cluster_events\" {\n\t\tjob_name = coalesce(argument.job_label.value, \"integrations/kubernetes/eventhandler\")\n\t\tlog_format + = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process + \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster + = coalesce(argument.cluster.value, \"k3d\"),\n\t\t\t}\n\t\t}\n\t\tforward_to = + argument.forward_to.value\n\t}\n}\n" keep-labels.alloy: "/*\nModule Components: keep_labels\nDescription: Pre-defined set of labels to keep, this stage should always be in-place as the previous relabeing\n \ stages make every pod label and annotation a label in the pipeline, @@ -365,42 +305,11 @@ data: \"receiver\" {\n\t\tvalue = loki.process.keep_labels.receiver\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h namespace: monitoring-system --- apiVersion: v1 data: - integrations-scrape.alloy: "/*\nModule Components: integrations_scrape\nDescription: - Integrations Module Components Scrape\n\nNote: Every argument except for \"forward_to\" - is optional, and does have a defined default value. However, the values for these\n - \ arguments are not defined using the default = \" ... \" argument syntax, - but rather using the coalesce(argument.value, \" ... \").\n This is because - if the argument passed in from another consuming module is set to null, the default - = \" ... \" syntax will\n does not override the value passed in, where coalesce() - will return the first non-null value.\n*/\n\ndeclare \"integrations_scrape\" {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"name\" {\n\t\tcomment = - \"Name of the integrations config\"\n\t\toptional = true\n\t}\n\n\targument \"namespace\" - {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional = true\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\tremote.kubernetes.configmap - \"integrations\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname - \ = coalesce(argument.name.value, \"alloy-integrations\")\n\t}\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\timport.string - \"memcached\" {\n\t\tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t}\n\n\tmemcached.component_memcached - \"instance\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tnamespace = - argument.namespace.value\n\t\tname = remote.kubernetes.configmap.integrations.data[\"MEMCACHED_K8S_SECRET_NAME\"]\n\t}\n\n\t// - /*****************************************************************\n\t// * Redis - Integrations\n\t// *****************************************************************/\n\t// - import.string \"redis\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"redis.alloy\"]\n\t// - }\n\n\t// redis.component_redis_exporter \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"REDIS_K8S_SECRET_NAME\"]\n\t// - }\n\n\t// /*****************************************************************\n\t// - * Mysql Integrations\n\t// *****************************************************************/\n\t// - import.string \"mysql\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"mysql.alloy\"]\n\t// - }\n\n\t// mysql.component_mysql \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"MYSQL_K8S_SECRET_NAME\"]\n\t// - }\n}\n" podmonitors-scrape.alloy: "/*\nModule Components: podmonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.podmonitors\n*/\n\ndeclare \"podmonitors_scrape\" {\n\n\t/*****************************************************************\n\t* @@ -433,7 +342,7 @@ data: {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 namespace: monitoring-system --- apiVersion: v1 @@ -981,17 +890,6 @@ metadata: type: Opaque --- apiVersion: v1 -data: - instance-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= - instance-name: cHJpbWFyeQ== - instance-timeout: NXM= -kind: Secret -metadata: - name: alloy-integrations-memcached - namespace: monitoring-system -type: Opaque ---- -apiVersion: v1 data: MIMIR_S3_SECRET_ACCESS_KEY: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= kind: Secret @@ -2290,7 +2188,6 @@ spec: annotations: kubectl.kubernetes.io/default-container: alloy logs.agent.grafana.com/scrape: "true" - logs.agent.grafana.com/scrub-level: debug profiles.grafana.com/cpu.port_name: http-metrics profiles.grafana.com/cpu.scrape: "false" profiles.grafana.com/goroutine.port_name: http-metrics @@ -2354,8 +2251,6 @@ spec: name: config - mountPath: /etc/alloy/modules/kubernetes/metrics name: modules-kubernetes-metrics - - mountPath: /etc/alloy/modules/kubernetes/integrations - name: modules-kubernetes-integrations - mountPath: /etc/alloy/modules/kubernetes/logs name: modules-kubernetes-logs - mountPath: /etc/alloy/modules/kubernetes/traces @@ -2368,16 +2263,13 @@ spec: serviceAccountName: alloy volumes: - configMap: - name: alloy-config-m6chdfm49m + name: alloy-config-55dd47md5f name: config - configMap: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 - name: modules-kubernetes-integrations - - configMap: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h name: modules-kubernetes-logs - configMap: name: alloy-modules-kubernetes-traces-8mgm8th9m5 diff --git a/kubernetes/microservices-mode/metrics/metrics.alloy b/kubernetes/microservices-mode/metrics/metrics.alloy index 66926d75..606728c9 100644 --- a/kubernetes/microservices-mode/metrics/metrics.alloy +++ b/kubernetes/microservices-mode/metrics/metrics.alloy @@ -24,10 +24,6 @@ import.file "metrics" { filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/kubernetes/metrics" } -metrics.integrations_scrape "kubernetes" { - forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] -} - metrics.podmonitors_scrape "kubernetes" { forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] } diff --git a/kubernetes/microservices-mode/profiles/k8s-all-in-one.yaml b/kubernetes/microservices-mode/profiles/k8s-all-in-one.yaml index 72ef2f4a..4c70d325 100644 --- a/kubernetes/microservices-mode/profiles/k8s-all-in-one.yaml +++ b/kubernetes/microservices-mode/profiles/k8s-all-in-one.yaml @@ -231,83 +231,12 @@ data: annotation_prefix = \"profiles.grafana.com\"\n\tforward_to = [provider.self_hosted_stack.kubernetes.profiles_receiver]\n}\n\n/********************************************\n * Metrics\n ********************************************/\nimport.file \"metrics\" {\n\tfilename = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") - + \"/kubernetes/metrics\"\n}\n\nmetrics.integrations_scrape \"kubernetes\" {\n\tforward_to - = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.podmonitors_scrape - \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape + + \"/kubernetes/metrics\"\n}\n\nmetrics.podmonitors_scrape \"kubernetes\" {\n\tforward_to + = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n" kind: ConfigMap metadata: - name: alloy-config-5k62427t46 - namespace: monitoring-system ---- -apiVersion: v1 -data: - MEMCACHED_K8S_SECRET_NAME: alloy-integrations-memcached - memcached.alloy: "/*\nModule Components: component_memcached\n*/\n\ndeclare \"component_memcached\" - {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\tcomment - \ = \"job label (default: integrations/kubernetes/memcached)\"\n\t\toptional = - true\n\t}\n\n\targument \"namespace\" {\n\t\tcomment = \"kubernetes secret name - (default: monitoring-system)\"\n\t\toptional = true\n\t}\n\n\targument \"name\" - {\n\t\tcomment = \"kubernetes secret name (default: alloy-integrations-redis)\"\n\t\toptional - = true\n\t}\n\n\targument \"keep_metrics\" {\n\t\toptional = true\n\t\tdefault - \ = \"(up|memcached_commands_total|memcached_connections_total|memcached_current_bytes|memcached_current_connections|memcached_current_items|memcached_items_evicted_total|memcached_items_total|memcached_max_connections|memcached_read_bytes_total|memcached_up|memcached_uptime_seconds|memcached_version|memcached_written_bytes_total)\"\n\t}\n\n\targument - \"scrape_interval\" {\n\t\tcomment = \"How often to scrape metrics from the targets - (default: 60s)\"\n\t\toptional = true\n\t}\n\n\targument \"scrape_timeout\" {\n\t\tcomment - \ = \"How long before a scrape times out (default: 10s)\"\n\t\toptional = true\n\t}\n\n\tremote.kubernetes.secret - \"memcached\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname - \ = coalesce(argument.name.value, \"alloy-integrations-memcached\")\n\t}\n\n\t/***************************************************************\n\t* - Integrations Memcached\n\t****************************************************************/\n\t// - https://grafana.com/docs/alloy/latest/reference/components/prometheus.exporter.memcached/\n\tprometheus.exporter.memcached - \"integrations_memcached_exporter\" {\n\t\taddress = nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-address\"])\n\t\ttimeout - = nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-timeout\"])\n\t}\n\n\t/***************************************************************\n\t* - Discovery Relabelings (pre-scrape)\n\t****************************************************************/\n\tdiscovery.relabel - \"integrations_memcached_exporter\" {\n\t\ttargets = prometheus.exporter.memcached.integrations_memcached_exporter.targets\n\n\t\trule - {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = coalesce(argument.job_label.value, - \"integrations/kubernetes/memcached\")\n\t\t}\n\n\t\trule {\n\t\t\ttarget_label - = \"instance\"\n\t\t\treplacement = coalesce(nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-name\"]), - constants.hostname)\n\t\t}\n\t}\n\n\t/***************************************************************\n\t* - Prometheus Scrape Integrations Targets\n\t****************************************************************/\n\tprometheus.scrape - \"integrations_memcached_exporter\" {\n\t\ttargets = concat(\n\t\t\tdiscovery.relabel.integrations_memcached_exporter.output,\n\t\t)\n\n\t\tenable_protobuf_negotiation - = true\n\t\tscrape_classic_histograms = true\n\n\t\tscrape_interval = coalesce(argument.scrape_interval.value, - \"60s\")\n\t\tscrape_timeout = coalesce(argument.scrape_timeout.value, \"10s\")\n\n\t\tclustering - {\n\t\t\tenabled = true\n\t\t}\n\n\t\tforward_to = [prometheus.relabel.integrations_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* - Prometheus Metric Relabelings (post-scrape)\n\t****************************************************************/\n\tprometheus.relabel - \"integrations_memcached_exporter\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\t// - keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels - = [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction - \ = \"keep\"\n\t\t}\n\t}\n}\n" -kind: ConfigMap -metadata: - name: alloy-integrations - namespace: monitoring-system ---- -apiVersion: v1 -data: - k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare - \"component_cluster_events\" {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected - logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/eventhandler\"\n\t}\n\n\targument - \"cluster\" {\n\t\toptional = true\n\t\tdefault = \"k3d\"\n\t}\n\n\tloki.source.kubernetes_events - \"cluster_events\" {\n\t\tjob_name = argument.job_label.value\n\t\tlog_format - = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process - \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster - = argument.cluster.value,\n\t\t\t}\n\t\t}\n\t\tforward_to = argument.forward_to.value\n\t}\n\n\t// - // Logs Service\n\t// remote.kubernetes.secret \"logs_service\" {\n\t// \tname - \ = \"loki-k8s-monitoring\"\n\t// \tnamespace = \"k8s-monitoring\"\n\t// }\n\t// - // Loki\n\t// loki.write \"logs_service\" {\n\t// \tendpoint {\n\t// \t\turl = - nonsensitive(remote.kubernetes.secret.logs_service.data[\"host\"]) + \"/loki/api/v1/push\"\n\t// - \t\ttenant_id = nonsensitive(remote.kubernetes.secret.logs_service.data[\"tenantId\"])\n\n\t// - \t\tbasic_auth {\n\t// \t\t\tusername = nonsensitive(remote.kubernetes.secret.logs_service.data[\"username\"])\n\t// - \t\t\tpassword = remote.kubernetes.secret.logs_service.data[\"password\"]\n\t// - \t\t}\n\t// \t}\n\t// }\n}\n" -kind: ConfigMap -metadata: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 + name: alloy-config-56888m5g8t namespace: monitoring-system --- apiVersion: v1 @@ -404,6 +333,17 @@ data: = {\n\t\t\t\t\tstream = \"\",\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// drop the temporary container runtime label as it is no longer needed\n\t\tstage.label_drop {\n\t\t\tvalues = [\"tmp_container_runtime\"]\n\t\t}\n\t}\n}\n" + k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare + \"kubernetes_cluster_events\" {\n\n\t/*****************************************************************\n\t* + ARGUMENTS\n\t*****************************************************************/\n\targument + \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected + logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional + = true\n\t}\n\n\targument \"cluster\" {\n\t\toptional = true\n\t}\n\n\tloki.source.kubernetes_events + \"cluster_events\" {\n\t\tjob_name = coalesce(argument.job_label.value, \"integrations/kubernetes/eventhandler\")\n\t\tlog_format + = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process + \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster + = coalesce(argument.cluster.value, \"k3d\"),\n\t\t\t}\n\t\t}\n\t\tforward_to = + argument.forward_to.value\n\t}\n}\n" keep-labels.alloy: "/*\nModule Components: keep_labels\nDescription: Pre-defined set of labels to keep, this stage should always be in-place as the previous relabeing\n \ stages make every pod label and annotation a label in the pipeline, @@ -427,42 +367,11 @@ data: \"receiver\" {\n\t\tvalue = loki.process.keep_labels.receiver\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h namespace: monitoring-system --- apiVersion: v1 data: - integrations-scrape.alloy: "/*\nModule Components: integrations_scrape\nDescription: - Integrations Module Components Scrape\n\nNote: Every argument except for \"forward_to\" - is optional, and does have a defined default value. However, the values for these\n - \ arguments are not defined using the default = \" ... \" argument syntax, - but rather using the coalesce(argument.value, \" ... \").\n This is because - if the argument passed in from another consuming module is set to null, the default - = \" ... \" syntax will\n does not override the value passed in, where coalesce() - will return the first non-null value.\n*/\n\ndeclare \"integrations_scrape\" {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"name\" {\n\t\tcomment = - \"Name of the integrations config\"\n\t\toptional = true\n\t}\n\n\targument \"namespace\" - {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional = true\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\tremote.kubernetes.configmap - \"integrations\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname - \ = coalesce(argument.name.value, \"alloy-integrations\")\n\t}\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\timport.string - \"memcached\" {\n\t\tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t}\n\n\tmemcached.component_memcached - \"instance\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tnamespace = - argument.namespace.value\n\t\tname = remote.kubernetes.configmap.integrations.data[\"MEMCACHED_K8S_SECRET_NAME\"]\n\t}\n\n\t// - /*****************************************************************\n\t// * Redis - Integrations\n\t// *****************************************************************/\n\t// - import.string \"redis\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"redis.alloy\"]\n\t// - }\n\n\t// redis.component_redis_exporter \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"REDIS_K8S_SECRET_NAME\"]\n\t// - }\n\n\t// /*****************************************************************\n\t// - * Mysql Integrations\n\t// *****************************************************************/\n\t// - import.string \"mysql\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"mysql.alloy\"]\n\t// - }\n\n\t// mysql.component_mysql \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"MYSQL_K8S_SECRET_NAME\"]\n\t// - }\n}\n" podmonitors-scrape.alloy: "/*\nModule Components: podmonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.podmonitors\n*/\n\ndeclare \"podmonitors_scrape\" {\n\n\t/*****************************************************************\n\t* @@ -495,7 +404,7 @@ data: {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 namespace: monitoring-system --- apiVersion: v1 @@ -1018,17 +927,6 @@ metadata: type: Opaque --- apiVersion: v1 -data: - instance-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= - instance-name: cHJpbWFyeQ== - instance-timeout: NXM= -kind: Secret -metadata: - name: alloy-integrations-memcached - namespace: monitoring-system -type: Opaque ---- -apiVersion: v1 data: MIMIR_S3_SECRET_ACCESS_KEY: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= kind: Secret @@ -2024,7 +1922,6 @@ spec: annotations: kubectl.kubernetes.io/default-container: alloy logs.agent.grafana.com/scrape: "true" - logs.agent.grafana.com/scrub-level: debug profiles.grafana.com/cpu.port_name: http-metrics profiles.grafana.com/cpu.scrape: "false" profiles.grafana.com/goroutine.port_name: http-metrics @@ -2088,8 +1985,6 @@ spec: name: config - mountPath: /etc/alloy/modules/kubernetes/metrics name: modules-kubernetes-metrics - - mountPath: /etc/alloy/modules/kubernetes/integrations - name: modules-kubernetes-integrations - mountPath: /etc/alloy/modules/kubernetes/logs name: modules-kubernetes-logs - mountPath: /etc/alloy/modules/kubernetes/traces @@ -2102,16 +1997,13 @@ spec: serviceAccountName: alloy volumes: - configMap: - name: alloy-config-5k62427t46 + name: alloy-config-56888m5g8t name: config - configMap: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 - name: modules-kubernetes-integrations - - configMap: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h name: modules-kubernetes-logs - configMap: name: alloy-modules-kubernetes-traces-8mgm8th9m5 diff --git a/kubernetes/microservices-mode/profiles/profiles.alloy b/kubernetes/microservices-mode/profiles/profiles.alloy index 691f7588..cf0354fa 100644 --- a/kubernetes/microservices-mode/profiles/profiles.alloy +++ b/kubernetes/microservices-mode/profiles/profiles.alloy @@ -37,10 +37,6 @@ import.file "metrics" { filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/kubernetes/metrics" } -metrics.integrations_scrape "kubernetes" { - forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] -} - metrics.podmonitors_scrape "kubernetes" { forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] } diff --git a/kubernetes/microservices-mode/traces/k8s-all-in-one.yaml b/kubernetes/microservices-mode/traces/k8s-all-in-one.yaml index f97ccdae..8a4d4ca8 100644 --- a/kubernetes/microservices-mode/traces/k8s-all-in-one.yaml +++ b/kubernetes/microservices-mode/traces/k8s-all-in-one.yaml @@ -243,83 +243,12 @@ data: Forward Alloy internal spans to traces process.\n\twrite_to = [traces.process_and_transform.kubernetes.alloy_traces_input]\n}\n\n/********************************************\n * Metrics\n ********************************************/\nimport.file \"metrics\" {\n\tfilename = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") - + \"/kubernetes/metrics\"\n}\n\nmetrics.integrations_scrape \"kubernetes\" {\n\tforward_to - = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.podmonitors_scrape - \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape + + \"/kubernetes/metrics\"\n}\n\nmetrics.podmonitors_scrape \"kubernetes\" {\n\tforward_to + = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n" kind: ConfigMap metadata: - name: alloy-config-gt2k68744f - namespace: monitoring-system ---- -apiVersion: v1 -data: - MEMCACHED_K8S_SECRET_NAME: alloy-integrations-memcached - memcached.alloy: "/*\nModule Components: component_memcached\n*/\n\ndeclare \"component_memcached\" - {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\tcomment - \ = \"job label (default: integrations/kubernetes/memcached)\"\n\t\toptional = - true\n\t}\n\n\targument \"namespace\" {\n\t\tcomment = \"kubernetes secret name - (default: monitoring-system)\"\n\t\toptional = true\n\t}\n\n\targument \"name\" - {\n\t\tcomment = \"kubernetes secret name (default: alloy-integrations-redis)\"\n\t\toptional - = true\n\t}\n\n\targument \"keep_metrics\" {\n\t\toptional = true\n\t\tdefault - \ = \"(up|memcached_commands_total|memcached_connections_total|memcached_current_bytes|memcached_current_connections|memcached_current_items|memcached_items_evicted_total|memcached_items_total|memcached_max_connections|memcached_read_bytes_total|memcached_up|memcached_uptime_seconds|memcached_version|memcached_written_bytes_total)\"\n\t}\n\n\targument - \"scrape_interval\" {\n\t\tcomment = \"How often to scrape metrics from the targets - (default: 60s)\"\n\t\toptional = true\n\t}\n\n\targument \"scrape_timeout\" {\n\t\tcomment - \ = \"How long before a scrape times out (default: 10s)\"\n\t\toptional = true\n\t}\n\n\tremote.kubernetes.secret - \"memcached\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname - \ = coalesce(argument.name.value, \"alloy-integrations-memcached\")\n\t}\n\n\t/***************************************************************\n\t* - Integrations Memcached\n\t****************************************************************/\n\t// - https://grafana.com/docs/alloy/latest/reference/components/prometheus.exporter.memcached/\n\tprometheus.exporter.memcached - \"integrations_memcached_exporter\" {\n\t\taddress = nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-address\"])\n\t\ttimeout - = nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-timeout\"])\n\t}\n\n\t/***************************************************************\n\t* - Discovery Relabelings (pre-scrape)\n\t****************************************************************/\n\tdiscovery.relabel - \"integrations_memcached_exporter\" {\n\t\ttargets = prometheus.exporter.memcached.integrations_memcached_exporter.targets\n\n\t\trule - {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = coalesce(argument.job_label.value, - \"integrations/kubernetes/memcached\")\n\t\t}\n\n\t\trule {\n\t\t\ttarget_label - = \"instance\"\n\t\t\treplacement = coalesce(nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-name\"]), - constants.hostname)\n\t\t}\n\t}\n\n\t/***************************************************************\n\t* - Prometheus Scrape Integrations Targets\n\t****************************************************************/\n\tprometheus.scrape - \"integrations_memcached_exporter\" {\n\t\ttargets = concat(\n\t\t\tdiscovery.relabel.integrations_memcached_exporter.output,\n\t\t)\n\n\t\tenable_protobuf_negotiation - = true\n\t\tscrape_classic_histograms = true\n\n\t\tscrape_interval = coalesce(argument.scrape_interval.value, - \"60s\")\n\t\tscrape_timeout = coalesce(argument.scrape_timeout.value, \"10s\")\n\n\t\tclustering - {\n\t\t\tenabled = true\n\t\t}\n\n\t\tforward_to = [prometheus.relabel.integrations_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* - Prometheus Metric Relabelings (post-scrape)\n\t****************************************************************/\n\tprometheus.relabel - \"integrations_memcached_exporter\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\t// - keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels - = [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction - \ = \"keep\"\n\t\t}\n\t}\n}\n" -kind: ConfigMap -metadata: - name: alloy-integrations - namespace: monitoring-system ---- -apiVersion: v1 -data: - k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare - \"component_cluster_events\" {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected - logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/eventhandler\"\n\t}\n\n\targument - \"cluster\" {\n\t\toptional = true\n\t\tdefault = \"k3d\"\n\t}\n\n\tloki.source.kubernetes_events - \"cluster_events\" {\n\t\tjob_name = argument.job_label.value\n\t\tlog_format - = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process - \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster - = argument.cluster.value,\n\t\t\t}\n\t\t}\n\t\tforward_to = argument.forward_to.value\n\t}\n\n\t// - // Logs Service\n\t// remote.kubernetes.secret \"logs_service\" {\n\t// \tname - \ = \"loki-k8s-monitoring\"\n\t// \tnamespace = \"k8s-monitoring\"\n\t// }\n\t// - // Loki\n\t// loki.write \"logs_service\" {\n\t// \tendpoint {\n\t// \t\turl = - nonsensitive(remote.kubernetes.secret.logs_service.data[\"host\"]) + \"/loki/api/v1/push\"\n\t// - \t\ttenant_id = nonsensitive(remote.kubernetes.secret.logs_service.data[\"tenantId\"])\n\n\t// - \t\tbasic_auth {\n\t// \t\t\tusername = nonsensitive(remote.kubernetes.secret.logs_service.data[\"username\"])\n\t// - \t\t\tpassword = remote.kubernetes.secret.logs_service.data[\"password\"]\n\t// - \t\t}\n\t// \t}\n\t// }\n}\n" -kind: ConfigMap -metadata: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 + name: alloy-config-t69dk2g68h namespace: monitoring-system --- apiVersion: v1 @@ -416,6 +345,17 @@ data: = {\n\t\t\t\t\tstream = \"\",\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// drop the temporary container runtime label as it is no longer needed\n\t\tstage.label_drop {\n\t\t\tvalues = [\"tmp_container_runtime\"]\n\t\t}\n\t}\n}\n" + k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare + \"kubernetes_cluster_events\" {\n\n\t/*****************************************************************\n\t* + ARGUMENTS\n\t*****************************************************************/\n\targument + \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected + logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional + = true\n\t}\n\n\targument \"cluster\" {\n\t\toptional = true\n\t}\n\n\tloki.source.kubernetes_events + \"cluster_events\" {\n\t\tjob_name = coalesce(argument.job_label.value, \"integrations/kubernetes/eventhandler\")\n\t\tlog_format + = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process + \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster + = coalesce(argument.cluster.value, \"k3d\"),\n\t\t\t}\n\t\t}\n\t\tforward_to = + argument.forward_to.value\n\t}\n}\n" keep-labels.alloy: "/*\nModule Components: keep_labels\nDescription: Pre-defined set of labels to keep, this stage should always be in-place as the previous relabeing\n \ stages make every pod label and annotation a label in the pipeline, @@ -439,42 +379,11 @@ data: \"receiver\" {\n\t\tvalue = loki.process.keep_labels.receiver\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h namespace: monitoring-system --- apiVersion: v1 data: - integrations-scrape.alloy: "/*\nModule Components: integrations_scrape\nDescription: - Integrations Module Components Scrape\n\nNote: Every argument except for \"forward_to\" - is optional, and does have a defined default value. However, the values for these\n - \ arguments are not defined using the default = \" ... \" argument syntax, - but rather using the coalesce(argument.value, \" ... \").\n This is because - if the argument passed in from another consuming module is set to null, the default - = \" ... \" syntax will\n does not override the value passed in, where coalesce() - will return the first non-null value.\n*/\n\ndeclare \"integrations_scrape\" {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"name\" {\n\t\tcomment = - \"Name of the integrations config\"\n\t\toptional = true\n\t}\n\n\targument \"namespace\" - {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional = true\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\tremote.kubernetes.configmap - \"integrations\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname - \ = coalesce(argument.name.value, \"alloy-integrations\")\n\t}\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\timport.string - \"memcached\" {\n\t\tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t}\n\n\tmemcached.component_memcached - \"instance\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tnamespace = - argument.namespace.value\n\t\tname = remote.kubernetes.configmap.integrations.data[\"MEMCACHED_K8S_SECRET_NAME\"]\n\t}\n\n\t// - /*****************************************************************\n\t// * Redis - Integrations\n\t// *****************************************************************/\n\t// - import.string \"redis\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"redis.alloy\"]\n\t// - }\n\n\t// redis.component_redis_exporter \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"REDIS_K8S_SECRET_NAME\"]\n\t// - }\n\n\t// /*****************************************************************\n\t// - * Mysql Integrations\n\t// *****************************************************************/\n\t// - import.string \"mysql\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"mysql.alloy\"]\n\t// - }\n\n\t// mysql.component_mysql \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"MYSQL_K8S_SECRET_NAME\"]\n\t// - }\n}\n" podmonitors-scrape.alloy: "/*\nModule Components: podmonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.podmonitors\n*/\n\ndeclare \"podmonitors_scrape\" {\n\n\t/*****************************************************************\n\t* @@ -507,7 +416,7 @@ data: {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 namespace: monitoring-system --- apiVersion: v1 @@ -1128,17 +1037,6 @@ metadata: type: Opaque --- apiVersion: v1 -data: - instance-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= - instance-name: cHJpbWFyeQ== - instance-timeout: NXM= -kind: Secret -metadata: - name: alloy-integrations-memcached - namespace: monitoring-system -type: Opaque ---- -apiVersion: v1 data: MIMIR_S3_SECRET_ACCESS_KEY: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= kind: Secret @@ -2369,7 +2267,6 @@ spec: annotations: kubectl.kubernetes.io/default-container: alloy logs.agent.grafana.com/scrape: "true" - logs.agent.grafana.com/scrub-level: debug profiles.grafana.com/cpu.port_name: http-metrics profiles.grafana.com/cpu.scrape: "false" profiles.grafana.com/goroutine.port_name: http-metrics @@ -2433,8 +2330,6 @@ spec: name: config - mountPath: /etc/alloy/modules/kubernetes/metrics name: modules-kubernetes-metrics - - mountPath: /etc/alloy/modules/kubernetes/integrations - name: modules-kubernetes-integrations - mountPath: /etc/alloy/modules/kubernetes/logs name: modules-kubernetes-logs - mountPath: /etc/alloy/modules/kubernetes/traces @@ -2447,16 +2342,13 @@ spec: serviceAccountName: alloy volumes: - configMap: - name: alloy-config-gt2k68744f + name: alloy-config-t69dk2g68h name: config - configMap: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 - name: modules-kubernetes-integrations - - configMap: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h name: modules-kubernetes-logs - configMap: name: alloy-modules-kubernetes-traces-8mgm8th9m5 diff --git a/kubernetes/microservices-mode/traces/traces.alloy b/kubernetes/microservices-mode/traces/traces.alloy index 8f8852b1..cbae15b5 100644 --- a/kubernetes/microservices-mode/traces/traces.alloy +++ b/kubernetes/microservices-mode/traces/traces.alloy @@ -48,10 +48,6 @@ import.file "metrics" { filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/kubernetes/metrics" } -metrics.integrations_scrape "kubernetes" { - forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] -} - metrics.podmonitors_scrape "kubernetes" { forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] } diff --git a/kubernetes/monolithic-mode/all-in-one/all-in-one.alloy b/kubernetes/monolithic-mode/all-in-one/all-in-one.alloy index 88eef811..b38f6905 100644 --- a/kubernetes/monolithic-mode/all-in-one/all-in-one.alloy +++ b/kubernetes/monolithic-mode/all-in-one/all-in-one.alloy @@ -27,10 +27,6 @@ import.file "metrics" { filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/kubernetes/metrics" } -metrics.integrations_scrape "kubernetes" { - forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] -} - metrics.podmonitors_scrape "kubernetes" { forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] } @@ -88,3 +84,23 @@ profiles.annotations_scrape "kubernetes" { forward_to = [provider.self_hosted_stack.kubernetes.profiles_receiver] // annotation_prefix = "profiles.grafana.com" } + +/***************************************************************** +* Alloy Integrations +*****************************************************************/ +remote.kubernetes.configmap "integrations" { + namespace = "monitoring-system" + name = "alloy-integrations" +} + +// Memcached Integrations +import.string "memcached" { + content = remote.kubernetes.configmap.integrations.data["memcached.alloy"] +} + +memcached.memcached_metrics_scrape "instance" { + forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] + + namespace = "monitoring-system" + name = remote.kubernetes.configmap.integrations.data["MEMCACHED_K8S_SECRET_NAME"] +} diff --git a/kubernetes/monolithic-mode/all-in-one/k8s-all-in-one.yaml b/kubernetes/monolithic-mode/all-in-one/k8s-all-in-one.yaml index fecf6fd1..346a3044 100644 --- a/kubernetes/monolithic-mode/all-in-one/k8s-all-in-one.yaml +++ b/kubernetes/monolithic-mode/all-in-one/k8s-all-in-one.yaml @@ -631,9 +631,8 @@ data: = coalesce(env(\"SELF_HOSTED_PROFILES_ENDPOINT_URL\"), \"http://nginx.gateway.svc:4040\")\n}\n\n/********************************************\n * Metrics\n ********************************************/\nimport.file \"metrics\" {\n\tfilename = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") - + \"/kubernetes/metrics\"\n}\n\nmetrics.integrations_scrape \"kubernetes\" {\n\tforward_to - = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.podmonitors_scrape - \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape + + \"/kubernetes/metrics\"\n}\n\nmetrics.podmonitors_scrape \"kubernetes\" {\n\tforward_to + = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\n/********************************************\n * Logs\n ********************************************/\nimport.file \"logs\" {\n\tfilename = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") + \"/kubernetes/logs\"\n}\n\nlogs.annotations_scrape @@ -652,16 +651,23 @@ data: {\n\tfilename = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") + \"/kubernetes/profiles\"\n}\n\nprofiles.annotations_scrape \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.profiles_receiver]\n\t// annotation_prefix - = \"profiles.grafana.com\"\n}\n" + = \"profiles.grafana.com\"\n}\n\n/*****************************************************************\n* + Alloy Integrations\n*****************************************************************/\nremote.kubernetes.configmap + \"integrations\" {\n\tnamespace = \"monitoring-system\"\n\tname = \"alloy-integrations\"\n}\n\n// + Memcached Integrations\nimport.string \"memcached\" {\n\tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n}\n\nmemcached.memcached_metrics_scrape + \"instance\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n\n\tnamespace + = \"monitoring-system\"\n\tname = remote.kubernetes.configmap.integrations.data[\"MEMCACHED_K8S_SECRET_NAME\"]\n}\n" kind: ConfigMap metadata: - name: alloy-config-6b695gbdm6 + name: alloy-config-tdm88h78mg namespace: monitoring-system --- apiVersion: v1 data: MEMCACHED_K8S_SECRET_NAME: alloy-integrations-memcached - memcached.alloy: "/*\nModule Components: component_memcached\n*/\n\ndeclare \"component_memcached\" + MYSQL_K8S_SECRET_NAME: alloy-integrations-mysql + REDIS_K8S_SECRET_NAME: alloy-integrations-redis + memcached.alloy: "/*\nModule Components: component_memcached\n*/\n\ndeclare \"memcached_metrics_scrape\" {\n\n\t/*****************************************************************\n\t* ARGUMENTS\n\t*****************************************************************/\n\targument \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected @@ -697,35 +703,81 @@ data: keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels = [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction \ = \"keep\"\n\t\t}\n\t}\n}\n" -kind: ConfigMap -metadata: - name: alloy-integrations - namespace: monitoring-system ---- -apiVersion: v1 -data: - k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare - \"component_cluster_events\" {\n\n\t/*****************************************************************\n\t* + mysql.alloy: "/*\nModule Components: component_mysql\n*/\n\ndeclare \"mysql_metrics_scrape\" + {\n\n\t/*****************************************************************\n\t* ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected - logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/eventhandler\"\n\t}\n\n\targument - \"cluster\" {\n\t\toptional = true\n\t\tdefault = \"k3d\"\n\t}\n\n\tloki.source.kubernetes_events - \"cluster_events\" {\n\t\tjob_name = argument.job_label.value\n\t\tlog_format - = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process - \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster - = argument.cluster.value,\n\t\t\t}\n\t\t}\n\t\tforward_to = argument.forward_to.value\n\t}\n\n\t// - // Logs Service\n\t// remote.kubernetes.secret \"logs_service\" {\n\t// \tname - \ = \"loki-k8s-monitoring\"\n\t// \tnamespace = \"k8s-monitoring\"\n\t// }\n\t// - // Loki\n\t// loki.write \"logs_service\" {\n\t// \tendpoint {\n\t// \t\turl = - nonsensitive(remote.kubernetes.secret.logs_service.data[\"host\"]) + \"/loki/api/v1/push\"\n\t// - \t\ttenant_id = nonsensitive(remote.kubernetes.secret.logs_service.data[\"tenantId\"])\n\n\t// - \t\tbasic_auth {\n\t// \t\t\tusername = nonsensitive(remote.kubernetes.secret.logs_service.data[\"username\"])\n\t// - \t\t\tpassword = remote.kubernetes.secret.logs_service.data[\"password\"]\n\t// - \t\t}\n\t// \t}\n\t// }\n}\n" + \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected + metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\tcomment + \ = \"job label (default: integrations/kubernetes/mysql)\"\n\t\toptional = true\n\t}\n\n\targument + \"namespace\" {\n\t\tcomment = \"kubernetes secret name (default: monitoring-system)\"\n\t\toptional + = true\n\t}\n\n\targument \"name\" {\n\t\tcomment = \"kubernetes secret name + (default: alloy-integrations-mysql)\"\n\t\toptional = true\n\t}\n\n\targument + \"keep_metrics\" {\n\t\toptional = true\n\t\tdefault = \"(up|instance:mysql_heartbeat_lag_seconds|instance:mysql_slave_lag_seconds|mysql_global_status_aborted_clients|mysql_global_status_aborted_connects|mysql_global_status_buffer_pool_pages|mysql_global_status_bytes_received|mysql_global_status_bytes_sent|mysql_global_status_commands_total|mysql_global_status_created_tmp_disk_tables|mysql_global_status_created_tmp_files|mysql_global_status_created_tmp_tables|mysql_global_status_handlers_total|mysql_global_status_innodb_log_waits|mysql_global_status_innodb_mem_adaptive_hash|mysql_global_status_innodb_mem_dictionary|mysql_global_status_innodb_num_open_files|mysql_global_status_innodb_page_size|mysql_global_status_max_used_connections|mysql_global_status_open_files|mysql_global_status_open_table_definitions|mysql_global_status_open_tables|mysql_global_status_opened_files|mysql_global_status_opened_table_definitions|mysql_global_status_opened_tables|mysql_global_status_qcache_free_memory|mysql_global_status_qcache_hits|mysql_global_status_qcache_inserts|mysql_global_status_qcache_lowmem_prunes|mysql_global_status_qcache_not_cached|mysql_global_status_qcache_queries_in_cache|mysql_global_status_queries|mysql_global_status_questions|mysql_global_status_select_full_join|mysql_global_status_select_full_range_join|mysql_global_status_select_range|mysql_global_status_select_range_check|mysql_global_status_select_scan|mysql_global_status_slow_queries|mysql_global_status_sort_merge_passes|mysql_global_status_sort_range|mysql_global_status_sort_rows|mysql_global_status_sort_scan|mysql_global_status_table_locks_immediate|mysql_global_status_table_locks_waited|mysql_global_status_table_open_cache_hits|mysql_global_status_table_open_cache_misses|mysql_global_status_table_open_cache_overflows|mysql_global_status_threads_cached|mysql_global_status_threads_connected|mysql_global_status_threads_created|mysql_global_status_threads_running|mysql_global_status_uptime|mysql_global_status_wsrep_local_recv_queue|mysql_global_status_wsrep_local_state|mysql_global_status_wsrep_ready|mysql_global_variables_innodb_additional_mem_pool_size|mysql_global_variables_innodb_buffer_pool_size|mysql_global_variables_innodb_log_buffer_size|mysql_global_variables_key_buffer_size|mysql_global_variables_max_connections|mysql_global_variables_open_files_limit|mysql_global_variables_query_cache_size|mysql_global_variables_table_definition_cache|mysql_global_variables_table_open_cache|mysql_global_variables_thread_cache_size|mysql_global_variables_tokudb_cache_size|mysql_global_variables_wsrep_desync|mysql_heartbeat_now_timestamp_seconds|mysql_heartbeat_stored_timestamp_seconds|mysql_info_schema_processlist_threads|mysql_slave_status_seconds_behind_master|mysql_slave_status_slave_io_running|mysql_slave_status_slave_sql_running|mysql_slave_status_sql_delay|mysql_up)\"\n\t}\n\n\targument + \"scrape_interval\" {\n\t\tcomment = \"How often to scrape metrics from the targets + (default: 60s)\"\n\t\toptional = true\n\t}\n\n\targument \"scrape_timeout\" {\n\t\tcomment + \ = \"How long before a scrape times out (default: 10s)\"\n\t\toptional = true\n\t}\n\n\tremote.kubernetes.secret + \"mysql\" {\n\t\tname = coalesce(argument.name.value, \"alloy-integrations-mysql\")\n\t\tnamespace + = coalesce(argument.namespace.value, \"monitoring-system\")\n\t}\n\n\t/***************************************************************\n\t* + Integrations Mysql\n\t****************************************************************/\n\tprometheus.exporter.mysql + \"integrations_mysqld_exporter\" {\n\t\tdata_source_name = nonsensitive(remote.kubernetes.secret.mysql.data[\"mysql-username\"]) + + \":\" + nonsensitive(remote.kubernetes.secret.mysql.data[\"mysql-password\"]) + + \"@(\" + nonsensitive(remote.kubernetes.secret.mysql.data[\"mysql-host\"]) + + \")/\"\n\t}\n\n\t/***************************************************************\n\t* + Discovery Relabelings (pre-scrape)\n\t****************************************************************/\n\tdiscovery.relabel + \"integrations_mysqld_exporter\" {\n\t\ttargets = prometheus.exporter.mysql.integrations_mysqld_exporter.targets\n\n\t\trule + {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = coalesce(argument.job_label.value, + \"integrations/kubernetes/mysql\")\n\t\t}\n\n\t\trule {\n\t\t\ttarget_label = + \"instance\"\n\t\t\treplacement = coalesce(nonsensitive(remote.kubernetes.secret.mysql.data[\"instance-name\"]), + constants.hostname)\n\t\t}\n\t}\n\n\t/***************************************************************\n\t* + Prometheus Scrape Integrations Targets\n\t****************************************************************/\n\tprometheus.scrape + \"integrations_mysqld_exporter\" {\n\t\ttargets = concat(\n\t\t\tdiscovery.relabel.integrations_mysqld_exporter.output,\n\t\t)\n\n\t\tenable_protobuf_negotiation + = true\n\t\tscrape_classic_histograms = true\n\n\t\tscrape_interval = coalesce(argument.scrape_interval.value, + \"60s\")\n\t\tscrape_timeout = coalesce(argument.scrape_timeout.value, \"10s\")\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\n\t\tforward_to = [prometheus.relabel.integrations_mysqld_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* + Prometheus Metric Relabelings (post-scrape)\n\t****************************************************************/\n\tprometheus.relabel + \"integrations_mysqld_exporter\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\t// + keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels + = [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction + \ = \"keep\"\n\t\t}\n\t}\n}\n" + redis.alloy: "/*\nModule Components: component_redis_exporter\n*/\n\ndeclare \"redis_exporter_metrics_scrape\" + {\n\n\t/*****************************************************************\n\t* + ARGUMENTS\n\t*****************************************************************/\n\targument + \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected + metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\tcomment + \ = \"job label (default: integrations/kubernetes/redis_exporter)\"\n\t\toptional + = true\n\t}\n\n\targument \"namespace\" {\n\t\tcomment = \"kubernetes secret + name (default: monitoring-system)\"\n\t\toptional = true\n\t}\n\n\targument \"name\" + {\n\t\tcomment = \"kubernetes secret name (default: alloy-integrations-redis)\"\n\t\toptional + = true\n\t}\n\n\targument \"keep_metrics\" {\n\t\toptional = true\n\t\tdefault + \ = \"(up|redis_blocked_clients|redis_cluster_slots_fail|redis_cluster_slots_pfail|redis_cluster_state|redis_commands_duration_seconds_total|redis_commands_total|redis_connected_clients|redis_connected_slaves|redis_db_keys|redis_db_keys_expiring|redis_evicted_keys_total|redis_keyspace_hits_total|redis_keyspace_misses_total|redis_master_last_io_seconds_ago|redis_memory_fragmentation_ratio|redis_memory_max_bytes|redis_memory_used_bytes|redis_memory_used_rss_bytes|redis_total_system_memory_bytes|redis_up)\"\n\t}\n\n\targument + \"scrape_interval\" {\n\t\tcomment = \"How often to scrape metrics from the targets + (default: 60s)\"\n\t\toptional = true\n\t\tdefault = \"60s\"\n\t}\n\n\targument + \"scrape_timeout\" {\n\t\tcomment = \"How long before a scrape times out (default: + 10s)\"\n\t\toptional = true\n\t\tdefault = \"10s\"\n\t}\n\n\tremote.kubernetes.secret + \"redis\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname + \ = coalesce(argument.name.value, \"alloy-integrations-redis\")\n\t}\n\n\t/***************************************************************\n\t* + Integrations Redis\n\t****************************************************************/\n\tprometheus.exporter.redis + \"integrations_redis_exporter\" {\n\t\tredis_addr = nonsensitive(remote.kubernetes.secret.redis.data[\"instance-address\"])\n\t\tredis_password + = nonsensitive(remote.kubernetes.secret.redis.data[\"instance-password\"])\n\t}\n\n\t/***************************************************************\n\t* + Discovery Relabelings (pre-scrape)\n\t****************************************************************/\n\tdiscovery.relabel + \"integrations_redis_exporter\" {\n\t\ttargets = prometheus.exporter.redis.integrations_redis_exporter.targets\n\n\t\trule + {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = coalesce(argument.job_label.value, + \"integrations/kubernetes/redis_exporter\")\n\t\t}\n\n\t\trule {\n\t\t\ttarget_label + = \"instance\"\n\t\t\treplacement = coalesce(nonsensitive(remote.kubernetes.secret.redis.data[\"instance-name\"]), + constants.hostname)\n\t\t}\n\t}\n\n\t/***************************************************************\n\t* + Prometheus Scrape Integrations Targets\n\t****************************************************************/\n\tprometheus.scrape + \"integrations_redis_exporter\" {\n\t\ttargets = concat(\n\t\t\tdiscovery.relabel.integrations_redis_exporter.output,\n\t\t)\n\n\t\tenable_protobuf_negotiation + = true\n\t\tscrape_classic_histograms = true\n\n\t\tscrape_interval = argument.scrape_interval.value\n\t\tscrape_timeout + \ = argument.scrape_timeout.value\n\n\t\tclustering {\n\t\t\tenabled = true\n\t\t}\n\n\t\tforward_to + = [prometheus.relabel.integrations_redis_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* + Prometheus Metric Relabelings (post-scrape)\n\t****************************************************************/\n\tprometheus.relabel + \"integrations_redis_exporter\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\t// + keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels + = [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction + \ = \"keep\"\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 + name: alloy-integrations namespace: monitoring-system --- apiVersion: v1 @@ -822,6 +874,17 @@ data: = {\n\t\t\t\t\tstream = \"\",\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// drop the temporary container runtime label as it is no longer needed\n\t\tstage.label_drop {\n\t\t\tvalues = [\"tmp_container_runtime\"]\n\t\t}\n\t}\n}\n" + k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare + \"kubernetes_cluster_events\" {\n\n\t/*****************************************************************\n\t* + ARGUMENTS\n\t*****************************************************************/\n\targument + \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected + logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional + = true\n\t}\n\n\targument \"cluster\" {\n\t\toptional = true\n\t}\n\n\tloki.source.kubernetes_events + \"cluster_events\" {\n\t\tjob_name = coalesce(argument.job_label.value, \"integrations/kubernetes/eventhandler\")\n\t\tlog_format + = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process + \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster + = coalesce(argument.cluster.value, \"k3d\"),\n\t\t\t}\n\t\t}\n\t\tforward_to = + argument.forward_to.value\n\t}\n}\n" keep-labels.alloy: "/*\nModule Components: keep_labels\nDescription: Pre-defined set of labels to keep, this stage should always be in-place as the previous relabeing\n \ stages make every pod label and annotation a label in the pipeline, @@ -845,42 +908,11 @@ data: \"receiver\" {\n\t\tvalue = loki.process.keep_labels.receiver\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h namespace: monitoring-system --- apiVersion: v1 data: - integrations-scrape.alloy: "/*\nModule Components: integrations_scrape\nDescription: - Integrations Module Components Scrape\n\nNote: Every argument except for \"forward_to\" - is optional, and does have a defined default value. However, the values for these\n - \ arguments are not defined using the default = \" ... \" argument syntax, - but rather using the coalesce(argument.value, \" ... \").\n This is because - if the argument passed in from another consuming module is set to null, the default - = \" ... \" syntax will\n does not override the value passed in, where coalesce() - will return the first non-null value.\n*/\n\ndeclare \"integrations_scrape\" {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"name\" {\n\t\tcomment = - \"Name of the integrations config\"\n\t\toptional = true\n\t}\n\n\targument \"namespace\" - {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional = true\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\tremote.kubernetes.configmap - \"integrations\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname - \ = coalesce(argument.name.value, \"alloy-integrations\")\n\t}\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\timport.string - \"memcached\" {\n\t\tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t}\n\n\tmemcached.component_memcached - \"instance\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tnamespace = - argument.namespace.value\n\t\tname = remote.kubernetes.configmap.integrations.data[\"MEMCACHED_K8S_SECRET_NAME\"]\n\t}\n\n\t// - /*****************************************************************\n\t// * Redis - Integrations\n\t// *****************************************************************/\n\t// - import.string \"redis\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"redis.alloy\"]\n\t// - }\n\n\t// redis.component_redis_exporter \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"REDIS_K8S_SECRET_NAME\"]\n\t// - }\n\n\t// /*****************************************************************\n\t// - * Mysql Integrations\n\t// *****************************************************************/\n\t// - import.string \"mysql\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"mysql.alloy\"]\n\t// - }\n\n\t// mysql.component_mysql \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"MYSQL_K8S_SECRET_NAME\"]\n\t// - }\n}\n" podmonitors-scrape.alloy: "/*\nModule Components: podmonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.podmonitors\n*/\n\ndeclare \"podmonitors_scrape\" {\n\n\t/*****************************************************************\n\t* @@ -913,7 +945,7 @@ data: {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 namespace: monitoring-system --- apiVersion: v1 @@ -1594,6 +1626,29 @@ metadata: type: Opaque --- apiVersion: v1 +data: + instance-name: cHJpbWFyeQ== + mysql-host: bXlzcWwubXlzcWwtc3lzdGVtLnN2Yy5jbHVzdGVyLmxvY2Fs + mysql-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= + mysql-username: bGd0bXA= +kind: Secret +metadata: + name: alloy-integrations-mysql + namespace: monitoring-system +type: Opaque +--- +apiVersion: v1 +data: + instance-address: cmVkaXMtbWFzdGVyLnJlZGlzLXN5c3RlbS5zdmMuY2x1c3Rlci5sb2NhbDo2Mzc5 + instance-name: cHJpbWFyeQ== + instance-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= +kind: Secret +metadata: + name: alloy-integrations-redis + namespace: monitoring-system +type: Opaque +--- +apiVersion: v1 data: MIMIR_S3_SECRET_ACCESS_KEY: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= kind: Secret @@ -2202,7 +2257,6 @@ spec: annotations: kubectl.kubernetes.io/default-container: alloy logs.agent.grafana.com/scrape: "true" - logs.agent.grafana.com/scrub-level: debug profiles.grafana.com/cpu.port_name: http-metrics profiles.grafana.com/cpu.scrape: "false" profiles.grafana.com/goroutine.port_name: http-metrics @@ -2266,8 +2320,6 @@ spec: name: config - mountPath: /etc/alloy/modules/kubernetes/metrics name: modules-kubernetes-metrics - - mountPath: /etc/alloy/modules/kubernetes/integrations - name: modules-kubernetes-integrations - mountPath: /etc/alloy/modules/kubernetes/logs name: modules-kubernetes-logs - mountPath: /etc/alloy/modules/kubernetes/traces @@ -2280,16 +2332,13 @@ spec: serviceAccountName: alloy volumes: - configMap: - name: alloy-config-6b695gbdm6 + name: alloy-config-tdm88h78mg name: config - configMap: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 - name: modules-kubernetes-integrations - - configMap: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h name: modules-kubernetes-logs - configMap: name: alloy-modules-kubernetes-traces-8mgm8th9m5 diff --git a/kubernetes/monolithic-mode/all-in-one/kustomization.yaml b/kubernetes/monolithic-mode/all-in-one/kustomization.yaml index e9e9e651..0b77436c 100644 --- a/kubernetes/monolithic-mode/all-in-one/kustomization.yaml +++ b/kubernetes/monolithic-mode/all-in-one/kustomization.yaml @@ -10,6 +10,7 @@ kind: Kustomization resources: - ../../common/alloy +- ../../common/alloy/configs/kubernetes/integrations - ../logs/loki - ../traces/tempo - ../metrics/mimir diff --git a/kubernetes/monolithic-mode/logs/k8s-all-in-one.yaml b/kubernetes/monolithic-mode/logs/k8s-all-in-one.yaml index 00aed586..118455fb 100644 --- a/kubernetes/monolithic-mode/logs/k8s-all-in-one.yaml +++ b/kubernetes/monolithic-mode/logs/k8s-all-in-one.yaml @@ -366,26 +366,40 @@ data: = coalesce(env(\"SELF_HOSTED_METRICS_ENDPOINT_URL\"), \"http://nginx.gateway.svc:8080/api/v1/push\")\n\tlogs_endpoint_url \ = coalesce(env(\"SELF_HOSTED_LOGS_ENDPOINT_URL\"), \"http://nginx.gateway.svc:3100/loki/api/v1/push\")\n}\n\n/********************************************\n * Logs\n ********************************************/\nimport.file \"logs\" {\n\tfilename - = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") + \"/kubernetes/logs\"\n}\n\nlogs.annotations_scrape + = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") + \"/kubernetes/logs\"\n}\n\nlogs.kubernetes_cluster_events + \"kubernetes\" {\n\tcluster = \"k3d-k3s-codelab\"\n\tforward_to = [logs.keep_labels.kubernetes.receiver]\n}\n\nlogs.annotations_scrape \"kubernetes\" {\n\tannotation_prefix = \"logs.grafana.com\"\n\tforward_to = [logs.keep_labels.kubernetes.receiver]\n}\n\nlogs.keep_labels \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.logs_receiver]\n}\n\n/********************************************\n * Metrics\n ********************************************/\nimport.file \"metrics\" {\n\tfilename = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") - + \"/kubernetes/metrics\"\n}\n\nmetrics.integrations_scrape \"kubernetes\" {\n\tforward_to - = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n\n\tnamespace = \"monitoring-system\"\n\tname - \ = \"alloy-integrations\"\n}\n\nmetrics.podmonitors_scrape \"kubernetes\" - {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape - \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n" + + \"/kubernetes/metrics\"\n}\n\nmetrics.podmonitors_scrape \"kubernetes\" {\n\tforward_to + = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape + \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\n/*****************************************************************\n* + Alloy Integrations\n*****************************************************************/\nremote.kubernetes.configmap + \"integrations\" {\n\tnamespace = \"monitoring-system\"\n\tname = \"alloy-integrations\"\n}\n\n// + Memcached Integrations\nimport.string \"memcached\" {\n\tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n}\n\nmemcached.memcached_metrics_scrape + \"instance\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n\n\tnamespace + = \"monitoring-system\"\n\tname = remote.kubernetes.configmap.integrations.data[\"MEMCACHED_K8S_SECRET_NAME\"]\n}\n\n// + // Redis Integrations\n// import.string \"redis\" {\n// \tcontent = remote.kubernetes.configmap.integrations.data[\"redis.alloy\"]\n// + }\n\n// redis.redis_exporter_metrics_scrape \"instance\" {\n// \tforward_to = + [provider.self_hosted_stack.kubernetes.metrics_receiver]\n\n// \tnamespace = \"monitoring-system\"\n// + \tname = remote.kubernetes.configmap.integrations.data[\"REDIS_K8S_SECRET_NAME\"]\n// + }\n\n// // Mysql Integrations\n// import.string \"mysql\" {\n// \tcontent = remote.kubernetes.configmap.integrations.data[\"mysql.alloy\"]\n// + }\n\n// mysql.mysql_metrics_scrape \"instance\" {\n// \tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n\n// + \tnamespace = \"monitoring-system\"\n// \tname = remote.kubernetes.configmap.integrations.data[\"MYSQL_K8S_SECRET_NAME\"]\n// + }\n" kind: ConfigMap metadata: - name: alloy-config-bdt752b5d5 + name: alloy-config-4m6599mmm2 namespace: monitoring-system --- apiVersion: v1 data: MEMCACHED_K8S_SECRET_NAME: alloy-integrations-memcached - memcached.alloy: "/*\nModule Components: component_memcached\n*/\n\ndeclare \"component_memcached\" + MYSQL_K8S_SECRET_NAME: alloy-integrations-mysql + REDIS_K8S_SECRET_NAME: alloy-integrations-redis + memcached.alloy: "/*\nModule Components: component_memcached\n*/\n\ndeclare \"memcached_metrics_scrape\" {\n\n\t/*****************************************************************\n\t* ARGUMENTS\n\t*****************************************************************/\n\targument \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected @@ -421,35 +435,81 @@ data: keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels = [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction \ = \"keep\"\n\t\t}\n\t}\n}\n" -kind: ConfigMap -metadata: - name: alloy-integrations - namespace: monitoring-system ---- -apiVersion: v1 -data: - k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare - \"component_cluster_events\" {\n\n\t/*****************************************************************\n\t* + mysql.alloy: "/*\nModule Components: component_mysql\n*/\n\ndeclare \"mysql_metrics_scrape\" + {\n\n\t/*****************************************************************\n\t* ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected - logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/eventhandler\"\n\t}\n\n\targument - \"cluster\" {\n\t\toptional = true\n\t\tdefault = \"k3d\"\n\t}\n\n\tloki.source.kubernetes_events - \"cluster_events\" {\n\t\tjob_name = argument.job_label.value\n\t\tlog_format - = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process - \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster - = argument.cluster.value,\n\t\t\t}\n\t\t}\n\t\tforward_to = argument.forward_to.value\n\t}\n\n\t// - // Logs Service\n\t// remote.kubernetes.secret \"logs_service\" {\n\t// \tname - \ = \"loki-k8s-monitoring\"\n\t// \tnamespace = \"k8s-monitoring\"\n\t// }\n\t// - // Loki\n\t// loki.write \"logs_service\" {\n\t// \tendpoint {\n\t// \t\turl = - nonsensitive(remote.kubernetes.secret.logs_service.data[\"host\"]) + \"/loki/api/v1/push\"\n\t// - \t\ttenant_id = nonsensitive(remote.kubernetes.secret.logs_service.data[\"tenantId\"])\n\n\t// - \t\tbasic_auth {\n\t// \t\t\tusername = nonsensitive(remote.kubernetes.secret.logs_service.data[\"username\"])\n\t// - \t\t\tpassword = remote.kubernetes.secret.logs_service.data[\"password\"]\n\t// - \t\t}\n\t// \t}\n\t// }\n}\n" + \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected + metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\tcomment + \ = \"job label (default: integrations/kubernetes/mysql)\"\n\t\toptional = true\n\t}\n\n\targument + \"namespace\" {\n\t\tcomment = \"kubernetes secret name (default: monitoring-system)\"\n\t\toptional + = true\n\t}\n\n\targument \"name\" {\n\t\tcomment = \"kubernetes secret name + (default: alloy-integrations-mysql)\"\n\t\toptional = true\n\t}\n\n\targument + \"keep_metrics\" {\n\t\toptional = true\n\t\tdefault = \"(up|instance:mysql_heartbeat_lag_seconds|instance:mysql_slave_lag_seconds|mysql_global_status_aborted_clients|mysql_global_status_aborted_connects|mysql_global_status_buffer_pool_pages|mysql_global_status_bytes_received|mysql_global_status_bytes_sent|mysql_global_status_commands_total|mysql_global_status_created_tmp_disk_tables|mysql_global_status_created_tmp_files|mysql_global_status_created_tmp_tables|mysql_global_status_handlers_total|mysql_global_status_innodb_log_waits|mysql_global_status_innodb_mem_adaptive_hash|mysql_global_status_innodb_mem_dictionary|mysql_global_status_innodb_num_open_files|mysql_global_status_innodb_page_size|mysql_global_status_max_used_connections|mysql_global_status_open_files|mysql_global_status_open_table_definitions|mysql_global_status_open_tables|mysql_global_status_opened_files|mysql_global_status_opened_table_definitions|mysql_global_status_opened_tables|mysql_global_status_qcache_free_memory|mysql_global_status_qcache_hits|mysql_global_status_qcache_inserts|mysql_global_status_qcache_lowmem_prunes|mysql_global_status_qcache_not_cached|mysql_global_status_qcache_queries_in_cache|mysql_global_status_queries|mysql_global_status_questions|mysql_global_status_select_full_join|mysql_global_status_select_full_range_join|mysql_global_status_select_range|mysql_global_status_select_range_check|mysql_global_status_select_scan|mysql_global_status_slow_queries|mysql_global_status_sort_merge_passes|mysql_global_status_sort_range|mysql_global_status_sort_rows|mysql_global_status_sort_scan|mysql_global_status_table_locks_immediate|mysql_global_status_table_locks_waited|mysql_global_status_table_open_cache_hits|mysql_global_status_table_open_cache_misses|mysql_global_status_table_open_cache_overflows|mysql_global_status_threads_cached|mysql_global_status_threads_connected|mysql_global_status_threads_created|mysql_global_status_threads_running|mysql_global_status_uptime|mysql_global_status_wsrep_local_recv_queue|mysql_global_status_wsrep_local_state|mysql_global_status_wsrep_ready|mysql_global_variables_innodb_additional_mem_pool_size|mysql_global_variables_innodb_buffer_pool_size|mysql_global_variables_innodb_log_buffer_size|mysql_global_variables_key_buffer_size|mysql_global_variables_max_connections|mysql_global_variables_open_files_limit|mysql_global_variables_query_cache_size|mysql_global_variables_table_definition_cache|mysql_global_variables_table_open_cache|mysql_global_variables_thread_cache_size|mysql_global_variables_tokudb_cache_size|mysql_global_variables_wsrep_desync|mysql_heartbeat_now_timestamp_seconds|mysql_heartbeat_stored_timestamp_seconds|mysql_info_schema_processlist_threads|mysql_slave_status_seconds_behind_master|mysql_slave_status_slave_io_running|mysql_slave_status_slave_sql_running|mysql_slave_status_sql_delay|mysql_up)\"\n\t}\n\n\targument + \"scrape_interval\" {\n\t\tcomment = \"How often to scrape metrics from the targets + (default: 60s)\"\n\t\toptional = true\n\t}\n\n\targument \"scrape_timeout\" {\n\t\tcomment + \ = \"How long before a scrape times out (default: 10s)\"\n\t\toptional = true\n\t}\n\n\tremote.kubernetes.secret + \"mysql\" {\n\t\tname = coalesce(argument.name.value, \"alloy-integrations-mysql\")\n\t\tnamespace + = coalesce(argument.namespace.value, \"monitoring-system\")\n\t}\n\n\t/***************************************************************\n\t* + Integrations Mysql\n\t****************************************************************/\n\tprometheus.exporter.mysql + \"integrations_mysqld_exporter\" {\n\t\tdata_source_name = nonsensitive(remote.kubernetes.secret.mysql.data[\"mysql-username\"]) + + \":\" + nonsensitive(remote.kubernetes.secret.mysql.data[\"mysql-password\"]) + + \"@(\" + nonsensitive(remote.kubernetes.secret.mysql.data[\"mysql-host\"]) + + \")/\"\n\t}\n\n\t/***************************************************************\n\t* + Discovery Relabelings (pre-scrape)\n\t****************************************************************/\n\tdiscovery.relabel + \"integrations_mysqld_exporter\" {\n\t\ttargets = prometheus.exporter.mysql.integrations_mysqld_exporter.targets\n\n\t\trule + {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = coalesce(argument.job_label.value, + \"integrations/kubernetes/mysql\")\n\t\t}\n\n\t\trule {\n\t\t\ttarget_label = + \"instance\"\n\t\t\treplacement = coalesce(nonsensitive(remote.kubernetes.secret.mysql.data[\"instance-name\"]), + constants.hostname)\n\t\t}\n\t}\n\n\t/***************************************************************\n\t* + Prometheus Scrape Integrations Targets\n\t****************************************************************/\n\tprometheus.scrape + \"integrations_mysqld_exporter\" {\n\t\ttargets = concat(\n\t\t\tdiscovery.relabel.integrations_mysqld_exporter.output,\n\t\t)\n\n\t\tenable_protobuf_negotiation + = true\n\t\tscrape_classic_histograms = true\n\n\t\tscrape_interval = coalesce(argument.scrape_interval.value, + \"60s\")\n\t\tscrape_timeout = coalesce(argument.scrape_timeout.value, \"10s\")\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\n\t\tforward_to = [prometheus.relabel.integrations_mysqld_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* + Prometheus Metric Relabelings (post-scrape)\n\t****************************************************************/\n\tprometheus.relabel + \"integrations_mysqld_exporter\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\t// + keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels + = [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction + \ = \"keep\"\n\t\t}\n\t}\n}\n" + redis.alloy: "/*\nModule Components: component_redis_exporter\n*/\n\ndeclare \"redis_exporter_metrics_scrape\" + {\n\n\t/*****************************************************************\n\t* + ARGUMENTS\n\t*****************************************************************/\n\targument + \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected + metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\tcomment + \ = \"job label (default: integrations/kubernetes/redis_exporter)\"\n\t\toptional + = true\n\t}\n\n\targument \"namespace\" {\n\t\tcomment = \"kubernetes secret + name (default: monitoring-system)\"\n\t\toptional = true\n\t}\n\n\targument \"name\" + {\n\t\tcomment = \"kubernetes secret name (default: alloy-integrations-redis)\"\n\t\toptional + = true\n\t}\n\n\targument \"keep_metrics\" {\n\t\toptional = true\n\t\tdefault + \ = \"(up|redis_blocked_clients|redis_cluster_slots_fail|redis_cluster_slots_pfail|redis_cluster_state|redis_commands_duration_seconds_total|redis_commands_total|redis_connected_clients|redis_connected_slaves|redis_db_keys|redis_db_keys_expiring|redis_evicted_keys_total|redis_keyspace_hits_total|redis_keyspace_misses_total|redis_master_last_io_seconds_ago|redis_memory_fragmentation_ratio|redis_memory_max_bytes|redis_memory_used_bytes|redis_memory_used_rss_bytes|redis_total_system_memory_bytes|redis_up)\"\n\t}\n\n\targument + \"scrape_interval\" {\n\t\tcomment = \"How often to scrape metrics from the targets + (default: 60s)\"\n\t\toptional = true\n\t\tdefault = \"60s\"\n\t}\n\n\targument + \"scrape_timeout\" {\n\t\tcomment = \"How long before a scrape times out (default: + 10s)\"\n\t\toptional = true\n\t\tdefault = \"10s\"\n\t}\n\n\tremote.kubernetes.secret + \"redis\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname + \ = coalesce(argument.name.value, \"alloy-integrations-redis\")\n\t}\n\n\t/***************************************************************\n\t* + Integrations Redis\n\t****************************************************************/\n\tprometheus.exporter.redis + \"integrations_redis_exporter\" {\n\t\tredis_addr = nonsensitive(remote.kubernetes.secret.redis.data[\"instance-address\"])\n\t\tredis_password + = nonsensitive(remote.kubernetes.secret.redis.data[\"instance-password\"])\n\t}\n\n\t/***************************************************************\n\t* + Discovery Relabelings (pre-scrape)\n\t****************************************************************/\n\tdiscovery.relabel + \"integrations_redis_exporter\" {\n\t\ttargets = prometheus.exporter.redis.integrations_redis_exporter.targets\n\n\t\trule + {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = coalesce(argument.job_label.value, + \"integrations/kubernetes/redis_exporter\")\n\t\t}\n\n\t\trule {\n\t\t\ttarget_label + = \"instance\"\n\t\t\treplacement = coalesce(nonsensitive(remote.kubernetes.secret.redis.data[\"instance-name\"]), + constants.hostname)\n\t\t}\n\t}\n\n\t/***************************************************************\n\t* + Prometheus Scrape Integrations Targets\n\t****************************************************************/\n\tprometheus.scrape + \"integrations_redis_exporter\" {\n\t\ttargets = concat(\n\t\t\tdiscovery.relabel.integrations_redis_exporter.output,\n\t\t)\n\n\t\tenable_protobuf_negotiation + = true\n\t\tscrape_classic_histograms = true\n\n\t\tscrape_interval = argument.scrape_interval.value\n\t\tscrape_timeout + \ = argument.scrape_timeout.value\n\n\t\tclustering {\n\t\t\tenabled = true\n\t\t}\n\n\t\tforward_to + = [prometheus.relabel.integrations_redis_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* + Prometheus Metric Relabelings (post-scrape)\n\t****************************************************************/\n\tprometheus.relabel + \"integrations_redis_exporter\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\t// + keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels + = [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction + \ = \"keep\"\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 + name: alloy-integrations namespace: monitoring-system --- apiVersion: v1 @@ -546,6 +606,17 @@ data: = {\n\t\t\t\t\tstream = \"\",\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// drop the temporary container runtime label as it is no longer needed\n\t\tstage.label_drop {\n\t\t\tvalues = [\"tmp_container_runtime\"]\n\t\t}\n\t}\n}\n" + k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare + \"kubernetes_cluster_events\" {\n\n\t/*****************************************************************\n\t* + ARGUMENTS\n\t*****************************************************************/\n\targument + \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected + logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional + = true\n\t}\n\n\targument \"cluster\" {\n\t\toptional = true\n\t}\n\n\tloki.source.kubernetes_events + \"cluster_events\" {\n\t\tjob_name = coalesce(argument.job_label.value, \"integrations/kubernetes/eventhandler\")\n\t\tlog_format + = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process + \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster + = coalesce(argument.cluster.value, \"k3d\"),\n\t\t\t}\n\t\t}\n\t\tforward_to = + argument.forward_to.value\n\t}\n}\n" keep-labels.alloy: "/*\nModule Components: keep_labels\nDescription: Pre-defined set of labels to keep, this stage should always be in-place as the previous relabeing\n \ stages make every pod label and annotation a label in the pipeline, @@ -569,42 +640,11 @@ data: \"receiver\" {\n\t\tvalue = loki.process.keep_labels.receiver\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h namespace: monitoring-system --- apiVersion: v1 data: - integrations-scrape.alloy: "/*\nModule Components: integrations_scrape\nDescription: - Integrations Module Components Scrape\n\nNote: Every argument except for \"forward_to\" - is optional, and does have a defined default value. However, the values for these\n - \ arguments are not defined using the default = \" ... \" argument syntax, - but rather using the coalesce(argument.value, \" ... \").\n This is because - if the argument passed in from another consuming module is set to null, the default - = \" ... \" syntax will\n does not override the value passed in, where coalesce() - will return the first non-null value.\n*/\n\ndeclare \"integrations_scrape\" {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"name\" {\n\t\tcomment = - \"Name of the integrations config\"\n\t\toptional = true\n\t}\n\n\targument \"namespace\" - {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional = true\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\tremote.kubernetes.configmap - \"integrations\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname - \ = coalesce(argument.name.value, \"alloy-integrations\")\n\t}\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\timport.string - \"memcached\" {\n\t\tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t}\n\n\tmemcached.component_memcached - \"instance\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tnamespace = - argument.namespace.value\n\t\tname = remote.kubernetes.configmap.integrations.data[\"MEMCACHED_K8S_SECRET_NAME\"]\n\t}\n\n\t// - /*****************************************************************\n\t// * Redis - Integrations\n\t// *****************************************************************/\n\t// - import.string \"redis\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"redis.alloy\"]\n\t// - }\n\n\t// redis.component_redis_exporter \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"REDIS_K8S_SECRET_NAME\"]\n\t// - }\n\n\t// /*****************************************************************\n\t// - * Mysql Integrations\n\t// *****************************************************************/\n\t// - import.string \"mysql\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"mysql.alloy\"]\n\t// - }\n\n\t// mysql.component_mysql \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"MYSQL_K8S_SECRET_NAME\"]\n\t// - }\n}\n" podmonitors-scrape.alloy: "/*\nModule Components: podmonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.podmonitors\n*/\n\ndeclare \"podmonitors_scrape\" {\n\n\t/*****************************************************************\n\t* @@ -637,7 +677,7 @@ data: {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 namespace: monitoring-system --- apiVersion: v1 @@ -1137,6 +1177,29 @@ metadata: type: Opaque --- apiVersion: v1 +data: + instance-name: cHJpbWFyeQ== + mysql-host: bXlzcWwubXlzcWwtc3lzdGVtLnN2Yy5jbHVzdGVyLmxvY2Fs + mysql-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= + mysql-username: bGd0bXA= +kind: Secret +metadata: + name: alloy-integrations-mysql + namespace: monitoring-system +type: Opaque +--- +apiVersion: v1 +data: + instance-address: cmVkaXMtbWFzdGVyLnJlZGlzLXN5c3RlbS5zdmMuY2x1c3Rlci5sb2NhbDo2Mzc5 + instance-name: cHJpbWFyeQ== + instance-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= +kind: Secret +metadata: + name: alloy-integrations-redis + namespace: monitoring-system +type: Opaque +--- +apiVersion: v1 data: MIMIR_S3_SECRET_ACCESS_KEY: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= kind: Secret @@ -1584,7 +1647,6 @@ spec: annotations: kubectl.kubernetes.io/default-container: alloy logs.agent.grafana.com/scrape: "true" - logs.agent.grafana.com/scrub-level: debug profiles.grafana.com/cpu.port_name: http-metrics profiles.grafana.com/cpu.scrape: "false" profiles.grafana.com/goroutine.port_name: http-metrics @@ -1648,8 +1710,6 @@ spec: name: config - mountPath: /etc/alloy/modules/kubernetes/metrics name: modules-kubernetes-metrics - - mountPath: /etc/alloy/modules/kubernetes/integrations - name: modules-kubernetes-integrations - mountPath: /etc/alloy/modules/kubernetes/logs name: modules-kubernetes-logs - mountPath: /etc/alloy/modules/kubernetes/traces @@ -1662,16 +1722,13 @@ spec: serviceAccountName: alloy volumes: - configMap: - name: alloy-config-bdt752b5d5 + name: alloy-config-4m6599mmm2 name: config - configMap: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 - name: modules-kubernetes-integrations - - configMap: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h name: modules-kubernetes-logs - configMap: name: alloy-modules-kubernetes-traces-8mgm8th9m5 diff --git a/kubernetes/monolithic-mode/logs/kustomization.yaml b/kubernetes/monolithic-mode/logs/kustomization.yaml index ba86bf5f..68c1431e 100644 --- a/kubernetes/monolithic-mode/logs/kustomization.yaml +++ b/kubernetes/monolithic-mode/logs/kustomization.yaml @@ -9,6 +9,7 @@ kind: Kustomization resources: - ../../common/alloy +- ../../common/alloy/configs/kubernetes/integrations - loki # optional diff --git a/kubernetes/monolithic-mode/logs/logs.alloy b/kubernetes/monolithic-mode/logs/logs.alloy index a3883dad..178fa156 100644 --- a/kubernetes/monolithic-mode/logs/logs.alloy +++ b/kubernetes/monolithic-mode/logs/logs.alloy @@ -25,6 +25,11 @@ import.file "logs" { filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/kubernetes/logs" } +logs.kubernetes_cluster_events "kubernetes" { + cluster = "k3d-k3s-codelab" + forward_to = [logs.keep_labels.kubernetes.receiver] +} + logs.annotations_scrape "kubernetes" { annotation_prefix = "logs.grafana.com" forward_to = [logs.keep_labels.kubernetes.receiver] @@ -41,17 +46,54 @@ import.file "metrics" { filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/kubernetes/metrics" } -metrics.integrations_scrape "kubernetes" { +metrics.podmonitors_scrape "kubernetes" { + forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] +} + +metrics.servicemonitors_scrape "kubernetes" { forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] +} +/***************************************************************** +* Alloy Integrations +*****************************************************************/ +remote.kubernetes.configmap "integrations" { namespace = "monitoring-system" name = "alloy-integrations" } -metrics.podmonitors_scrape "kubernetes" { - forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] +// Memcached Integrations +import.string "memcached" { + content = remote.kubernetes.configmap.integrations.data["memcached.alloy"] } -metrics.servicemonitors_scrape "kubernetes" { +memcached.memcached_metrics_scrape "instance" { forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] + + namespace = "monitoring-system" + name = remote.kubernetes.configmap.integrations.data["MEMCACHED_K8S_SECRET_NAME"] } + +// // Redis Integrations +// import.string "redis" { +// content = remote.kubernetes.configmap.integrations.data["redis.alloy"] +// } + +// redis.redis_exporter_metrics_scrape "instance" { +// forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] + +// namespace = "monitoring-system" +// name = remote.kubernetes.configmap.integrations.data["REDIS_K8S_SECRET_NAME"] +// } + +// // Mysql Integrations +// import.string "mysql" { +// content = remote.kubernetes.configmap.integrations.data["mysql.alloy"] +// } + +// mysql.mysql_metrics_scrape "instance" { +// forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] + +// namespace = "monitoring-system" +// name = remote.kubernetes.configmap.integrations.data["MYSQL_K8S_SECRET_NAME"] +// } diff --git a/kubernetes/monolithic-mode/metrics/k8s-all-in-one.yaml b/kubernetes/monolithic-mode/metrics/k8s-all-in-one.yaml index 96e28579..519506e2 100644 --- a/kubernetes/monolithic-mode/metrics/k8s-all-in-one.yaml +++ b/kubernetes/monolithic-mode/metrics/k8s-all-in-one.yaml @@ -154,86 +154,15 @@ data: = coalesce(env(\"SELF_HOSTED_METRICS_ENDPOINT_URL\"), \"http://nginx.gateway.svc:8080/api/v1/push\")\n}\n\n/********************************************\n * Metrics\n ********************************************/\nimport.file \"metrics\" {\n\tfilename = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") - + \"/kubernetes/metrics\"\n}\n\nmetrics.integrations_scrape \"kubernetes\" {\n\tforward_to - = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.podmonitors_scrape - \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape + + \"/kubernetes/metrics\"\n}\n\nmetrics.podmonitors_scrape \"kubernetes\" {\n\tforward_to + = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\n// metrics.annotations_scrape \"kubernetes\" {\n// \tlabel_prefix = \"metrics.grafana.com\"\n// \tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n// \tscrape_interval = \"15s\"\n// }\n" kind: ConfigMap metadata: - name: alloy-config-m6chdfm49m - namespace: monitoring-system ---- -apiVersion: v1 -data: - MEMCACHED_K8S_SECRET_NAME: alloy-integrations-memcached - memcached.alloy: "/*\nModule Components: component_memcached\n*/\n\ndeclare \"component_memcached\" - {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\tcomment - \ = \"job label (default: integrations/kubernetes/memcached)\"\n\t\toptional = - true\n\t}\n\n\targument \"namespace\" {\n\t\tcomment = \"kubernetes secret name - (default: monitoring-system)\"\n\t\toptional = true\n\t}\n\n\targument \"name\" - {\n\t\tcomment = \"kubernetes secret name (default: alloy-integrations-redis)\"\n\t\toptional - = true\n\t}\n\n\targument \"keep_metrics\" {\n\t\toptional = true\n\t\tdefault - \ = \"(up|memcached_commands_total|memcached_connections_total|memcached_current_bytes|memcached_current_connections|memcached_current_items|memcached_items_evicted_total|memcached_items_total|memcached_max_connections|memcached_read_bytes_total|memcached_up|memcached_uptime_seconds|memcached_version|memcached_written_bytes_total)\"\n\t}\n\n\targument - \"scrape_interval\" {\n\t\tcomment = \"How often to scrape metrics from the targets - (default: 60s)\"\n\t\toptional = true\n\t}\n\n\targument \"scrape_timeout\" {\n\t\tcomment - \ = \"How long before a scrape times out (default: 10s)\"\n\t\toptional = true\n\t}\n\n\tremote.kubernetes.secret - \"memcached\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname - \ = coalesce(argument.name.value, \"alloy-integrations-memcached\")\n\t}\n\n\t/***************************************************************\n\t* - Integrations Memcached\n\t****************************************************************/\n\t// - https://grafana.com/docs/alloy/latest/reference/components/prometheus.exporter.memcached/\n\tprometheus.exporter.memcached - \"integrations_memcached_exporter\" {\n\t\taddress = nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-address\"])\n\t\ttimeout - = nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-timeout\"])\n\t}\n\n\t/***************************************************************\n\t* - Discovery Relabelings (pre-scrape)\n\t****************************************************************/\n\tdiscovery.relabel - \"integrations_memcached_exporter\" {\n\t\ttargets = prometheus.exporter.memcached.integrations_memcached_exporter.targets\n\n\t\trule - {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = coalesce(argument.job_label.value, - \"integrations/kubernetes/memcached\")\n\t\t}\n\n\t\trule {\n\t\t\ttarget_label - = \"instance\"\n\t\t\treplacement = coalesce(nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-name\"]), - constants.hostname)\n\t\t}\n\t}\n\n\t/***************************************************************\n\t* - Prometheus Scrape Integrations Targets\n\t****************************************************************/\n\tprometheus.scrape - \"integrations_memcached_exporter\" {\n\t\ttargets = concat(\n\t\t\tdiscovery.relabel.integrations_memcached_exporter.output,\n\t\t)\n\n\t\tenable_protobuf_negotiation - = true\n\t\tscrape_classic_histograms = true\n\n\t\tscrape_interval = coalesce(argument.scrape_interval.value, - \"60s\")\n\t\tscrape_timeout = coalesce(argument.scrape_timeout.value, \"10s\")\n\n\t\tclustering - {\n\t\t\tenabled = true\n\t\t}\n\n\t\tforward_to = [prometheus.relabel.integrations_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* - Prometheus Metric Relabelings (post-scrape)\n\t****************************************************************/\n\tprometheus.relabel - \"integrations_memcached_exporter\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\t// - keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels - = [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction - \ = \"keep\"\n\t\t}\n\t}\n}\n" -kind: ConfigMap -metadata: - name: alloy-integrations - namespace: monitoring-system ---- -apiVersion: v1 -data: - k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare - \"component_cluster_events\" {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected - logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/eventhandler\"\n\t}\n\n\targument - \"cluster\" {\n\t\toptional = true\n\t\tdefault = \"k3d\"\n\t}\n\n\tloki.source.kubernetes_events - \"cluster_events\" {\n\t\tjob_name = argument.job_label.value\n\t\tlog_format - = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process - \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster - = argument.cluster.value,\n\t\t\t}\n\t\t}\n\t\tforward_to = argument.forward_to.value\n\t}\n\n\t// - // Logs Service\n\t// remote.kubernetes.secret \"logs_service\" {\n\t// \tname - \ = \"loki-k8s-monitoring\"\n\t// \tnamespace = \"k8s-monitoring\"\n\t// }\n\t// - // Loki\n\t// loki.write \"logs_service\" {\n\t// \tendpoint {\n\t// \t\turl = - nonsensitive(remote.kubernetes.secret.logs_service.data[\"host\"]) + \"/loki/api/v1/push\"\n\t// - \t\ttenant_id = nonsensitive(remote.kubernetes.secret.logs_service.data[\"tenantId\"])\n\n\t// - \t\tbasic_auth {\n\t// \t\t\tusername = nonsensitive(remote.kubernetes.secret.logs_service.data[\"username\"])\n\t// - \t\t\tpassword = remote.kubernetes.secret.logs_service.data[\"password\"]\n\t// - \t\t}\n\t// \t}\n\t// }\n}\n" -kind: ConfigMap -metadata: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 + name: alloy-config-55dd47md5f namespace: monitoring-system --- apiVersion: v1 @@ -330,6 +259,17 @@ data: = {\n\t\t\t\t\tstream = \"\",\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// drop the temporary container runtime label as it is no longer needed\n\t\tstage.label_drop {\n\t\t\tvalues = [\"tmp_container_runtime\"]\n\t\t}\n\t}\n}\n" + k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare + \"kubernetes_cluster_events\" {\n\n\t/*****************************************************************\n\t* + ARGUMENTS\n\t*****************************************************************/\n\targument + \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected + logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional + = true\n\t}\n\n\targument \"cluster\" {\n\t\toptional = true\n\t}\n\n\tloki.source.kubernetes_events + \"cluster_events\" {\n\t\tjob_name = coalesce(argument.job_label.value, \"integrations/kubernetes/eventhandler\")\n\t\tlog_format + = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process + \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster + = coalesce(argument.cluster.value, \"k3d\"),\n\t\t\t}\n\t\t}\n\t\tforward_to = + argument.forward_to.value\n\t}\n}\n" keep-labels.alloy: "/*\nModule Components: keep_labels\nDescription: Pre-defined set of labels to keep, this stage should always be in-place as the previous relabeing\n \ stages make every pod label and annotation a label in the pipeline, @@ -353,42 +293,11 @@ data: \"receiver\" {\n\t\tvalue = loki.process.keep_labels.receiver\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h namespace: monitoring-system --- apiVersion: v1 data: - integrations-scrape.alloy: "/*\nModule Components: integrations_scrape\nDescription: - Integrations Module Components Scrape\n\nNote: Every argument except for \"forward_to\" - is optional, and does have a defined default value. However, the values for these\n - \ arguments are not defined using the default = \" ... \" argument syntax, - but rather using the coalesce(argument.value, \" ... \").\n This is because - if the argument passed in from another consuming module is set to null, the default - = \" ... \" syntax will\n does not override the value passed in, where coalesce() - will return the first non-null value.\n*/\n\ndeclare \"integrations_scrape\" {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"name\" {\n\t\tcomment = - \"Name of the integrations config\"\n\t\toptional = true\n\t}\n\n\targument \"namespace\" - {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional = true\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\tremote.kubernetes.configmap - \"integrations\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname - \ = coalesce(argument.name.value, \"alloy-integrations\")\n\t}\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\timport.string - \"memcached\" {\n\t\tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t}\n\n\tmemcached.component_memcached - \"instance\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tnamespace = - argument.namespace.value\n\t\tname = remote.kubernetes.configmap.integrations.data[\"MEMCACHED_K8S_SECRET_NAME\"]\n\t}\n\n\t// - /*****************************************************************\n\t// * Redis - Integrations\n\t// *****************************************************************/\n\t// - import.string \"redis\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"redis.alloy\"]\n\t// - }\n\n\t// redis.component_redis_exporter \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"REDIS_K8S_SECRET_NAME\"]\n\t// - }\n\n\t// /*****************************************************************\n\t// - * Mysql Integrations\n\t// *****************************************************************/\n\t// - import.string \"mysql\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"mysql.alloy\"]\n\t// - }\n\n\t// mysql.component_mysql \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"MYSQL_K8S_SECRET_NAME\"]\n\t// - }\n}\n" podmonitors-scrape.alloy: "/*\nModule Components: podmonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.podmonitors\n*/\n\ndeclare \"podmonitors_scrape\" {\n\n\t/*****************************************************************\n\t* @@ -421,7 +330,7 @@ data: {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 namespace: monitoring-system --- apiVersion: v1 @@ -895,17 +804,6 @@ metadata: type: Opaque --- apiVersion: v1 -data: - instance-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= - instance-name: cHJpbWFyeQ== - instance-timeout: NXM= -kind: Secret -metadata: - name: alloy-integrations-memcached - namespace: monitoring-system -type: Opaque ---- -apiVersion: v1 data: MIMIR_S3_SECRET_ACCESS_KEY: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= kind: Secret @@ -1161,7 +1059,6 @@ spec: annotations: kubectl.kubernetes.io/default-container: alloy logs.agent.grafana.com/scrape: "true" - logs.agent.grafana.com/scrub-level: debug profiles.grafana.com/cpu.port_name: http-metrics profiles.grafana.com/cpu.scrape: "false" profiles.grafana.com/goroutine.port_name: http-metrics @@ -1225,8 +1122,6 @@ spec: name: config - mountPath: /etc/alloy/modules/kubernetes/metrics name: modules-kubernetes-metrics - - mountPath: /etc/alloy/modules/kubernetes/integrations - name: modules-kubernetes-integrations - mountPath: /etc/alloy/modules/kubernetes/logs name: modules-kubernetes-logs - mountPath: /etc/alloy/modules/kubernetes/traces @@ -1239,16 +1134,13 @@ spec: serviceAccountName: alloy volumes: - configMap: - name: alloy-config-m6chdfm49m + name: alloy-config-55dd47md5f name: config - configMap: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 - name: modules-kubernetes-integrations - - configMap: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h name: modules-kubernetes-logs - configMap: name: alloy-modules-kubernetes-traces-8mgm8th9m5 diff --git a/kubernetes/monolithic-mode/metrics/metrics.alloy b/kubernetes/monolithic-mode/metrics/metrics.alloy index 66926d75..606728c9 100644 --- a/kubernetes/monolithic-mode/metrics/metrics.alloy +++ b/kubernetes/monolithic-mode/metrics/metrics.alloy @@ -24,10 +24,6 @@ import.file "metrics" { filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/kubernetes/metrics" } -metrics.integrations_scrape "kubernetes" { - forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] -} - metrics.podmonitors_scrape "kubernetes" { forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] } diff --git a/kubernetes/monolithic-mode/profiles/k8s-all-in-one.yaml b/kubernetes/monolithic-mode/profiles/k8s-all-in-one.yaml index eeb5c528..96bb12ac 100644 --- a/kubernetes/monolithic-mode/profiles/k8s-all-in-one.yaml +++ b/kubernetes/monolithic-mode/profiles/k8s-all-in-one.yaml @@ -222,83 +222,12 @@ data: annotation_prefix = \"profiles.grafana.com\"\n\tforward_to = [provider.self_hosted_stack.kubernetes.profiles_receiver]\n}\n\n/********************************************\n * Metrics\n ********************************************/\nimport.file \"metrics\" {\n\tfilename = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") - + \"/kubernetes/metrics\"\n}\n\nmetrics.integrations_scrape \"kubernetes\" {\n\tforward_to - = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.podmonitors_scrape - \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape + + \"/kubernetes/metrics\"\n}\n\nmetrics.podmonitors_scrape \"kubernetes\" {\n\tforward_to + = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n" kind: ConfigMap metadata: - name: alloy-config-5k62427t46 - namespace: monitoring-system ---- -apiVersion: v1 -data: - MEMCACHED_K8S_SECRET_NAME: alloy-integrations-memcached - memcached.alloy: "/*\nModule Components: component_memcached\n*/\n\ndeclare \"component_memcached\" - {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\tcomment - \ = \"job label (default: integrations/kubernetes/memcached)\"\n\t\toptional = - true\n\t}\n\n\targument \"namespace\" {\n\t\tcomment = \"kubernetes secret name - (default: monitoring-system)\"\n\t\toptional = true\n\t}\n\n\targument \"name\" - {\n\t\tcomment = \"kubernetes secret name (default: alloy-integrations-redis)\"\n\t\toptional - = true\n\t}\n\n\targument \"keep_metrics\" {\n\t\toptional = true\n\t\tdefault - \ = \"(up|memcached_commands_total|memcached_connections_total|memcached_current_bytes|memcached_current_connections|memcached_current_items|memcached_items_evicted_total|memcached_items_total|memcached_max_connections|memcached_read_bytes_total|memcached_up|memcached_uptime_seconds|memcached_version|memcached_written_bytes_total)\"\n\t}\n\n\targument - \"scrape_interval\" {\n\t\tcomment = \"How often to scrape metrics from the targets - (default: 60s)\"\n\t\toptional = true\n\t}\n\n\targument \"scrape_timeout\" {\n\t\tcomment - \ = \"How long before a scrape times out (default: 10s)\"\n\t\toptional = true\n\t}\n\n\tremote.kubernetes.secret - \"memcached\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname - \ = coalesce(argument.name.value, \"alloy-integrations-memcached\")\n\t}\n\n\t/***************************************************************\n\t* - Integrations Memcached\n\t****************************************************************/\n\t// - https://grafana.com/docs/alloy/latest/reference/components/prometheus.exporter.memcached/\n\tprometheus.exporter.memcached - \"integrations_memcached_exporter\" {\n\t\taddress = nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-address\"])\n\t\ttimeout - = nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-timeout\"])\n\t}\n\n\t/***************************************************************\n\t* - Discovery Relabelings (pre-scrape)\n\t****************************************************************/\n\tdiscovery.relabel - \"integrations_memcached_exporter\" {\n\t\ttargets = prometheus.exporter.memcached.integrations_memcached_exporter.targets\n\n\t\trule - {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = coalesce(argument.job_label.value, - \"integrations/kubernetes/memcached\")\n\t\t}\n\n\t\trule {\n\t\t\ttarget_label - = \"instance\"\n\t\t\treplacement = coalesce(nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-name\"]), - constants.hostname)\n\t\t}\n\t}\n\n\t/***************************************************************\n\t* - Prometheus Scrape Integrations Targets\n\t****************************************************************/\n\tprometheus.scrape - \"integrations_memcached_exporter\" {\n\t\ttargets = concat(\n\t\t\tdiscovery.relabel.integrations_memcached_exporter.output,\n\t\t)\n\n\t\tenable_protobuf_negotiation - = true\n\t\tscrape_classic_histograms = true\n\n\t\tscrape_interval = coalesce(argument.scrape_interval.value, - \"60s\")\n\t\tscrape_timeout = coalesce(argument.scrape_timeout.value, \"10s\")\n\n\t\tclustering - {\n\t\t\tenabled = true\n\t\t}\n\n\t\tforward_to = [prometheus.relabel.integrations_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* - Prometheus Metric Relabelings (post-scrape)\n\t****************************************************************/\n\tprometheus.relabel - \"integrations_memcached_exporter\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\t// - keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels - = [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction - \ = \"keep\"\n\t\t}\n\t}\n}\n" -kind: ConfigMap -metadata: - name: alloy-integrations - namespace: monitoring-system ---- -apiVersion: v1 -data: - k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare - \"component_cluster_events\" {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected - logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/eventhandler\"\n\t}\n\n\targument - \"cluster\" {\n\t\toptional = true\n\t\tdefault = \"k3d\"\n\t}\n\n\tloki.source.kubernetes_events - \"cluster_events\" {\n\t\tjob_name = argument.job_label.value\n\t\tlog_format - = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process - \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster - = argument.cluster.value,\n\t\t\t}\n\t\t}\n\t\tforward_to = argument.forward_to.value\n\t}\n\n\t// - // Logs Service\n\t// remote.kubernetes.secret \"logs_service\" {\n\t// \tname - \ = \"loki-k8s-monitoring\"\n\t// \tnamespace = \"k8s-monitoring\"\n\t// }\n\t// - // Loki\n\t// loki.write \"logs_service\" {\n\t// \tendpoint {\n\t// \t\turl = - nonsensitive(remote.kubernetes.secret.logs_service.data[\"host\"]) + \"/loki/api/v1/push\"\n\t// - \t\ttenant_id = nonsensitive(remote.kubernetes.secret.logs_service.data[\"tenantId\"])\n\n\t// - \t\tbasic_auth {\n\t// \t\t\tusername = nonsensitive(remote.kubernetes.secret.logs_service.data[\"username\"])\n\t// - \t\t\tpassword = remote.kubernetes.secret.logs_service.data[\"password\"]\n\t// - \t\t}\n\t// \t}\n\t// }\n}\n" -kind: ConfigMap -metadata: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 + name: alloy-config-56888m5g8t namespace: monitoring-system --- apiVersion: v1 @@ -395,6 +324,17 @@ data: = {\n\t\t\t\t\tstream = \"\",\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// drop the temporary container runtime label as it is no longer needed\n\t\tstage.label_drop {\n\t\t\tvalues = [\"tmp_container_runtime\"]\n\t\t}\n\t}\n}\n" + k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare + \"kubernetes_cluster_events\" {\n\n\t/*****************************************************************\n\t* + ARGUMENTS\n\t*****************************************************************/\n\targument + \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected + logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional + = true\n\t}\n\n\targument \"cluster\" {\n\t\toptional = true\n\t}\n\n\tloki.source.kubernetes_events + \"cluster_events\" {\n\t\tjob_name = coalesce(argument.job_label.value, \"integrations/kubernetes/eventhandler\")\n\t\tlog_format + = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process + \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster + = coalesce(argument.cluster.value, \"k3d\"),\n\t\t\t}\n\t\t}\n\t\tforward_to = + argument.forward_to.value\n\t}\n}\n" keep-labels.alloy: "/*\nModule Components: keep_labels\nDescription: Pre-defined set of labels to keep, this stage should always be in-place as the previous relabeing\n \ stages make every pod label and annotation a label in the pipeline, @@ -418,42 +358,11 @@ data: \"receiver\" {\n\t\tvalue = loki.process.keep_labels.receiver\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h namespace: monitoring-system --- apiVersion: v1 data: - integrations-scrape.alloy: "/*\nModule Components: integrations_scrape\nDescription: - Integrations Module Components Scrape\n\nNote: Every argument except for \"forward_to\" - is optional, and does have a defined default value. However, the values for these\n - \ arguments are not defined using the default = \" ... \" argument syntax, - but rather using the coalesce(argument.value, \" ... \").\n This is because - if the argument passed in from another consuming module is set to null, the default - = \" ... \" syntax will\n does not override the value passed in, where coalesce() - will return the first non-null value.\n*/\n\ndeclare \"integrations_scrape\" {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"name\" {\n\t\tcomment = - \"Name of the integrations config\"\n\t\toptional = true\n\t}\n\n\targument \"namespace\" - {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional = true\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\tremote.kubernetes.configmap - \"integrations\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname - \ = coalesce(argument.name.value, \"alloy-integrations\")\n\t}\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\timport.string - \"memcached\" {\n\t\tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t}\n\n\tmemcached.component_memcached - \"instance\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tnamespace = - argument.namespace.value\n\t\tname = remote.kubernetes.configmap.integrations.data[\"MEMCACHED_K8S_SECRET_NAME\"]\n\t}\n\n\t// - /*****************************************************************\n\t// * Redis - Integrations\n\t// *****************************************************************/\n\t// - import.string \"redis\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"redis.alloy\"]\n\t// - }\n\n\t// redis.component_redis_exporter \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"REDIS_K8S_SECRET_NAME\"]\n\t// - }\n\n\t// /*****************************************************************\n\t// - * Mysql Integrations\n\t// *****************************************************************/\n\t// - import.string \"mysql\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"mysql.alloy\"]\n\t// - }\n\n\t// mysql.component_mysql \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"MYSQL_K8S_SECRET_NAME\"]\n\t// - }\n}\n" podmonitors-scrape.alloy: "/*\nModule Components: podmonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.podmonitors\n*/\n\ndeclare \"podmonitors_scrape\" {\n\n\t/*****************************************************************\n\t* @@ -486,7 +395,7 @@ data: {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 namespace: monitoring-system --- apiVersion: v1 @@ -1008,17 +917,6 @@ metadata: type: Opaque --- apiVersion: v1 -data: - instance-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= - instance-name: cHJpbWFyeQ== - instance-timeout: NXM= -kind: Secret -metadata: - name: alloy-integrations-memcached - namespace: monitoring-system -type: Opaque ---- -apiVersion: v1 data: MIMIR_S3_SECRET_ACCESS_KEY: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= kind: Secret @@ -1357,7 +1255,6 @@ spec: annotations: kubectl.kubernetes.io/default-container: alloy logs.agent.grafana.com/scrape: "true" - logs.agent.grafana.com/scrub-level: debug profiles.grafana.com/cpu.port_name: http-metrics profiles.grafana.com/cpu.scrape: "false" profiles.grafana.com/goroutine.port_name: http-metrics @@ -1421,8 +1318,6 @@ spec: name: config - mountPath: /etc/alloy/modules/kubernetes/metrics name: modules-kubernetes-metrics - - mountPath: /etc/alloy/modules/kubernetes/integrations - name: modules-kubernetes-integrations - mountPath: /etc/alloy/modules/kubernetes/logs name: modules-kubernetes-logs - mountPath: /etc/alloy/modules/kubernetes/traces @@ -1435,16 +1330,13 @@ spec: serviceAccountName: alloy volumes: - configMap: - name: alloy-config-5k62427t46 + name: alloy-config-56888m5g8t name: config - configMap: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 - name: modules-kubernetes-integrations - - configMap: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h name: modules-kubernetes-logs - configMap: name: alloy-modules-kubernetes-traces-8mgm8th9m5 diff --git a/kubernetes/monolithic-mode/profiles/profiles.alloy b/kubernetes/monolithic-mode/profiles/profiles.alloy index 691f7588..cf0354fa 100644 --- a/kubernetes/monolithic-mode/profiles/profiles.alloy +++ b/kubernetes/monolithic-mode/profiles/profiles.alloy @@ -37,10 +37,6 @@ import.file "metrics" { filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/kubernetes/metrics" } -metrics.integrations_scrape "kubernetes" { - forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] -} - metrics.podmonitors_scrape "kubernetes" { forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] } diff --git a/kubernetes/monolithic-mode/traces/k8s-all-in-one.yaml b/kubernetes/monolithic-mode/traces/k8s-all-in-one.yaml index 13ec029c..0a42722f 100644 --- a/kubernetes/monolithic-mode/traces/k8s-all-in-one.yaml +++ b/kubernetes/monolithic-mode/traces/k8s-all-in-one.yaml @@ -232,83 +232,12 @@ data: Forward Alloy internal spans to traces process.\n\twrite_to = [traces.process_and_transform.kubernetes.alloy_traces_input]\n}\n\n/********************************************\n * Metrics\n ********************************************/\nimport.file \"metrics\" {\n\tfilename = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") - + \"/kubernetes/metrics\"\n}\n\nmetrics.integrations_scrape \"kubernetes\" {\n\tforward_to - = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.podmonitors_scrape - \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape + + \"/kubernetes/metrics\"\n}\n\nmetrics.podmonitors_scrape \"kubernetes\" {\n\tforward_to + = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n" kind: ConfigMap metadata: - name: alloy-config-gt2k68744f - namespace: monitoring-system ---- -apiVersion: v1 -data: - MEMCACHED_K8S_SECRET_NAME: alloy-integrations-memcached - memcached.alloy: "/*\nModule Components: component_memcached\n*/\n\ndeclare \"component_memcached\" - {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\tcomment - \ = \"job label (default: integrations/kubernetes/memcached)\"\n\t\toptional = - true\n\t}\n\n\targument \"namespace\" {\n\t\tcomment = \"kubernetes secret name - (default: monitoring-system)\"\n\t\toptional = true\n\t}\n\n\targument \"name\" - {\n\t\tcomment = \"kubernetes secret name (default: alloy-integrations-redis)\"\n\t\toptional - = true\n\t}\n\n\targument \"keep_metrics\" {\n\t\toptional = true\n\t\tdefault - \ = \"(up|memcached_commands_total|memcached_connections_total|memcached_current_bytes|memcached_current_connections|memcached_current_items|memcached_items_evicted_total|memcached_items_total|memcached_max_connections|memcached_read_bytes_total|memcached_up|memcached_uptime_seconds|memcached_version|memcached_written_bytes_total)\"\n\t}\n\n\targument - \"scrape_interval\" {\n\t\tcomment = \"How often to scrape metrics from the targets - (default: 60s)\"\n\t\toptional = true\n\t}\n\n\targument \"scrape_timeout\" {\n\t\tcomment - \ = \"How long before a scrape times out (default: 10s)\"\n\t\toptional = true\n\t}\n\n\tremote.kubernetes.secret - \"memcached\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname - \ = coalesce(argument.name.value, \"alloy-integrations-memcached\")\n\t}\n\n\t/***************************************************************\n\t* - Integrations Memcached\n\t****************************************************************/\n\t// - https://grafana.com/docs/alloy/latest/reference/components/prometheus.exporter.memcached/\n\tprometheus.exporter.memcached - \"integrations_memcached_exporter\" {\n\t\taddress = nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-address\"])\n\t\ttimeout - = nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-timeout\"])\n\t}\n\n\t/***************************************************************\n\t* - Discovery Relabelings (pre-scrape)\n\t****************************************************************/\n\tdiscovery.relabel - \"integrations_memcached_exporter\" {\n\t\ttargets = prometheus.exporter.memcached.integrations_memcached_exporter.targets\n\n\t\trule - {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = coalesce(argument.job_label.value, - \"integrations/kubernetes/memcached\")\n\t\t}\n\n\t\trule {\n\t\t\ttarget_label - = \"instance\"\n\t\t\treplacement = coalesce(nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-name\"]), - constants.hostname)\n\t\t}\n\t}\n\n\t/***************************************************************\n\t* - Prometheus Scrape Integrations Targets\n\t****************************************************************/\n\tprometheus.scrape - \"integrations_memcached_exporter\" {\n\t\ttargets = concat(\n\t\t\tdiscovery.relabel.integrations_memcached_exporter.output,\n\t\t)\n\n\t\tenable_protobuf_negotiation - = true\n\t\tscrape_classic_histograms = true\n\n\t\tscrape_interval = coalesce(argument.scrape_interval.value, - \"60s\")\n\t\tscrape_timeout = coalesce(argument.scrape_timeout.value, \"10s\")\n\n\t\tclustering - {\n\t\t\tenabled = true\n\t\t}\n\n\t\tforward_to = [prometheus.relabel.integrations_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* - Prometheus Metric Relabelings (post-scrape)\n\t****************************************************************/\n\tprometheus.relabel - \"integrations_memcached_exporter\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\t// - keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels - = [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction - \ = \"keep\"\n\t\t}\n\t}\n}\n" -kind: ConfigMap -metadata: - name: alloy-integrations - namespace: monitoring-system ---- -apiVersion: v1 -data: - k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare - \"component_cluster_events\" {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected - logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/eventhandler\"\n\t}\n\n\targument - \"cluster\" {\n\t\toptional = true\n\t\tdefault = \"k3d\"\n\t}\n\n\tloki.source.kubernetes_events - \"cluster_events\" {\n\t\tjob_name = argument.job_label.value\n\t\tlog_format - = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process - \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster - = argument.cluster.value,\n\t\t\t}\n\t\t}\n\t\tforward_to = argument.forward_to.value\n\t}\n\n\t// - // Logs Service\n\t// remote.kubernetes.secret \"logs_service\" {\n\t// \tname - \ = \"loki-k8s-monitoring\"\n\t// \tnamespace = \"k8s-monitoring\"\n\t// }\n\t// - // Loki\n\t// loki.write \"logs_service\" {\n\t// \tendpoint {\n\t// \t\turl = - nonsensitive(remote.kubernetes.secret.logs_service.data[\"host\"]) + \"/loki/api/v1/push\"\n\t// - \t\ttenant_id = nonsensitive(remote.kubernetes.secret.logs_service.data[\"tenantId\"])\n\n\t// - \t\tbasic_auth {\n\t// \t\t\tusername = nonsensitive(remote.kubernetes.secret.logs_service.data[\"username\"])\n\t// - \t\t\tpassword = remote.kubernetes.secret.logs_service.data[\"password\"]\n\t// - \t\t}\n\t// \t}\n\t// }\n}\n" -kind: ConfigMap -metadata: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 + name: alloy-config-t69dk2g68h namespace: monitoring-system --- apiVersion: v1 @@ -405,6 +334,17 @@ data: = {\n\t\t\t\t\tstream = \"\",\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// drop the temporary container runtime label as it is no longer needed\n\t\tstage.label_drop {\n\t\t\tvalues = [\"tmp_container_runtime\"]\n\t\t}\n\t}\n}\n" + k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare + \"kubernetes_cluster_events\" {\n\n\t/*****************************************************************\n\t* + ARGUMENTS\n\t*****************************************************************/\n\targument + \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected + logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional + = true\n\t}\n\n\targument \"cluster\" {\n\t\toptional = true\n\t}\n\n\tloki.source.kubernetes_events + \"cluster_events\" {\n\t\tjob_name = coalesce(argument.job_label.value, \"integrations/kubernetes/eventhandler\")\n\t\tlog_format + = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process + \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster + = coalesce(argument.cluster.value, \"k3d\"),\n\t\t\t}\n\t\t}\n\t\tforward_to = + argument.forward_to.value\n\t}\n}\n" keep-labels.alloy: "/*\nModule Components: keep_labels\nDescription: Pre-defined set of labels to keep, this stage should always be in-place as the previous relabeing\n \ stages make every pod label and annotation a label in the pipeline, @@ -428,42 +368,11 @@ data: \"receiver\" {\n\t\tvalue = loki.process.keep_labels.receiver\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h namespace: monitoring-system --- apiVersion: v1 data: - integrations-scrape.alloy: "/*\nModule Components: integrations_scrape\nDescription: - Integrations Module Components Scrape\n\nNote: Every argument except for \"forward_to\" - is optional, and does have a defined default value. However, the values for these\n - \ arguments are not defined using the default = \" ... \" argument syntax, - but rather using the coalesce(argument.value, \" ... \").\n This is because - if the argument passed in from another consuming module is set to null, the default - = \" ... \" syntax will\n does not override the value passed in, where coalesce() - will return the first non-null value.\n*/\n\ndeclare \"integrations_scrape\" {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"name\" {\n\t\tcomment = - \"Name of the integrations config\"\n\t\toptional = true\n\t}\n\n\targument \"namespace\" - {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional = true\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\tremote.kubernetes.configmap - \"integrations\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname - \ = coalesce(argument.name.value, \"alloy-integrations\")\n\t}\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\timport.string - \"memcached\" {\n\t\tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t}\n\n\tmemcached.component_memcached - \"instance\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tnamespace = - argument.namespace.value\n\t\tname = remote.kubernetes.configmap.integrations.data[\"MEMCACHED_K8S_SECRET_NAME\"]\n\t}\n\n\t// - /*****************************************************************\n\t// * Redis - Integrations\n\t// *****************************************************************/\n\t// - import.string \"redis\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"redis.alloy\"]\n\t// - }\n\n\t// redis.component_redis_exporter \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"REDIS_K8S_SECRET_NAME\"]\n\t// - }\n\n\t// /*****************************************************************\n\t// - * Mysql Integrations\n\t// *****************************************************************/\n\t// - import.string \"mysql\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"mysql.alloy\"]\n\t// - }\n\n\t// mysql.component_mysql \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"MYSQL_K8S_SECRET_NAME\"]\n\t// - }\n}\n" podmonitors-scrape.alloy: "/*\nModule Components: podmonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.podmonitors\n*/\n\ndeclare \"podmonitors_scrape\" {\n\n\t/*****************************************************************\n\t* @@ -496,7 +405,7 @@ data: {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 namespace: monitoring-system --- apiVersion: v1 @@ -1103,17 +1012,6 @@ metadata: type: Opaque --- apiVersion: v1 -data: - instance-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= - instance-name: cHJpbWFyeQ== - instance-timeout: NXM= -kind: Secret -metadata: - name: alloy-integrations-memcached - namespace: monitoring-system -type: Opaque ---- -apiVersion: v1 data: MIMIR_S3_SECRET_ACCESS_KEY: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= kind: Secret @@ -1447,7 +1345,6 @@ spec: annotations: kubectl.kubernetes.io/default-container: alloy logs.agent.grafana.com/scrape: "true" - logs.agent.grafana.com/scrub-level: debug profiles.grafana.com/cpu.port_name: http-metrics profiles.grafana.com/cpu.scrape: "false" profiles.grafana.com/goroutine.port_name: http-metrics @@ -1511,8 +1408,6 @@ spec: name: config - mountPath: /etc/alloy/modules/kubernetes/metrics name: modules-kubernetes-metrics - - mountPath: /etc/alloy/modules/kubernetes/integrations - name: modules-kubernetes-integrations - mountPath: /etc/alloy/modules/kubernetes/logs name: modules-kubernetes-logs - mountPath: /etc/alloy/modules/kubernetes/traces @@ -1525,16 +1420,13 @@ spec: serviceAccountName: alloy volumes: - configMap: - name: alloy-config-gt2k68744f + name: alloy-config-t69dk2g68h name: config - configMap: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 - name: modules-kubernetes-integrations - - configMap: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h name: modules-kubernetes-logs - configMap: name: alloy-modules-kubernetes-traces-8mgm8th9m5 diff --git a/kubernetes/monolithic-mode/traces/traces.alloy b/kubernetes/monolithic-mode/traces/traces.alloy index 8f8852b1..cbae15b5 100644 --- a/kubernetes/monolithic-mode/traces/traces.alloy +++ b/kubernetes/monolithic-mode/traces/traces.alloy @@ -48,10 +48,6 @@ import.file "metrics" { filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/kubernetes/metrics" } -metrics.integrations_scrape "kubernetes" { - forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] -} - metrics.podmonitors_scrape "kubernetes" { forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] } diff --git a/kubernetes/read-write-mode/logs/k8s-all-in-one.yaml b/kubernetes/read-write-mode/logs/k8s-all-in-one.yaml index d286eb00..30e7a532 100644 --- a/kubernetes/read-write-mode/logs/k8s-all-in-one.yaml +++ b/kubernetes/read-write-mode/logs/k8s-all-in-one.yaml @@ -379,19 +379,33 @@ data: = [provider.self_hosted_stack.kubernetes.logs_receiver]\n}\n\n/********************************************\n * Metrics\n ********************************************/\nimport.file \"metrics\" {\n\tfilename = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") - + \"/kubernetes/metrics\"\n}\n\nmetrics.integrations_scrape \"kubernetes\" {\n\tforward_to - = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.podmonitors_scrape - \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape - \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n" + + \"/kubernetes/metrics\"\n}\n\nmetrics.podmonitors_scrape \"kubernetes\" {\n\tforward_to + = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape + \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\n/*****************************************************************\n* + Alloy Integrations\n*****************************************************************/\nremote.kubernetes.configmap + \"integrations\" {\n\tnamespace = \"monitoring-system\"\n\tname = \"alloy-integrations\"\n}\n\n// + Memcached Integrations\nimport.string \"memcached\" {\n\tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n}\n\nmemcached.memcached_metrics_scrape + \"instance\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n\n\tnamespace + = \"monitoring-system\"\n\tname = remote.kubernetes.configmap.integrations.data[\"MEMCACHED_K8S_SECRET_NAME\"]\n}\n\n// + // Redis Integrations\n// import.string \"redis\" {\n// \tcontent = remote.kubernetes.configmap.integrations.data[\"redis.alloy\"]\n// + }\n\n// redis.redis_exporter_metrics_scrape \"instance\" {\n// \tforward_to = + [provider.self_hosted_stack.kubernetes.metrics_receiver]\n\n// \tnamespace = \"monitoring-system\"\n// + \tname = remote.kubernetes.configmap.integrations.data[\"REDIS_K8S_SECRET_NAME\"]\n// + }\n\n// // Mysql Integrations\n// import.string \"mysql\" {\n// \tcontent = remote.kubernetes.configmap.integrations.data[\"mysql.alloy\"]\n// + }\n\n// mysql.mysql_metrics_scrape \"instance\" {\n// \tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n\n// + \tnamespace = \"monitoring-system\"\n// \tname = remote.kubernetes.configmap.integrations.data[\"MYSQL_K8S_SECRET_NAME\"]\n// + }\n" kind: ConfigMap metadata: - name: alloy-config-8t9d8htff7 + name: alloy-config-72927d7k99 namespace: monitoring-system --- apiVersion: v1 data: MEMCACHED_K8S_SECRET_NAME: alloy-integrations-memcached - memcached.alloy: "/*\nModule Components: component_memcached\n*/\n\ndeclare \"component_memcached\" + MYSQL_K8S_SECRET_NAME: alloy-integrations-mysql + REDIS_K8S_SECRET_NAME: alloy-integrations-redis + memcached.alloy: "/*\nModule Components: component_memcached\n*/\n\ndeclare \"memcached_metrics_scrape\" {\n\n\t/*****************************************************************\n\t* ARGUMENTS\n\t*****************************************************************/\n\targument \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected @@ -427,35 +441,81 @@ data: keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels = [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction \ = \"keep\"\n\t\t}\n\t}\n}\n" -kind: ConfigMap -metadata: - name: alloy-integrations - namespace: monitoring-system ---- -apiVersion: v1 -data: - k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare - \"component_cluster_events\" {\n\n\t/*****************************************************************\n\t* + mysql.alloy: "/*\nModule Components: component_mysql\n*/\n\ndeclare \"mysql_metrics_scrape\" + {\n\n\t/*****************************************************************\n\t* ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected - logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/eventhandler\"\n\t}\n\n\targument - \"cluster\" {\n\t\toptional = true\n\t\tdefault = \"k3d\"\n\t}\n\n\tloki.source.kubernetes_events - \"cluster_events\" {\n\t\tjob_name = argument.job_label.value\n\t\tlog_format - = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process - \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster - = argument.cluster.value,\n\t\t\t}\n\t\t}\n\t\tforward_to = argument.forward_to.value\n\t}\n\n\t// - // Logs Service\n\t// remote.kubernetes.secret \"logs_service\" {\n\t// \tname - \ = \"loki-k8s-monitoring\"\n\t// \tnamespace = \"k8s-monitoring\"\n\t// }\n\t// - // Loki\n\t// loki.write \"logs_service\" {\n\t// \tendpoint {\n\t// \t\turl = - nonsensitive(remote.kubernetes.secret.logs_service.data[\"host\"]) + \"/loki/api/v1/push\"\n\t// - \t\ttenant_id = nonsensitive(remote.kubernetes.secret.logs_service.data[\"tenantId\"])\n\n\t// - \t\tbasic_auth {\n\t// \t\t\tusername = nonsensitive(remote.kubernetes.secret.logs_service.data[\"username\"])\n\t// - \t\t\tpassword = remote.kubernetes.secret.logs_service.data[\"password\"]\n\t// - \t\t}\n\t// \t}\n\t// }\n}\n" + \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected + metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\tcomment + \ = \"job label (default: integrations/kubernetes/mysql)\"\n\t\toptional = true\n\t}\n\n\targument + \"namespace\" {\n\t\tcomment = \"kubernetes secret name (default: monitoring-system)\"\n\t\toptional + = true\n\t}\n\n\targument \"name\" {\n\t\tcomment = \"kubernetes secret name + (default: alloy-integrations-mysql)\"\n\t\toptional = true\n\t}\n\n\targument + \"keep_metrics\" {\n\t\toptional = true\n\t\tdefault = \"(up|instance:mysql_heartbeat_lag_seconds|instance:mysql_slave_lag_seconds|mysql_global_status_aborted_clients|mysql_global_status_aborted_connects|mysql_global_status_buffer_pool_pages|mysql_global_status_bytes_received|mysql_global_status_bytes_sent|mysql_global_status_commands_total|mysql_global_status_created_tmp_disk_tables|mysql_global_status_created_tmp_files|mysql_global_status_created_tmp_tables|mysql_global_status_handlers_total|mysql_global_status_innodb_log_waits|mysql_global_status_innodb_mem_adaptive_hash|mysql_global_status_innodb_mem_dictionary|mysql_global_status_innodb_num_open_files|mysql_global_status_innodb_page_size|mysql_global_status_max_used_connections|mysql_global_status_open_files|mysql_global_status_open_table_definitions|mysql_global_status_open_tables|mysql_global_status_opened_files|mysql_global_status_opened_table_definitions|mysql_global_status_opened_tables|mysql_global_status_qcache_free_memory|mysql_global_status_qcache_hits|mysql_global_status_qcache_inserts|mysql_global_status_qcache_lowmem_prunes|mysql_global_status_qcache_not_cached|mysql_global_status_qcache_queries_in_cache|mysql_global_status_queries|mysql_global_status_questions|mysql_global_status_select_full_join|mysql_global_status_select_full_range_join|mysql_global_status_select_range|mysql_global_status_select_range_check|mysql_global_status_select_scan|mysql_global_status_slow_queries|mysql_global_status_sort_merge_passes|mysql_global_status_sort_range|mysql_global_status_sort_rows|mysql_global_status_sort_scan|mysql_global_status_table_locks_immediate|mysql_global_status_table_locks_waited|mysql_global_status_table_open_cache_hits|mysql_global_status_table_open_cache_misses|mysql_global_status_table_open_cache_overflows|mysql_global_status_threads_cached|mysql_global_status_threads_connected|mysql_global_status_threads_created|mysql_global_status_threads_running|mysql_global_status_uptime|mysql_global_status_wsrep_local_recv_queue|mysql_global_status_wsrep_local_state|mysql_global_status_wsrep_ready|mysql_global_variables_innodb_additional_mem_pool_size|mysql_global_variables_innodb_buffer_pool_size|mysql_global_variables_innodb_log_buffer_size|mysql_global_variables_key_buffer_size|mysql_global_variables_max_connections|mysql_global_variables_open_files_limit|mysql_global_variables_query_cache_size|mysql_global_variables_table_definition_cache|mysql_global_variables_table_open_cache|mysql_global_variables_thread_cache_size|mysql_global_variables_tokudb_cache_size|mysql_global_variables_wsrep_desync|mysql_heartbeat_now_timestamp_seconds|mysql_heartbeat_stored_timestamp_seconds|mysql_info_schema_processlist_threads|mysql_slave_status_seconds_behind_master|mysql_slave_status_slave_io_running|mysql_slave_status_slave_sql_running|mysql_slave_status_sql_delay|mysql_up)\"\n\t}\n\n\targument + \"scrape_interval\" {\n\t\tcomment = \"How often to scrape metrics from the targets + (default: 60s)\"\n\t\toptional = true\n\t}\n\n\targument \"scrape_timeout\" {\n\t\tcomment + \ = \"How long before a scrape times out (default: 10s)\"\n\t\toptional = true\n\t}\n\n\tremote.kubernetes.secret + \"mysql\" {\n\t\tname = coalesce(argument.name.value, \"alloy-integrations-mysql\")\n\t\tnamespace + = coalesce(argument.namespace.value, \"monitoring-system\")\n\t}\n\n\t/***************************************************************\n\t* + Integrations Mysql\n\t****************************************************************/\n\tprometheus.exporter.mysql + \"integrations_mysqld_exporter\" {\n\t\tdata_source_name = nonsensitive(remote.kubernetes.secret.mysql.data[\"mysql-username\"]) + + \":\" + nonsensitive(remote.kubernetes.secret.mysql.data[\"mysql-password\"]) + + \"@(\" + nonsensitive(remote.kubernetes.secret.mysql.data[\"mysql-host\"]) + + \")/\"\n\t}\n\n\t/***************************************************************\n\t* + Discovery Relabelings (pre-scrape)\n\t****************************************************************/\n\tdiscovery.relabel + \"integrations_mysqld_exporter\" {\n\t\ttargets = prometheus.exporter.mysql.integrations_mysqld_exporter.targets\n\n\t\trule + {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = coalesce(argument.job_label.value, + \"integrations/kubernetes/mysql\")\n\t\t}\n\n\t\trule {\n\t\t\ttarget_label = + \"instance\"\n\t\t\treplacement = coalesce(nonsensitive(remote.kubernetes.secret.mysql.data[\"instance-name\"]), + constants.hostname)\n\t\t}\n\t}\n\n\t/***************************************************************\n\t* + Prometheus Scrape Integrations Targets\n\t****************************************************************/\n\tprometheus.scrape + \"integrations_mysqld_exporter\" {\n\t\ttargets = concat(\n\t\t\tdiscovery.relabel.integrations_mysqld_exporter.output,\n\t\t)\n\n\t\tenable_protobuf_negotiation + = true\n\t\tscrape_classic_histograms = true\n\n\t\tscrape_interval = coalesce(argument.scrape_interval.value, + \"60s\")\n\t\tscrape_timeout = coalesce(argument.scrape_timeout.value, \"10s\")\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\n\t\tforward_to = [prometheus.relabel.integrations_mysqld_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* + Prometheus Metric Relabelings (post-scrape)\n\t****************************************************************/\n\tprometheus.relabel + \"integrations_mysqld_exporter\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\t// + keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels + = [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction + \ = \"keep\"\n\t\t}\n\t}\n}\n" + redis.alloy: "/*\nModule Components: component_redis_exporter\n*/\n\ndeclare \"redis_exporter_metrics_scrape\" + {\n\n\t/*****************************************************************\n\t* + ARGUMENTS\n\t*****************************************************************/\n\targument + \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected + metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\tcomment + \ = \"job label (default: integrations/kubernetes/redis_exporter)\"\n\t\toptional + = true\n\t}\n\n\targument \"namespace\" {\n\t\tcomment = \"kubernetes secret + name (default: monitoring-system)\"\n\t\toptional = true\n\t}\n\n\targument \"name\" + {\n\t\tcomment = \"kubernetes secret name (default: alloy-integrations-redis)\"\n\t\toptional + = true\n\t}\n\n\targument \"keep_metrics\" {\n\t\toptional = true\n\t\tdefault + \ = \"(up|redis_blocked_clients|redis_cluster_slots_fail|redis_cluster_slots_pfail|redis_cluster_state|redis_commands_duration_seconds_total|redis_commands_total|redis_connected_clients|redis_connected_slaves|redis_db_keys|redis_db_keys_expiring|redis_evicted_keys_total|redis_keyspace_hits_total|redis_keyspace_misses_total|redis_master_last_io_seconds_ago|redis_memory_fragmentation_ratio|redis_memory_max_bytes|redis_memory_used_bytes|redis_memory_used_rss_bytes|redis_total_system_memory_bytes|redis_up)\"\n\t}\n\n\targument + \"scrape_interval\" {\n\t\tcomment = \"How often to scrape metrics from the targets + (default: 60s)\"\n\t\toptional = true\n\t\tdefault = \"60s\"\n\t}\n\n\targument + \"scrape_timeout\" {\n\t\tcomment = \"How long before a scrape times out (default: + 10s)\"\n\t\toptional = true\n\t\tdefault = \"10s\"\n\t}\n\n\tremote.kubernetes.secret + \"redis\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname + \ = coalesce(argument.name.value, \"alloy-integrations-redis\")\n\t}\n\n\t/***************************************************************\n\t* + Integrations Redis\n\t****************************************************************/\n\tprometheus.exporter.redis + \"integrations_redis_exporter\" {\n\t\tredis_addr = nonsensitive(remote.kubernetes.secret.redis.data[\"instance-address\"])\n\t\tredis_password + = nonsensitive(remote.kubernetes.secret.redis.data[\"instance-password\"])\n\t}\n\n\t/***************************************************************\n\t* + Discovery Relabelings (pre-scrape)\n\t****************************************************************/\n\tdiscovery.relabel + \"integrations_redis_exporter\" {\n\t\ttargets = prometheus.exporter.redis.integrations_redis_exporter.targets\n\n\t\trule + {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = coalesce(argument.job_label.value, + \"integrations/kubernetes/redis_exporter\")\n\t\t}\n\n\t\trule {\n\t\t\ttarget_label + = \"instance\"\n\t\t\treplacement = coalesce(nonsensitive(remote.kubernetes.secret.redis.data[\"instance-name\"]), + constants.hostname)\n\t\t}\n\t}\n\n\t/***************************************************************\n\t* + Prometheus Scrape Integrations Targets\n\t****************************************************************/\n\tprometheus.scrape + \"integrations_redis_exporter\" {\n\t\ttargets = concat(\n\t\t\tdiscovery.relabel.integrations_redis_exporter.output,\n\t\t)\n\n\t\tenable_protobuf_negotiation + = true\n\t\tscrape_classic_histograms = true\n\n\t\tscrape_interval = argument.scrape_interval.value\n\t\tscrape_timeout + \ = argument.scrape_timeout.value\n\n\t\tclustering {\n\t\t\tenabled = true\n\t\t}\n\n\t\tforward_to + = [prometheus.relabel.integrations_redis_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* + Prometheus Metric Relabelings (post-scrape)\n\t****************************************************************/\n\tprometheus.relabel + \"integrations_redis_exporter\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\t// + keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels + = [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction + \ = \"keep\"\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 + name: alloy-integrations namespace: monitoring-system --- apiVersion: v1 @@ -552,6 +612,17 @@ data: = {\n\t\t\t\t\tstream = \"\",\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// drop the temporary container runtime label as it is no longer needed\n\t\tstage.label_drop {\n\t\t\tvalues = [\"tmp_container_runtime\"]\n\t\t}\n\t}\n}\n" + k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare + \"kubernetes_cluster_events\" {\n\n\t/*****************************************************************\n\t* + ARGUMENTS\n\t*****************************************************************/\n\targument + \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected + logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional + = true\n\t}\n\n\targument \"cluster\" {\n\t\toptional = true\n\t}\n\n\tloki.source.kubernetes_events + \"cluster_events\" {\n\t\tjob_name = coalesce(argument.job_label.value, \"integrations/kubernetes/eventhandler\")\n\t\tlog_format + = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process + \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster + = coalesce(argument.cluster.value, \"k3d\"),\n\t\t\t}\n\t\t}\n\t\tforward_to = + argument.forward_to.value\n\t}\n}\n" keep-labels.alloy: "/*\nModule Components: keep_labels\nDescription: Pre-defined set of labels to keep, this stage should always be in-place as the previous relabeing\n \ stages make every pod label and annotation a label in the pipeline, @@ -575,42 +646,11 @@ data: \"receiver\" {\n\t\tvalue = loki.process.keep_labels.receiver\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h namespace: monitoring-system --- apiVersion: v1 data: - integrations-scrape.alloy: "/*\nModule Components: integrations_scrape\nDescription: - Integrations Module Components Scrape\n\nNote: Every argument except for \"forward_to\" - is optional, and does have a defined default value. However, the values for these\n - \ arguments are not defined using the default = \" ... \" argument syntax, - but rather using the coalesce(argument.value, \" ... \").\n This is because - if the argument passed in from another consuming module is set to null, the default - = \" ... \" syntax will\n does not override the value passed in, where coalesce() - will return the first non-null value.\n*/\n\ndeclare \"integrations_scrape\" {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"name\" {\n\t\tcomment = - \"Name of the integrations config\"\n\t\toptional = true\n\t}\n\n\targument \"namespace\" - {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional = true\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\tremote.kubernetes.configmap - \"integrations\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname - \ = coalesce(argument.name.value, \"alloy-integrations\")\n\t}\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\timport.string - \"memcached\" {\n\t\tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t}\n\n\tmemcached.component_memcached - \"instance\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tnamespace = - argument.namespace.value\n\t\tname = remote.kubernetes.configmap.integrations.data[\"MEMCACHED_K8S_SECRET_NAME\"]\n\t}\n\n\t// - /*****************************************************************\n\t// * Redis - Integrations\n\t// *****************************************************************/\n\t// - import.string \"redis\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"redis.alloy\"]\n\t// - }\n\n\t// redis.component_redis_exporter \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"REDIS_K8S_SECRET_NAME\"]\n\t// - }\n\n\t// /*****************************************************************\n\t// - * Mysql Integrations\n\t// *****************************************************************/\n\t// - import.string \"mysql\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"mysql.alloy\"]\n\t// - }\n\n\t// mysql.component_mysql \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"MYSQL_K8S_SECRET_NAME\"]\n\t// - }\n}\n" podmonitors-scrape.alloy: "/*\nModule Components: podmonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.podmonitors\n*/\n\ndeclare \"podmonitors_scrape\" {\n\n\t/*****************************************************************\n\t* @@ -643,7 +683,7 @@ data: {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 namespace: monitoring-system --- apiVersion: v1 @@ -1137,6 +1177,29 @@ metadata: type: Opaque --- apiVersion: v1 +data: + instance-name: cHJpbWFyeQ== + mysql-host: bXlzcWwubXlzcWwtc3lzdGVtLnN2Yy5jbHVzdGVyLmxvY2Fs + mysql-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= + mysql-username: bGd0bXA= +kind: Secret +metadata: + name: alloy-integrations-mysql + namespace: monitoring-system +type: Opaque +--- +apiVersion: v1 +data: + instance-address: cmVkaXMtbWFzdGVyLnJlZGlzLXN5c3RlbS5zdmMuY2x1c3Rlci5sb2NhbDo2Mzc5 + instance-name: cHJpbWFyeQ== + instance-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= +kind: Secret +metadata: + name: alloy-integrations-redis + namespace: monitoring-system +type: Opaque +--- +apiVersion: v1 data: MIMIR_S3_SECRET_ACCESS_KEY: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= kind: Secret @@ -1965,7 +2028,6 @@ spec: annotations: kubectl.kubernetes.io/default-container: alloy logs.agent.grafana.com/scrape: "true" - logs.agent.grafana.com/scrub-level: debug profiles.grafana.com/cpu.port_name: http-metrics profiles.grafana.com/cpu.scrape: "false" profiles.grafana.com/goroutine.port_name: http-metrics @@ -2029,8 +2091,6 @@ spec: name: config - mountPath: /etc/alloy/modules/kubernetes/metrics name: modules-kubernetes-metrics - - mountPath: /etc/alloy/modules/kubernetes/integrations - name: modules-kubernetes-integrations - mountPath: /etc/alloy/modules/kubernetes/logs name: modules-kubernetes-logs - mountPath: /etc/alloy/modules/kubernetes/traces @@ -2043,16 +2103,13 @@ spec: serviceAccountName: alloy volumes: - configMap: - name: alloy-config-8t9d8htff7 + name: alloy-config-72927d7k99 name: config - configMap: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 - name: modules-kubernetes-integrations - - configMap: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h name: modules-kubernetes-logs - configMap: name: alloy-modules-kubernetes-traces-8mgm8th9m5 diff --git a/kubernetes/read-write-mode/logs/kustomization.yaml b/kubernetes/read-write-mode/logs/kustomization.yaml index ee568861..9cefdc8b 100644 --- a/kubernetes/read-write-mode/logs/kustomization.yaml +++ b/kubernetes/read-write-mode/logs/kustomization.yaml @@ -9,6 +9,7 @@ kind: Kustomization resources: - ../../common/alloy +- ../../common/alloy/configs/kubernetes/integrations - loki # optional diff --git a/kubernetes/read-write-mode/logs/logs.alloy b/kubernetes/read-write-mode/logs/logs.alloy index 1915e1ac..514a59e7 100644 --- a/kubernetes/read-write-mode/logs/logs.alloy +++ b/kubernetes/read-write-mode/logs/logs.alloy @@ -41,14 +41,54 @@ import.file "metrics" { filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/kubernetes/metrics" } -metrics.integrations_scrape "kubernetes" { +metrics.podmonitors_scrape "kubernetes" { forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] } -metrics.podmonitors_scrape "kubernetes" { +metrics.servicemonitors_scrape "kubernetes" { forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] } -metrics.servicemonitors_scrape "kubernetes" { +/***************************************************************** +* Alloy Integrations +*****************************************************************/ +remote.kubernetes.configmap "integrations" { + namespace = "monitoring-system" + name = "alloy-integrations" +} + +// Memcached Integrations +import.string "memcached" { + content = remote.kubernetes.configmap.integrations.data["memcached.alloy"] +} + +memcached.memcached_metrics_scrape "instance" { forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] + + namespace = "monitoring-system" + name = remote.kubernetes.configmap.integrations.data["MEMCACHED_K8S_SECRET_NAME"] } + +// // Redis Integrations +// import.string "redis" { +// content = remote.kubernetes.configmap.integrations.data["redis.alloy"] +// } + +// redis.redis_exporter_metrics_scrape "instance" { +// forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] + +// namespace = "monitoring-system" +// name = remote.kubernetes.configmap.integrations.data["REDIS_K8S_SECRET_NAME"] +// } + +// // Mysql Integrations +// import.string "mysql" { +// content = remote.kubernetes.configmap.integrations.data["mysql.alloy"] +// } + +// mysql.mysql_metrics_scrape "instance" { +// forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] + +// namespace = "monitoring-system" +// name = remote.kubernetes.configmap.integrations.data["MYSQL_K8S_SECRET_NAME"] +// } diff --git a/kubernetes/read-write-mode/metrics/k8s-all-in-one.yaml b/kubernetes/read-write-mode/metrics/k8s-all-in-one.yaml index 07554e5d..6ab48b9a 100644 --- a/kubernetes/read-write-mode/metrics/k8s-all-in-one.yaml +++ b/kubernetes/read-write-mode/metrics/k8s-all-in-one.yaml @@ -154,86 +154,15 @@ data: = coalesce(env(\"SELF_HOSTED_METRICS_ENDPOINT_URL\"), \"http://nginx.gateway.svc:8080/api/v1/push\")\n}\n\n/********************************************\n * Metrics\n ********************************************/\nimport.file \"metrics\" {\n\tfilename = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") - + \"/kubernetes/metrics\"\n}\n\nmetrics.integrations_scrape \"kubernetes\" {\n\tforward_to - = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.podmonitors_scrape - \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape + + \"/kubernetes/metrics\"\n}\n\nmetrics.podmonitors_scrape \"kubernetes\" {\n\tforward_to + = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\nmetrics.servicemonitors_scrape \"kubernetes\" {\n\tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n}\n\n// metrics.annotations_scrape \"kubernetes\" {\n// \tlabel_prefix = \"metrics.grafana.com\"\n// \tforward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver]\n// \tscrape_interval = \"15s\"\n// }\n" kind: ConfigMap metadata: - name: alloy-config-m6chdfm49m - namespace: monitoring-system ---- -apiVersion: v1 -data: - MEMCACHED_K8S_SECRET_NAME: alloy-integrations-memcached - memcached.alloy: "/*\nModule Components: component_memcached\n*/\n\ndeclare \"component_memcached\" - {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\tcomment - \ = \"job label (default: integrations/kubernetes/memcached)\"\n\t\toptional = - true\n\t}\n\n\targument \"namespace\" {\n\t\tcomment = \"kubernetes secret name - (default: monitoring-system)\"\n\t\toptional = true\n\t}\n\n\targument \"name\" - {\n\t\tcomment = \"kubernetes secret name (default: alloy-integrations-redis)\"\n\t\toptional - = true\n\t}\n\n\targument \"keep_metrics\" {\n\t\toptional = true\n\t\tdefault - \ = \"(up|memcached_commands_total|memcached_connections_total|memcached_current_bytes|memcached_current_connections|memcached_current_items|memcached_items_evicted_total|memcached_items_total|memcached_max_connections|memcached_read_bytes_total|memcached_up|memcached_uptime_seconds|memcached_version|memcached_written_bytes_total)\"\n\t}\n\n\targument - \"scrape_interval\" {\n\t\tcomment = \"How often to scrape metrics from the targets - (default: 60s)\"\n\t\toptional = true\n\t}\n\n\targument \"scrape_timeout\" {\n\t\tcomment - \ = \"How long before a scrape times out (default: 10s)\"\n\t\toptional = true\n\t}\n\n\tremote.kubernetes.secret - \"memcached\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname - \ = coalesce(argument.name.value, \"alloy-integrations-memcached\")\n\t}\n\n\t/***************************************************************\n\t* - Integrations Memcached\n\t****************************************************************/\n\t// - https://grafana.com/docs/alloy/latest/reference/components/prometheus.exporter.memcached/\n\tprometheus.exporter.memcached - \"integrations_memcached_exporter\" {\n\t\taddress = nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-address\"])\n\t\ttimeout - = nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-timeout\"])\n\t}\n\n\t/***************************************************************\n\t* - Discovery Relabelings (pre-scrape)\n\t****************************************************************/\n\tdiscovery.relabel - \"integrations_memcached_exporter\" {\n\t\ttargets = prometheus.exporter.memcached.integrations_memcached_exporter.targets\n\n\t\trule - {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = coalesce(argument.job_label.value, - \"integrations/kubernetes/memcached\")\n\t\t}\n\n\t\trule {\n\t\t\ttarget_label - = \"instance\"\n\t\t\treplacement = coalesce(nonsensitive(remote.kubernetes.secret.memcached.data[\"instance-name\"]), - constants.hostname)\n\t\t}\n\t}\n\n\t/***************************************************************\n\t* - Prometheus Scrape Integrations Targets\n\t****************************************************************/\n\tprometheus.scrape - \"integrations_memcached_exporter\" {\n\t\ttargets = concat(\n\t\t\tdiscovery.relabel.integrations_memcached_exporter.output,\n\t\t)\n\n\t\tenable_protobuf_negotiation - = true\n\t\tscrape_classic_histograms = true\n\n\t\tscrape_interval = coalesce(argument.scrape_interval.value, - \"60s\")\n\t\tscrape_timeout = coalesce(argument.scrape_timeout.value, \"10s\")\n\n\t\tclustering - {\n\t\t\tenabled = true\n\t\t}\n\n\t\tforward_to = [prometheus.relabel.integrations_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* - Prometheus Metric Relabelings (post-scrape)\n\t****************************************************************/\n\tprometheus.relabel - \"integrations_memcached_exporter\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\t// - keep only metrics that match the keep_metrics regex\n\t\trule {\n\t\t\tsource_labels - = [\"__name__\"]\n\t\t\tregex = argument.keep_metrics.value\n\t\t\taction - \ = \"keep\"\n\t\t}\n\t}\n}\n" -kind: ConfigMap -metadata: - name: alloy-integrations - namespace: monitoring-system ---- -apiVersion: v1 -data: - k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare - \"component_cluster_events\" {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected - logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/eventhandler\"\n\t}\n\n\targument - \"cluster\" {\n\t\toptional = true\n\t\tdefault = \"k3d\"\n\t}\n\n\tloki.source.kubernetes_events - \"cluster_events\" {\n\t\tjob_name = argument.job_label.value\n\t\tlog_format - = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process - \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster - = argument.cluster.value,\n\t\t\t}\n\t\t}\n\t\tforward_to = argument.forward_to.value\n\t}\n\n\t// - // Logs Service\n\t// remote.kubernetes.secret \"logs_service\" {\n\t// \tname - \ = \"loki-k8s-monitoring\"\n\t// \tnamespace = \"k8s-monitoring\"\n\t// }\n\t// - // Loki\n\t// loki.write \"logs_service\" {\n\t// \tendpoint {\n\t// \t\turl = - nonsensitive(remote.kubernetes.secret.logs_service.data[\"host\"]) + \"/loki/api/v1/push\"\n\t// - \t\ttenant_id = nonsensitive(remote.kubernetes.secret.logs_service.data[\"tenantId\"])\n\n\t// - \t\tbasic_auth {\n\t// \t\t\tusername = nonsensitive(remote.kubernetes.secret.logs_service.data[\"username\"])\n\t// - \t\t\tpassword = remote.kubernetes.secret.logs_service.data[\"password\"]\n\t// - \t\t}\n\t// \t}\n\t// }\n}\n" -kind: ConfigMap -metadata: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 + name: alloy-config-55dd47md5f namespace: monitoring-system --- apiVersion: v1 @@ -330,6 +259,17 @@ data: = {\n\t\t\t\t\tstream = \"\",\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// drop the temporary container runtime label as it is no longer needed\n\t\tstage.label_drop {\n\t\t\tvalues = [\"tmp_container_runtime\"]\n\t\t}\n\t}\n}\n" + k8s-events.alloy: "/*\nModule Components: component_cluster_events\n*/\n\ndeclare + \"kubernetes_cluster_events\" {\n\n\t/*****************************************************************\n\t* + ARGUMENTS\n\t*****************************************************************/\n\targument + \"forward_to\" {\n\t\tcomment = \"Must be a list(LogsReceiver) where collected + logs should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional + = true\n\t}\n\n\targument \"cluster\" {\n\t\toptional = true\n\t}\n\n\tloki.source.kubernetes_events + \"cluster_events\" {\n\t\tjob_name = coalesce(argument.job_label.value, \"integrations/kubernetes/eventhandler\")\n\t\tlog_format + = \"logfmt\"\n\t\tforward_to = [loki.process.logs_service.receiver]\n\t}\n\n\tloki.process + \"logs_service\" {\n\t\tstage.static_labels {\n\t\t\tvalues = {\n\t\t\t\tcluster + = coalesce(argument.cluster.value, \"k3d\"),\n\t\t\t}\n\t\t}\n\t\tforward_to = + argument.forward_to.value\n\t}\n}\n" keep-labels.alloy: "/*\nModule Components: keep_labels\nDescription: Pre-defined set of labels to keep, this stage should always be in-place as the previous relabeing\n \ stages make every pod label and annotation a label in the pipeline, @@ -353,42 +293,11 @@ data: \"receiver\" {\n\t\tvalue = loki.process.keep_labels.receiver\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h namespace: monitoring-system --- apiVersion: v1 data: - integrations-scrape.alloy: "/*\nModule Components: integrations_scrape\nDescription: - Integrations Module Components Scrape\n\nNote: Every argument except for \"forward_to\" - is optional, and does have a defined default value. However, the values for these\n - \ arguments are not defined using the default = \" ... \" argument syntax, - but rather using the coalesce(argument.value, \" ... \").\n This is because - if the argument passed in from another consuming module is set to null, the default - = \" ... \" syntax will\n does not override the value passed in, where coalesce() - will return the first non-null value.\n*/\n\ndeclare \"integrations_scrape\" {\n\n\t/*****************************************************************\n\t* - ARGUMENTS\n\t*****************************************************************/\n\targument - \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"name\" {\n\t\tcomment = - \"Name of the integrations config\"\n\t\toptional = true\n\t}\n\n\targument \"namespace\" - {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional = true\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\tremote.kubernetes.configmap - \"integrations\" {\n\t\tnamespace = coalesce(argument.namespace.value, \"monitoring-system\")\n\t\tname - \ = coalesce(argument.name.value, \"alloy-integrations\")\n\t}\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\timport.string - \"memcached\" {\n\t\tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t}\n\n\tmemcached.component_memcached - \"instance\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tnamespace = - argument.namespace.value\n\t\tname = remote.kubernetes.configmap.integrations.data[\"MEMCACHED_K8S_SECRET_NAME\"]\n\t}\n\n\t// - /*****************************************************************\n\t// * Redis - Integrations\n\t// *****************************************************************/\n\t// - import.string \"redis\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"redis.alloy\"]\n\t// - }\n\n\t// redis.component_redis_exporter \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"REDIS_K8S_SECRET_NAME\"]\n\t// - }\n\n\t// /*****************************************************************\n\t// - * Mysql Integrations\n\t// *****************************************************************/\n\t// - import.string \"mysql\" {\n\t// \tcontent = remote.kubernetes.configmap.integrations.data[\"mysql.alloy\"]\n\t// - }\n\n\t// mysql.component_mysql \"instance\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tnamespace = argument.namespace.value\n\t// \tname = remote.kubernetes.configmap.integrations.data[\"MYSQL_K8S_SECRET_NAME\"]\n\t// - }\n}\n" podmonitors-scrape.alloy: "/*\nModule Components: podmonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.podmonitors\n*/\n\ndeclare \"podmonitors_scrape\" {\n\n\t/*****************************************************************\n\t* @@ -421,7 +330,7 @@ data: {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 namespace: monitoring-system --- apiVersion: v1 @@ -896,17 +805,6 @@ metadata: type: Opaque --- apiVersion: v1 -data: - instance-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= - instance-name: cHJpbWFyeQ== - instance-timeout: NXM= -kind: Secret -metadata: - name: alloy-integrations-memcached - namespace: monitoring-system -type: Opaque ---- -apiVersion: v1 data: MIMIR_S3_SECRET_ACCESS_KEY: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= kind: Secret @@ -1339,7 +1237,6 @@ spec: annotations: kubectl.kubernetes.io/default-container: alloy logs.agent.grafana.com/scrape: "true" - logs.agent.grafana.com/scrub-level: debug profiles.grafana.com/cpu.port_name: http-metrics profiles.grafana.com/cpu.scrape: "false" profiles.grafana.com/goroutine.port_name: http-metrics @@ -1403,8 +1300,6 @@ spec: name: config - mountPath: /etc/alloy/modules/kubernetes/metrics name: modules-kubernetes-metrics - - mountPath: /etc/alloy/modules/kubernetes/integrations - name: modules-kubernetes-integrations - mountPath: /etc/alloy/modules/kubernetes/logs name: modules-kubernetes-logs - mountPath: /etc/alloy/modules/kubernetes/traces @@ -1417,16 +1312,13 @@ spec: serviceAccountName: alloy volumes: - configMap: - name: alloy-config-m6chdfm49m + name: alloy-config-55dd47md5f name: config - configMap: - name: alloy-modules-kubernetes-metrics-5g24522dhc + name: alloy-modules-kubernetes-metrics-44gc54b647 name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-mb46d6kmf6 - name: modules-kubernetes-integrations - - configMap: - name: alloy-modules-kubernetes-logs-d7c756mt2f + name: alloy-modules-kubernetes-logs-gd277tmt9h name: modules-kubernetes-logs - configMap: name: alloy-modules-kubernetes-traces-8mgm8th9m5 diff --git a/kubernetes/read-write-mode/metrics/metrics.alloy b/kubernetes/read-write-mode/metrics/metrics.alloy index 66926d75..606728c9 100644 --- a/kubernetes/read-write-mode/metrics/metrics.alloy +++ b/kubernetes/read-write-mode/metrics/metrics.alloy @@ -24,10 +24,6 @@ import.file "metrics" { filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/kubernetes/metrics" } -metrics.integrations_scrape "kubernetes" { - forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] -} - metrics.podmonitors_scrape "kubernetes" { forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] }