From 622a0d36120eb54394d10c572594837ae223d543 Mon Sep 17 00:00:00 2001 From: Weifeng Wang Date: Mon, 22 Apr 2024 11:51:21 +0800 Subject: [PATCH] Update alloy-integrations Signed-off-by: Weifeng Wang --- .../kubernetes/integrations/k8s-events.alloy | 56 ++ .../kubernetes/integrations/memcached.alloy | 33 +- .../kubernetes/integrations/mysql.alloy | 107 +++ .../kubernetes/integrations/redis.alloy | 110 +++ .../kubernetes/logs/annotations-scrape.alloy | 251 ++++++ .../kubernetes/logs/keep-labels.alloy | 61 ++ .../metrics/integrations-scrape.alloy | 56 +- .../metrics/podmonitors-scrape.alloy | 15 + .../metrics/servicemonitors-scrape.alloy | 15 + .../profiles/annotations-scrape.alloy | 812 ++++++++++++++++++ .../traces/process-and-transform.alloy | 260 ++++++ .../common/alloy/configs/kubernetes/README.md | 10 + .../kubernetes/integrations/memcached.alloy | 34 +- .../kubernetes/integrations/mysql.alloy | 24 +- .../kubernetes/integrations/redis.alloy | 24 +- .../metrics/integrations-scrape.alloy | 53 +- .../metrics/podmonitors-scrape.alloy | 15 + .../metrics/servicemonitors-scrape.alloy | 15 + kubernetes/common/alloy/kustomization.yaml | 66 +- .../alloy/manifests/k8s-all-in-one.yaml | 239 ++---- .../grafana/manifests/k8s-all-in-one.yaml | 2 +- kubernetes/common/grafana/values-k3d-k3s.yaml | 1 + .../logs/k8s-all-in-one.yaml | 239 ++---- .../metrics/k8s-all-in-one.yaml | 239 ++---- .../profiles/k8s-all-in-one.yaml | 239 ++---- .../traces/k8s-all-in-one.yaml | 239 ++---- .../traces/kustomization.yaml | 2 +- .../traces/{configs => }/traces.alloy | 0 .../all-in-one/{configs => }/all-in-one.alloy | 0 .../all-in-one/k8s-all-in-one.yaml | 239 ++---- .../all-in-one/kustomization.yaml | 2 +- .../monolithic-mode/logs/k8s-all-in-one.yaml | 248 +++--- kubernetes/monolithic-mode/logs/logs.alloy | 3 + .../metrics/k8s-all-in-one.yaml | 239 ++---- .../profiles/k8s-all-in-one.yaml | 239 ++---- .../traces/k8s-all-in-one.yaml | 239 ++---- .../monolithic-mode/traces/kustomization.yaml | 2 +- .../traces/{configs => }/traces.alloy | 0 .../read-write-mode/logs/k8s-all-in-one.yaml | 239 ++---- .../metrics/k8s-all-in-one.yaml | 239 ++---- 40 files changed, 2988 insertions(+), 1918 deletions(-) create mode 100644 alloy-modules/kubernetes/integrations/k8s-events.alloy create mode 100644 alloy-modules/kubernetes/integrations/mysql.alloy create mode 100644 alloy-modules/kubernetes/integrations/redis.alloy create mode 100644 alloy-modules/kubernetes/logs/annotations-scrape.alloy create mode 100644 alloy-modules/kubernetes/logs/keep-labels.alloy create mode 100644 alloy-modules/kubernetes/profiles/annotations-scrape.alloy create mode 100644 alloy-modules/kubernetes/traces/process-and-transform.alloy create mode 100644 kubernetes/common/alloy/configs/kubernetes/README.md rename kubernetes/microservices-mode/traces/{configs => }/traces.alloy (100%) rename kubernetes/monolithic-mode/all-in-one/{configs => }/all-in-one.alloy (100%) rename kubernetes/monolithic-mode/traces/{configs => }/traces.alloy (100%) diff --git a/alloy-modules/kubernetes/integrations/k8s-events.alloy b/alloy-modules/kubernetes/integrations/k8s-events.alloy new file mode 100644 index 00000000..48630bc4 --- /dev/null +++ b/alloy-modules/kubernetes/integrations/k8s-events.alloy @@ -0,0 +1,56 @@ +/* +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/memcached.alloy b/alloy-modules/kubernetes/integrations/memcached.alloy index 10a34965..b02b4681 100644 --- a/alloy-modules/kubernetes/integrations/memcached.alloy +++ b/alloy-modules/kubernetes/integrations/memcached.alloy @@ -11,20 +11,18 @@ declare "component_memcached" { comment = "Must be a list(MetricssReceiver) where collected metrics should be forwarded to" } - argument "memcached_address" { - comment = "address of the Memcached" + argument "job_label" { + comment = "job label (default: integrations/kubernetes/memcached)" optional = true - default = "memcached:11211" } - argument "memcached_timeout" { - comment = "timeout of the Memcached" + argument "namespace" { + comment = "kubernetes secret name (default: monitoring-system)" optional = true - default = "5s" } - argument "instance_name" { - comment = "instance of the Memcached" + argument "name" { + comment = "kubernetes secret name (default: alloy-integrations-redis)" optional = true } @@ -36,13 +34,16 @@ declare "component_memcached" { argument "scrape_interval" { comment = "How often to scrape metrics from the targets (default: 60s)" optional = true - default = "60s" } argument "scrape_timeout" { comment = "How long before a scrape times out (default: 10s)" optional = true - default = "10s" + } + + remote.kubernetes.secret "memcached" { + namespace = coalesce(argument.namespace.value, "monitoring-system") + name = coalesce(argument.name.value, "alloy-integrations-memcached") } /*************************************************************** @@ -50,8 +51,8 @@ declare "component_memcached" { ****************************************************************/ // https://grafana.com/docs/alloy/latest/reference/components/prometheus.exporter.memcached/ prometheus.exporter.memcached "integrations_memcached_exporter" { - address = argument.memcached_address.value - timeout = argument.memcached_timeout.value + address = nonsensitive(remote.kubernetes.secret.memcached.data["instance-address"]) + timeout = nonsensitive(remote.kubernetes.secret.memcached.data["instance-timeout"]) } /*************************************************************** @@ -62,12 +63,12 @@ declare "component_memcached" { rule { target_label = "job" - replacement = "integrations/kubernetes/memcached" + replacement = coalesce(argument.job_label.value, "integrations/kubernetes/memcached") } rule { target_label = "instance" - replacement = coalesce(argument.instance_name.value, constants.hostname) + replacement = coalesce(nonsensitive(remote.kubernetes.secret.memcached.data["instance-name"]), constants.hostname) } } @@ -82,8 +83,8 @@ declare "component_memcached" { enable_protobuf_negotiation = true scrape_classic_histograms = true - scrape_interval = argument.scrape_interval.value - scrape_timeout = argument.scrape_timeout.value + scrape_interval = coalesce(argument.scrape_interval.value, "60s") + scrape_timeout = coalesce(argument.scrape_timeout.value, "10s") clustering { enabled = true diff --git a/alloy-modules/kubernetes/integrations/mysql.alloy b/alloy-modules/kubernetes/integrations/mysql.alloy new file mode 100644 index 00000000..b7848c56 --- /dev/null +++ b/alloy-modules/kubernetes/integrations/mysql.alloy @@ -0,0 +1,107 @@ +/* +Module Components: component_mysql +*/ + +declare "component_mysql" { + + /***************************************************************** + * ARGUMENTS + *****************************************************************/ + argument "forward_to" { + comment = "Must be a list(MetricssReceiver) where collected metrics should be forwarded to" + } + + argument "job_label" { + comment = "job label (default: integrations/kubernetes/mysql)" + optional = true + } + + argument "namespace" { + comment = "kubernetes secret name (default: monitoring-system)" + optional = true + } + + argument "name" { + comment = "kubernetes secret name (default: alloy-integrations-mysql)" + optional = true + } + + argument "keep_metrics" { + optional = true + default = "(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)" + } + + argument "scrape_interval" { + comment = "How often to scrape metrics from the targets (default: 60s)" + optional = true + } + + argument "scrape_timeout" { + comment = "How long before a scrape times out (default: 10s)" + optional = true + } + + remote.kubernetes.secret "mysql" { + name = coalesce(argument.name.value, "alloy-integrations-mysql") + namespace = coalesce(argument.namespace.value, "monitoring-system") + } + + /*************************************************************** + * Integrations Mysql + ****************************************************************/ + prometheus.exporter.mysql "integrations_mysqld_exporter" { + data_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"]) + ")/" + } + + /*************************************************************** + * Discovery Relabelings (pre-scrape) + ****************************************************************/ + discovery.relabel "integrations_mysqld_exporter" { + targets = prometheus.exporter.mysql.integrations_mysqld_exporter.targets + + rule { + target_label = "job" + replacement = coalesce(argument.job_label.value, "integrations/kubernetes/mysql") + } + + rule { + target_label = "instance" + replacement = coalesce(nonsensitive(remote.kubernetes.secret.mysql.data["instance-name"]), constants.hostname) + } + } + + /*************************************************************** + * Prometheus Scrape Integrations Targets + ****************************************************************/ + prometheus.scrape "integrations_mysqld_exporter" { + targets = concat( + discovery.relabel.integrations_mysqld_exporter.output, + ) + + enable_protobuf_negotiation = true + scrape_classic_histograms = true + + scrape_interval = coalesce(argument.scrape_interval.value, "60s") + scrape_timeout = coalesce(argument.scrape_timeout.value, "10s") + + clustering { + enabled = true + } + + forward_to = [prometheus.relabel.integrations_mysqld_exporter.receiver] + } + + /*************************************************************** + * Prometheus Metric Relabelings (post-scrape) + ****************************************************************/ + prometheus.relabel "integrations_mysqld_exporter" { + forward_to = argument.forward_to.value + + // keep only metrics that match the keep_metrics regex + rule { + source_labels = ["__name__"] + regex = argument.keep_metrics.value + action = "keep" + } + } +} diff --git a/alloy-modules/kubernetes/integrations/redis.alloy b/alloy-modules/kubernetes/integrations/redis.alloy new file mode 100644 index 00000000..e3474652 --- /dev/null +++ b/alloy-modules/kubernetes/integrations/redis.alloy @@ -0,0 +1,110 @@ +/* +Module Components: component_redis_exporter +*/ + +declare "component_redis_exporter" { + + /***************************************************************** + * ARGUMENTS + *****************************************************************/ + argument "forward_to" { + comment = "Must be a list(MetricssReceiver) where collected metrics should be forwarded to" + } + + argument "job_label" { + comment = "job label (default: integrations/kubernetes/redis_exporter)" + optional = true + } + + argument "namespace" { + comment = "kubernetes secret name (default: monitoring-system)" + optional = true + } + + argument "name" { + comment = "kubernetes secret name (default: alloy-integrations-redis)" + optional = true + } + + argument "keep_metrics" { + optional = true + default = "(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)" + } + + argument "scrape_interval" { + comment = "How often to scrape metrics from the targets (default: 60s)" + optional = true + default = "60s" + } + + argument "scrape_timeout" { + comment = "How long before a scrape times out (default: 10s)" + optional = true + default = "10s" + } + + remote.kubernetes.secret "redis" { + namespace = coalesce(argument.namespace.value, "monitoring-system") + name = coalesce(argument.name.value, "alloy-integrations-redis") + } + + /*************************************************************** + * Integrations Redis + ****************************************************************/ + prometheus.exporter.redis "integrations_redis_exporter" { + redis_addr = nonsensitive(remote.kubernetes.secret.redis.data["instance-address"]) + redis_password = nonsensitive(remote.kubernetes.secret.redis.data["instance-password"]) + } + + /*************************************************************** + * Discovery Relabelings (pre-scrape) + ****************************************************************/ + discovery.relabel "integrations_redis_exporter" { + targets = prometheus.exporter.redis.integrations_redis_exporter.targets + + rule { + target_label = "job" + replacement = coalesce(argument.job_label.value, "integrations/kubernetes/redis_exporter") + } + + rule { + target_label = "instance" + replacement = coalesce(nonsensitive(remote.kubernetes.secret.redis.data["instance-name"]), constants.hostname) + } + } + + /*************************************************************** + * Prometheus Scrape Integrations Targets + ****************************************************************/ + prometheus.scrape "integrations_redis_exporter" { + targets = concat( + discovery.relabel.integrations_redis_exporter.output, + ) + + enable_protobuf_negotiation = true + scrape_classic_histograms = true + + scrape_interval = argument.scrape_interval.value + scrape_timeout = argument.scrape_timeout.value + + clustering { + enabled = true + } + + forward_to = [prometheus.relabel.integrations_redis_exporter.receiver] + } + + /*************************************************************** + * Prometheus Metric Relabelings (post-scrape) + ****************************************************************/ + prometheus.relabel "integrations_redis_exporter" { + forward_to = argument.forward_to.value + + // keep only metrics that match the keep_metrics regex + rule { + source_labels = ["__name__"] + regex = argument.keep_metrics.value + action = "keep" + } + } +} diff --git a/alloy-modules/kubernetes/logs/annotations-scrape.alloy b/alloy-modules/kubernetes/logs/annotations-scrape.alloy new file mode 100644 index 00000000..66bbceb1 --- /dev/null +++ b/alloy-modules/kubernetes/logs/annotations-scrape.alloy @@ -0,0 +1,251 @@ +/* +Module Components: annotations_scrape +Description: Scrapes targets for logs based on kubernetes Pod annotations + + Annotations: + logs.grafana.com/ingest: true + logs.grafana.com/tenant: "primary" +*/ + +declare "annotations_scrape" { + + /***************************************************************** + * ARGUMENTS + *****************************************************************/ + argument "forward_to" { + comment = "Must be a list(LogsReceiver) where collected logs should be forwarded to" + } + + argument "tenant" { + comment = "The tenant to filter logs to. This does not have to be the tenantId, this is the value to look for in the logs.agent.grafana.com/tenant annotation, and this can be a regex." + optional = true + default = ".*" + } + + // arguments for kubernetes discovery + argument "namespaces" { + comment = "The namespaces to look for targets in (default: [\"kube-system\"] is all namespaces)" + optional = true + } + + argument "annotation_prefix" { + comment = "The annotation_prefix to use (default: logs.grafana.com)" + default = "logs.grafana.com" + optional = true + } + + argument "__sd_annotation" { + optional = true + comment = "The logic is used to transform the annotation argument into a valid label name by removing unsupported characters." + default = replace(replace(replace(coalesce(argument.annotation_prefix.value, "logs.grafana.com"), ".", "_"), "/", "_"), "-", "_") + } + + // find all pods + discovery.kubernetes "annotation_logs" { + role = "pod" + + namespaces { + names = coalesce(argument.namespaces.value, []) + } + } + + // filter logs by kubernetes annotations + discovery.relabel "annotation_logs_filter" { + targets = discovery.kubernetes.annotation_logs.targets + + // allow pods to declare their logs to be ingested or not, the default is true + // i.e. logs.grafana.com/ingest: false + rule { + action = "keep" + source_labels = [ + "__meta_kubernetes_pod_annotation_" + argument.__sd_annotation.value + "_scrape", + ] + regex = "^(true|)$" + } + + // allow pods to declare what tenant their logs should be written to, the following annotation is supported: + // logs.grafana.com/tenant: "primary" + rule { + action = "keep" + source_labels = [ + "__meta_kubernetes_pod_annotation_" + argument.__sd_annotation.value + "_tenant", + ] + regex = "^(" + argument.tenant.value + ")$" + } + + // set the instance label as the name of the worker node the pod is on + rule { + action = "replace" + source_labels = ["__meta_kubernetes_pod_node_name"] + target_label = "instance" + } + + // set the namespace label + rule { + source_labels = ["__meta_kubernetes_namespace"] + target_label = "namespace" + } + + // set the pod label + rule { + source_labels = ["__meta_kubernetes_pod_name"] + target_label = "pod" + } + + // set the container label + rule { + source_labels = ["__meta_kubernetes_pod_container_name"] + target_label = "container" + } + + // set a workload label + rule { + source_labels = [ + "__meta_kubernetes_pod_controller_kind", + "__meta_kubernetes_pod_controller_name", + ] + separator = "/" + target_label = "workload" + } + // remove the hash from the ReplicaSet + rule { + source_labels = ["workload"] + regex = "(ReplicaSet/.+)-.+" + target_label = "workload" + } + + // set the app name if specified as metadata labels "app:" or "app.kubernetes.io/name:" or "k8s-app:" + rule { + action = "replace" + source_labels = [ + "__meta_kubernetes_pod_label_app_kubernetes_io_name", + "__meta_kubernetes_pod_label_k8s_app", + "__meta_kubernetes_pod_label_app", + ] + separator = ";" + regex = "^(?:;*)?([^;]+).*$" + replacement = "$1" + target_label = "app" + } + + // set the component if specified as metadata labels "component:" or "app.kubernetes.io/component:" or "k8s-component:" + rule { + action = "replace" + source_labels = [ + "__meta_kubernetes_pod_label_app_kubernetes_io_component", + "__meta_kubernetes_pod_label_k8s_component", + "__meta_kubernetes_pod_label_component", + ] + regex = "^(?:;*)?([^;]+).*$" + replacement = "$1" + target_label = "component" + } + + // set the version if specified as metadata labels "version:" or "app.kubernetes.io/version:" or "app_version:" + rule { + action = "replace" + source_labels = [ + "__meta_kubernetes_pod_label_app_kubernetes_io_version", + "__meta_kubernetes_pod_label_version", + "__meta_kubernetes_pod_label_app_version", + ] + regex = "^(?:;*)?([^;]+).*$" + replacement = "$1" + target_label = "version" + } + + // set a source label + rule { + action = "replace" + replacement = "kubernetes" + target_label = "source" + } + + // set the job label to be namespace / friendly pod name + rule { + action = "replace" + source_labels = [ + "workload", + "__meta_kubernetes_namespace", + ] + regex = ".+\\/(.+);(.+)" + replacement = "$2/$1" + target_label = "job" + } + + // make all labels on the pod available to the pipeline as labels, + // they are omitted before write via labelallow unless explicitly set + rule { + action = "labelmap" + regex = "__meta_kubernetes_pod_label_(.+)" + } + + // make all annotations on the pod available to the pipeline as labels, + // they are omitted before write via labelallow unless explicitly set + rule { + action = "labelmap" + regex = "__meta_kubernetes_pod_annotation_(.+)" + } + + // as a result of kubernetes service discovery for pods, all of the meta data information is exposed in labels + // __meta_kubernetes_pod_*, including __meta_kubernetes_pod_container_id which can be used to determine what + // the pods container runtime is, docker (docker://...) or containerd (containerd://...) this will inform us + // which parsing stage to use. However, any labels that begin with __* are not passed to loki.process + // (pipeline) stages. Use a relabeling stage to set a label that can be used a LogQL selector in the stage + // below so parsing can be automatically determined, then drop the label from the loki.process stage. + // set the container runtime as a label + rule { + action = "replace" + source_labels = ["__meta_kubernetes_pod_container_id"] + regex = "^(\\w+):\\/\\/.+$" + replacement = "$1" + target_label = "tmp_container_runtime" + } + } + + loki.source.kubernetes "lsd_kubernetes_logs" { + targets = discovery.relabel.annotation_logs_filter.output + forward_to = [loki.process.parse.receiver] + } + + // parse the log based on the container runtime + loki.process "parse" { + forward_to = argument.forward_to.value + /******************************************************************************* + * Container Runtime Parsing + ********************************************************************************/ + // if the label tmp_container_runtime from above is containerd parse using cri + stage.match { + selector = "{tmp_container_runtime=\"containerd\"}" + // the cri processing stage extracts the following k/v pairs: log, stream, time, flags + stage.cri { } + + // Set the extract flags and stream values as labels + stage.labels { + values = { + flags = "", + stream = "", + } + } + } + + // if the label tmp_container_runtime from above is docker parse using docker + stage.match { + selector = "{tmp_container_runtime=\"docker\"}" + // the docker processing stage extracts the following k/v pairs: log, stream, time + stage.docker { } + + // Set the extract stream value as a label + stage.labels { + values = { + stream = "", + } + } + } + + // drop the temporary container runtime label as it is no longer needed + stage.label_drop { + values = ["tmp_container_runtime"] + } + } +} diff --git a/alloy-modules/kubernetes/logs/keep-labels.alloy b/alloy-modules/kubernetes/logs/keep-labels.alloy new file mode 100644 index 00000000..e164474c --- /dev/null +++ b/alloy-modules/kubernetes/logs/keep-labels.alloy @@ -0,0 +1,61 @@ +/* +Module Components: keep_labels +Description: Pre-defined set of labels to keep, this stage should always be in-place as the previous relabeing + stages make every pod label and annotation a label in the pipeline, which we do not want created + in Loki as that would have extremely high-cardinality. +*/ + +declare "keep_labels" { + + /***************************************************************** + * ARGUMENTS + *****************************************************************/ + argument "forward_to" { + comment = "Must be a list(LogsReceiver) where collected logs should be forwarded to" + } + + argument "keep_labels" { + optional = true + comment = "List of labels to keep before the log message is written to Loki" + default = [ + "app", + "cluster", + "component", + "container", + "env", + "job", + "level", + "namespace", + "region", + "service", + "squad", + "team", + "workload", + ] + } + + /***************************************************************** + * LOKI PROCESS + *****************************************************************/ + loki.process "keep_labels" { + forward_to = argument.forward_to.value + + /* + As all of the pod labels and annotations we transformed into labels in the previous relabelings to make + them available to the pipeline processing we need to ensure they are not automatically created in Loki. + This would result in an extremely high number of labels and values severely impacting query performance. + Not every log has to contain these labels, but this list should reflect the set of labels that you want + to explicitly allow. + */ + stage.label_keep { + values = argument.keep_labels.value + } + } + + /***************************************************************** + * EXPORTS + *****************************************************************/ + export "receiver" { + value = loki.process.keep_labels.receiver + } +} diff --git a/alloy-modules/kubernetes/metrics/integrations-scrape.alloy b/alloy-modules/kubernetes/metrics/integrations-scrape.alloy index 33e589a3..542f1bb0 100644 --- a/alloy-modules/kubernetes/metrics/integrations-scrape.alloy +++ b/alloy-modules/kubernetes/metrics/integrations-scrape.alloy @@ -20,40 +20,60 @@ declare "integrations_scrape" { argument "name" { comment = "Name of the integrations config" optional = true - default = "alloy-integrations" } argument "namespace" { comment = "Namespace of the integrations config" optional = true - default = "default" } /***************************************************************** * Import Integrations Components *****************************************************************/ - // integrate components local files - import.file "integrate" { - filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/kubernetes/integrations" + remote.kubernetes.configmap "integrations" { + namespace = coalesce(argument.namespace.value, "monitoring-system") + name = coalesce(argument.name.value, "alloy-integrations") } - // // integrate components kubernetes configmap - // remote.kubernetes.configmap "integrations" { - // name = argument.name.value - // namespace = argument.namespace.value - // } - // import.string "integrate" { - // content = remote.kubernetes.configmap.integrations.data["memcached.alloy"] - // } - /***************************************************************** * Memcached Integrations *****************************************************************/ - integrate.component_memcached "primary" { + import.string "memcached" { + content = remote.kubernetes.configmap.integrations.data["memcached.alloy"] + } + + memcached.component_memcached "instance" { forward_to = argument.forward_to.value - instance_name = "primary" - memcached_address = "memcached.memcached-system.svc.cluster.local:11211" - memcached_timeout = "5s" + 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/alloy-modules/kubernetes/metrics/podmonitors-scrape.alloy b/alloy-modules/kubernetes/metrics/podmonitors-scrape.alloy index 2aff0001..540e2ff0 100644 --- a/alloy-modules/kubernetes/metrics/podmonitors-scrape.alloy +++ b/alloy-modules/kubernetes/metrics/podmonitors-scrape.alloy @@ -13,12 +13,27 @@ declare "podmonitors_scrape" { optional = false } + argument "scrape_interval" { + comment = "How often to scrape metrics from the targets (default: 60s)" + optional = true + } + + argument "scrape_timeout" { + comment = "How long before a scrape times out (default: 10s)" + optional = true + } + /***************************************************************** * Kubernetes Auto Scrape PodMonitors *****************************************************************/ prometheus.operator.podmonitors "scrape" { forward_to = argument.forward_to.value + scrape { + default_scrape_interval = coalesce(argument.scrape_interval.value, "60s") + default_scrape_timeout = coalesce(argument.scrape_timeout.value, "10s") + } + clustering { enabled = true } diff --git a/alloy-modules/kubernetes/metrics/servicemonitors-scrape.alloy b/alloy-modules/kubernetes/metrics/servicemonitors-scrape.alloy index 888206be..d221e276 100644 --- a/alloy-modules/kubernetes/metrics/servicemonitors-scrape.alloy +++ b/alloy-modules/kubernetes/metrics/servicemonitors-scrape.alloy @@ -13,12 +13,27 @@ declare "servicemonitors_scrape" { optional = false } + argument "scrape_interval" { + comment = "How often to scrape metrics from the targets (default: 60s)" + optional = true + } + + argument "scrape_timeout" { + comment = "How long before a scrape times out (default: 10s)" + optional = true + } + /***************************************************************** * Kubernetes Auto Scrape ServiceMonitors *****************************************************************/ prometheus.operator.servicemonitors "scrape" { forward_to = argument.forward_to.value + scrape { + default_scrape_interval = coalesce(argument.scrape_interval.value, "60s") + default_scrape_timeout = coalesce(argument.scrape_timeout.value, "10s") + } + clustering { enabled = true } diff --git a/alloy-modules/kubernetes/profiles/annotations-scrape.alloy b/alloy-modules/kubernetes/profiles/annotations-scrape.alloy new file mode 100644 index 00000000..33d82ce5 --- /dev/null +++ b/alloy-modules/kubernetes/profiles/annotations-scrape.alloy @@ -0,0 +1,812 @@ +/* +Module Components: annotations_scrape +Description: Scrapes targets for metrics based on kubernetes Pod annotations + +*/ + +declare "annotations_scrape" { + + /***************************************************************** + * ARGUMENTS + *****************************************************************/ + argument "forward_to" { + comment = "Must be a list(ProfilessReceiver) where collected logs should be forwarded to" + } + + discovery.kubernetes "pyroscope_kubernetes" { + role = "pod" + } + + // The default scrape config allows to define annotations based scraping. + // + // For example the following annotations: + // + // ``` + // profiles.grafana.com/memory.scrape: "true" + // profiles.grafana.com/memory.port: "8080" + // profiles.grafana.com/cpu.scrape: "true" + // profiles.grafana.com/cpu.port: "8080" + // profiles.grafana.com/goroutine.scrape: "true" + // profiles.grafana.com/goroutine.port: "8080" + // ``` + // + // will scrape the `memory`, `cpu` and `goroutine` profiles from the `8080` port of the pod. + // + // For more information see https://grafana.com/docs/phlare/latest/operators-guide/deploy-kubernetes/#optional-scrape-your-own-workloads-profiles + discovery.relabel "kubernetes_pods" { + targets = concat(discovery.kubernetes.pyroscope_kubernetes.targets) + + rule { + action = "drop" + source_labels = ["__meta_kubernetes_pod_phase"] + regex = "Pending|Succeeded|Failed|Completed" + } + + rule { + action = "labelmap" + regex = "__meta_kubernetes_pod_label_(.+)" + } + + rule { + action = "replace" + source_labels = ["__meta_kubernetes_namespace"] + target_label = "namespace" + } + + rule { + action = "replace" + source_labels = ["__meta_kubernetes_pod_name"] + target_label = "pod" + } + + rule { + action = "replace" + source_labels = ["__meta_kubernetes_pod_container_name"] + target_label = "container" + } + } + + discovery.relabel "kubernetes_pods_memory_default_name" { + targets = concat(discovery.relabel.kubernetes_pods.output) + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_scrape"] + action = "keep" + regex = "true" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_port_name"] + action = "keep" + regex = "" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_scheme"] + action = "replace" + regex = "(https?)" + target_label = "__scheme__" + replacement = "$1" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_path"] + action = "replace" + regex = "(.+)" + target_label = "__profile_path__" + replacement = "$1" + } + + rule { + source_labels = ["__address__", "__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_port"] + action = "replace" + regex = "(.+?)(?::\\d+)?;(\\d+)" + target_label = "__address__" + replacement = "$1:$2" + } + } + + discovery.relabel "kubernetes_pods_memory_custom_name" { + targets = concat(discovery.relabel.kubernetes_pods.output) + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_scrape"] + action = "keep" + regex = "true" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_port_name"] + action = "drop" + regex = "" + } + + rule { + source_labels = ["__meta_kubernetes_pod_container_port_name"] + target_label = "__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_port_name" + action = "keepequal" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_scheme"] + action = "replace" + regex = "(https?)" + target_label = "__scheme__" + replacement = "$1" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_path"] + action = "replace" + regex = "(.+)" + target_label = "__profile_path__" + replacement = "$1" + } + + rule { + source_labels = ["__address__", "__meta_kubernetes_pod_annotation_profiles_grafana_com_memory_port"] + action = "replace" + regex = "(.+?)(?::\\d+)?;(\\d+)" + target_label = "__address__" + replacement = "$1:$2" + } + } + + /***************************************************************** + * Kubernetes Pyroscope Scrape Memory + *****************************************************************/ + pyroscope.scrape "pyroscope_scrape_memory" { + clustering { + enabled = true + } + + targets = concat(discovery.relabel.kubernetes_pods_memory_default_name.output, discovery.relabel.kubernetes_pods_memory_custom_name.output) + forward_to = argument.forward_to.value + + profiling_config { + profile.memory { + enabled = true + } + + profile.process_cpu { + enabled = false + } + + profile.goroutine { + enabled = false + } + + profile.block { + enabled = false + } + + profile.mutex { + enabled = false + } + + profile.fgprof { + enabled = false + } + } + } + + discovery.relabel "kubernetes_pods_cpu_default_name" { + targets = concat(discovery.relabel.kubernetes_pods.output) + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_scrape"] + action = "keep" + regex = "true" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_port_name"] + action = "keep" + regex = "" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_scheme"] + action = "replace" + regex = "(https?)" + target_label = "__scheme__" + replacement = "$1" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_path"] + action = "replace" + regex = "(.+)" + target_label = "__profile_path__" + replacement = "$1" + } + + rule { + source_labels = ["__address__", "__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_port"] + action = "replace" + regex = "(.+?)(?::\\d+)?;(\\d+)" + target_label = "__address__" + replacement = "$1:$2" + } + } + + discovery.relabel "kubernetes_pods_cpu_custom_name" { + targets = concat(discovery.relabel.kubernetes_pods.output) + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_scrape"] + action = "keep" + regex = "true" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_port_name"] + action = "drop" + regex = "" + } + + rule { + source_labels = ["__meta_kubernetes_pod_container_port_name"] + target_label = "__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_port_name" + action = "keepequal" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_scheme"] + action = "replace" + regex = "(https?)" + target_label = "__scheme__" + replacement = "$1" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_path"] + action = "replace" + regex = "(.+)" + target_label = "__profile_path__" + replacement = "$1" + } + + rule { + source_labels = ["__address__", "__meta_kubernetes_pod_annotation_profiles_grafana_com_cpu_port"] + action = "replace" + regex = "(.+?)(?::\\d+)?;(\\d+)" + target_label = "__address__" + replacement = "$1:$2" + } + } + + /***************************************************************** + * Kubernetes Pyroscope Scrape CPU + *****************************************************************/ + pyroscope.scrape "pyroscope_scrape_cpu" { + clustering { + enabled = true + } + + targets = concat(discovery.relabel.kubernetes_pods_cpu_default_name.output, discovery.relabel.kubernetes_pods_cpu_custom_name.output) + forward_to = argument.forward_to.value + + profiling_config { + profile.memory { + enabled = false + } + + profile.process_cpu { + enabled = true + } + + profile.goroutine { + enabled = false + } + + profile.block { + enabled = false + } + + profile.mutex { + enabled = false + } + + profile.fgprof { + enabled = false + } + } + } + + discovery.relabel "kubernetes_pods_goroutine_default_name" { + targets = concat(discovery.relabel.kubernetes_pods.output) + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_scrape"] + action = "keep" + regex = "true" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_port_name"] + action = "keep" + regex = "" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_scheme"] + action = "replace" + regex = "(https?)" + target_label = "__scheme__" + replacement = "$1" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_path"] + action = "replace" + regex = "(.+)" + target_label = "__profile_path__" + replacement = "$1" + } + + rule { + source_labels = ["__address__", "__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_port"] + action = "replace" + regex = "(.+?)(?::\\d+)?;(\\d+)" + target_label = "__address__" + replacement = "$1:$2" + } + } + + discovery.relabel "kubernetes_pods_goroutine_custom_name" { + targets = concat(discovery.relabel.kubernetes_pods.output) + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_scrape"] + action = "keep" + regex = "true" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_port_name"] + action = "drop" + regex = "" + } + + rule { + source_labels = ["__meta_kubernetes_pod_container_port_name"] + target_label = "__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_port_name" + action = "keepequal" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_scheme"] + action = "replace" + regex = "(https?)" + target_label = "__scheme__" + replacement = "$1" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_path"] + action = "replace" + regex = "(.+)" + target_label = "__profile_path__" + replacement = "$1" + } + + rule { + source_labels = ["__address__", "__meta_kubernetes_pod_annotation_profiles_grafana_com_goroutine_port"] + action = "replace" + regex = "(.+?)(?::\\d+)?;(\\d+)" + target_label = "__address__" + replacement = "$1:$2" + } + } + + /***************************************************************** + * Kubernetes Pyroscope Scrape Goroutine + *****************************************************************/ + pyroscope.scrape "pyroscope_scrape_goroutine" { + clustering { + enabled = true + } + + targets = concat(discovery.relabel.kubernetes_pods_goroutine_default_name.output, discovery.relabel.kubernetes_pods_goroutine_custom_name.output) + forward_to = argument.forward_to.value + + profiling_config { + profile.memory { + enabled = false + } + + profile.process_cpu { + enabled = false + } + + profile.goroutine { + enabled = true + } + + profile.block { + enabled = false + } + + profile.mutex { + enabled = false + } + + profile.fgprof { + enabled = false + } + } + } + + discovery.relabel "kubernetes_pods_block_default_name" { + targets = concat(discovery.relabel.kubernetes_pods.output) + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_block_scrape"] + action = "keep" + regex = "true" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_block_port_name"] + action = "keep" + regex = "" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_block_scheme"] + action = "replace" + regex = "(https?)" + target_label = "__scheme__" + replacement = "$1" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_block_path"] + action = "replace" + regex = "(.+)" + target_label = "__profile_path__" + replacement = "$1" + } + + rule { + source_labels = ["__address__", "__meta_kubernetes_pod_annotation_profiles_grafana_com_block_port"] + action = "replace" + regex = "(.+?)(?::\\d+)?;(\\d+)" + target_label = "__address__" + replacement = "$1:$2" + } + } + + discovery.relabel "kubernetes_pods_block_custom_name" { + targets = concat(discovery.relabel.kubernetes_pods.output) + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_block_scrape"] + action = "keep" + regex = "true" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_block_port_name"] + action = "drop" + regex = "" + } + + rule { + source_labels = ["__meta_kubernetes_pod_container_port_name"] + target_label = "__meta_kubernetes_pod_annotation_profiles_grafana_com_block_port_name" + action = "keepequal" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_block_scheme"] + action = "replace" + regex = "(https?)" + target_label = "__scheme__" + replacement = "$1" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_block_path"] + action = "replace" + regex = "(.+)" + target_label = "__profile_path__" + replacement = "$1" + } + + rule { + source_labels = ["__address__", "__meta_kubernetes_pod_annotation_profiles_grafana_com_block_port"] + action = "replace" + regex = "(.+?)(?::\\d+)?;(\\d+)" + target_label = "__address__" + replacement = "$1:$2" + } + } + + /***************************************************************** + * Kubernetes Pyroscope Scrape Block + *****************************************************************/ + pyroscope.scrape "pyroscope_scrape_block" { + clustering { + enabled = true + } + + targets = concat(discovery.relabel.kubernetes_pods_block_default_name.output, discovery.relabel.kubernetes_pods_block_custom_name.output) + forward_to = argument.forward_to.value + + profiling_config { + profile.memory { + enabled = false + } + + profile.process_cpu { + enabled = false + } + + profile.goroutine { + enabled = false + } + + profile.block { + enabled = true + } + + profile.mutex { + enabled = false + } + + profile.fgprof { + enabled = false + } + } + } + + discovery.relabel "kubernetes_pods_mutex_default_name" { + targets = concat(discovery.relabel.kubernetes_pods.output) + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_scrape"] + action = "keep" + regex = "true" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_port_name"] + action = "keep" + regex = "" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_scheme"] + action = "replace" + regex = "(https?)" + target_label = "__scheme__" + replacement = "$1" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_path"] + action = "replace" + regex = "(.+)" + target_label = "__profile_path__" + replacement = "$1" + } + + rule { + source_labels = ["__address__", "__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_port"] + action = "replace" + regex = "(.+?)(?::\\d+)?;(\\d+)" + target_label = "__address__" + replacement = "$1:$2" + } + } + + discovery.relabel "kubernetes_pods_mutex_custom_name" { + targets = concat(discovery.relabel.kubernetes_pods.output) + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_scrape"] + action = "keep" + regex = "true" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_port_name"] + action = "drop" + regex = "" + } + + rule { + source_labels = ["__meta_kubernetes_pod_container_port_name"] + target_label = "__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_port_name" + action = "keepequal" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_scheme"] + action = "replace" + regex = "(https?)" + target_label = "__scheme__" + replacement = "$1" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_path"] + action = "replace" + regex = "(.+)" + target_label = "__profile_path__" + replacement = "$1" + } + + rule { + source_labels = ["__address__", "__meta_kubernetes_pod_annotation_profiles_grafana_com_mutex_port"] + action = "replace" + regex = "(.+?)(?::\\d+)?;(\\d+)" + target_label = "__address__" + replacement = "$1:$2" + } + } + + /***************************************************************** + * Kubernetes Pyroscope Scrape Mutex + *****************************************************************/ + pyroscope.scrape "pyroscope_scrape_mutex" { + clustering { + enabled = true + } + + targets = concat(discovery.relabel.kubernetes_pods_mutex_default_name.output, discovery.relabel.kubernetes_pods_mutex_custom_name.output) + forward_to = argument.forward_to.value + + profiling_config { + profile.memory { + enabled = false + } + + profile.process_cpu { + enabled = false + } + + profile.goroutine { + enabled = false + } + + profile.block { + enabled = false + } + + profile.mutex { + enabled = true + } + + profile.fgprof { + enabled = false + } + } + } + + discovery.relabel "kubernetes_pods_fgprof_default_name" { + targets = concat(discovery.relabel.kubernetes_pods.output) + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_scrape"] + action = "keep" + regex = "true" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_port_name"] + action = "keep" + regex = "" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_scheme"] + action = "replace" + regex = "(https?)" + target_label = "__scheme__" + replacement = "$1" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_path"] + action = "replace" + regex = "(.+)" + target_label = "__profile_path__" + replacement = "$1" + } + + rule { + source_labels = ["__address__", "__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_port"] + action = "replace" + regex = "(.+?)(?::\\d+)?;(\\d+)" + target_label = "__address__" + replacement = "$1:$2" + } + } + + discovery.relabel "kubernetes_pods_fgprof_custom_name" { + targets = concat(discovery.relabel.kubernetes_pods.output) + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_scrape"] + action = "keep" + regex = "true" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_port_name"] + action = "drop" + regex = "" + } + + rule { + source_labels = ["__meta_kubernetes_pod_container_port_name"] + target_label = "__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_port_name" + action = "keepequal" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_scheme"] + action = "replace" + regex = "(https?)" + target_label = "__scheme__" + replacement = "$1" + } + + rule { + source_labels = ["__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_path"] + action = "replace" + regex = "(.+)" + target_label = "__profile_path__" + replacement = "$1" + } + + rule { + source_labels = ["__address__", "__meta_kubernetes_pod_annotation_profiles_grafana_com_fgprof_port"] + action = "replace" + regex = "(.+?)(?::\\d+)?;(\\d+)" + target_label = "__address__" + replacement = "$1:$2" + } + } + + /***************************************************************** + * Kubernetes Pyroscope Scrape Fgprof + *****************************************************************/ + pyroscope.scrape "pyroscope_scrape_fgprof" { + clustering { + enabled = true + } + + targets = concat(discovery.relabel.kubernetes_pods_fgprof_default_name.output, discovery.relabel.kubernetes_pods_fgprof_custom_name.output) + forward_to = argument.forward_to.value + + profiling_config { + profile.memory { + enabled = false + } + + profile.process_cpu { + enabled = false + } + + profile.goroutine { + enabled = false + } + + profile.block { + enabled = false + } + + profile.mutex { + enabled = false + } + + profile.fgprof { + enabled = true + } + } + } +} diff --git a/alloy-modules/kubernetes/traces/process-and-transform.alloy b/alloy-modules/kubernetes/traces/process-and-transform.alloy new file mode 100644 index 00000000..7ab57c49 --- /dev/null +++ b/alloy-modules/kubernetes/traces/process-and-transform.alloy @@ -0,0 +1,260 @@ +/* +Module Components: process_and_transform + +Description: Traces data collection processing and transformation +*/ + +// Processing And Transformation +declare "process_and_transform" { + + /***************************************************************** + * ARGUMENTS + *****************************************************************/ + argument "traces_forward_to" { + comment = "Must be a list(TracesReceiver) where collected traces should be forwarded to" + } + + argument "logs_forward_to" { + comment = "Must be a list(LogsReceiver) where collected logs should be forwarded to" + } + + argument "metrics_forward_to" { + comment = "Must be a list(MetricsReceiver) where collected metrics should be forwarded to" + } + + argument "cluster" { + optional = true + default = "k3d-k3s-codelab" + } + + argument "otlp_http_endpoint" { + optional = true + default = "0.0.0.0:4318" + } + + argument "otlp_grpc_endpoint" { + optional = true + default = "0.0.0.0:4317" + } + + /***************************************************************** + * Jaeger for Metrics Logs Traces + *****************************************************************/ + otelcol.receiver.jaeger "default" { + protocols { + grpc { + endpoint = "0.0.0.0:14250" + } + + thrift_http { + endpoint = "0.0.0.0:14268" + } + + thrift_binary { + endpoint = "0.0.0.0:6832" + } + + thrift_compact { + endpoint = "0.0.0.0:6831" + } + } + + output { + metrics = [otelcol.processor.batch.default.input] + logs = [otelcol.processor.resourcedetection.default.input] + traces = [otelcol.processor.resourcedetection.default.input] + } + } + + /***************************************************************** + * Otelcol for Metrics Logs Traces + *****************************************************************/ + otelcol.receiver.otlp "default" { + grpc { + endpoint = argument.otlp_grpc_endpoint.value + } + + http { + endpoint = argument.otlp_http_endpoint.value + } + + output { + metrics = [otelcol.processor.batch.default.input] + logs = [otelcol.processor.resourcedetection.default.input] + traces = [ + otelcol.processor.resourcedetection.default.input, + otelcol.connector.spanlogs.autologging.input, + ] + } + } + + otelcol.processor.resourcedetection "default" { + detectors = ["env"] + + output { + logs = [otelcol.processor.k8sattributes.default.input] + traces = [otelcol.processor.k8sattributes.default.input] + } + } + + otelcol.processor.k8sattributes "default" { + extract { + metadata = [ + "k8s.namespace.name", + "k8s.pod.name", + "k8s.deployment.name", + "k8s.statefulset.name", + "k8s.daemonset.name", + "k8s.cronjob.name", + "k8s.job.name", + "k8s.node.name", + "k8s.pod.uid", + "k8s.pod.start_time", + ] + } + + pod_association { + source { + from = "connection" + } + } + + output { + logs = [otelcol.processor.transform.add_resource_attributes.input] + traces = [otelcol.processor.transform.add_resource_attributes.input] + } + } + + otelcol.processor.transform "add_resource_attributes" { + error_mode = "ignore" + + log_statements { + context = "resource" + statements = [ + `set(attributes["pod"], attributes["k8s.pod.name"])`, + `set(attributes["namespace"], attributes["k8s.namespace.name"])`, + `set(attributes["loki.resource.labels"], "pod, namespace, cluster, job")`, + `set(attributes["k8s.cluster.name"], "k3d-k3s-codelab") where attributes["k8s.cluster.name"] == nil`, + ] + } + + trace_statements { + context = "resource" + statements = [ + `set(attributes["k8s.cluster.name"], "k3d-k3s-codelab") where attributes["k8s.cluster.name"] == nil`, + ] + } + + output { + logs = [otelcol.processor.filter.default.input] + traces = [otelcol.processor.filter.default.input] + } + } + + otelcol.processor.filter "default" { + error_mode = "ignore" + + output { + logs = [otelcol.processor.batch.default.input] + traces = [otelcol.processor.batch.default.input] + } + } + + otelcol.processor.batch "default" { + send_batch_size = 16384 + send_batch_max_size = 0 + timeout = "5s" + + output { + metrics = [otelcol.processor.memory_limiter.default.input] + logs = [otelcol.processor.memory_limiter.default.input] + traces = [otelcol.processor.memory_limiter.default.input] + } + } + + otelcol.processor.memory_limiter "default" { + check_interval = "1s" + limit_percentage = 50 + spike_limit_percentage = 30 + + output { + metrics = [otelcol.exporter.prometheus.tracesmetrics.input] + logs = [otelcol.exporter.loki.traceslogs.input] + traces = argument.traces_forward_to.value + } + } + + otelcol.exporter.prometheus "tracesmetrics" { + forward_to = argument.metrics_forward_to.value + } + + otelcol.exporter.loki "traceslogs" { + forward_to = [loki.process.traceslogs.receiver] + } + + // The OpenTelemetry spanlog connector processes incoming trace spans and extracts data from them ready + // for logging. + otelcol.connector.spanlogs "autologging" { + // We only want to output a line for each root span (ie. every single trace), and not for every + // process or span (outputting a line for every span would be extremely verbose). + spans = false + roots = true + processes = false + + // We want to ensure that the following three span attributes are included in the log line, if present. + span_attributes = [ + "http.method", + "http.target", + "http.status_code", + ] + + // Overrides the default key in the log line to be `traceId`, which is then used by Grafana to + // identify the trace ID for correlation with the Tempo datasource. + overrides { + trace_id_key = "traceId" + } + + // Send to the OpenTelemetry Loki exporter. + output { + logs = [otelcol.exporter.loki.autologging.input] + } + } + + // Simply forwards the incoming OpenTelemetry log format out as a Loki log. + // We need this stage to ensure we can then process the logline as a Loki object. + otelcol.exporter.loki "autologging" { + forward_to = [loki.process.autologging.receiver] + } + + // The Loki processor allows us to accept a correctly formatted Loki log and mutate it into + // a set of fields for output. + loki.process "autologging" { + // The JSON stage simply extracts the `body` (the actual logline) from the Loki log, ignoring + // all other fields. + stage.json { + expressions = {"body" = ""} + } + // The output stage takes the body (the main logline) and uses this as the source for the output + // logline. In this case, it essentially turns it into logfmt. + stage.output { + source = "body" + } + + forward_to = [loki.process.traceslogs.receiver] + } + + loki.process "traceslogs" { + stage.tenant { + value = "anonymous" + } + + forward_to = argument.logs_forward_to.value + } + + /***************************************************************** + * EXPORTS + *****************************************************************/ + export "alloy_traces_input" { + value = otelcol.processor.batch.default.input + } +} diff --git a/kubernetes/common/alloy/configs/kubernetes/README.md b/kubernetes/common/alloy/configs/kubernetes/README.md new file mode 100644 index 00000000..e8208a5b --- /dev/null +++ b/kubernetes/common/alloy/configs/kubernetes/README.md @@ -0,0 +1,10 @@ +# Alloy Modules - Kubernetes(WIP) + +## Modules + +- [Metrics](metrics/README.md) +- [Integrations](integrations/README.md) + +## Kubernetes `annotations_scrape` Component + +Kubernetes `annotations_scrape` Component for [`Logs`](logs/annotations-scrape.alloy), [`Metrics`](metrics/annotations-scrape.alloy) and [`Profiles`](profiles/annotations-scrape.alloy) diff --git a/kubernetes/common/alloy/configs/kubernetes/integrations/memcached.alloy b/kubernetes/common/alloy/configs/kubernetes/integrations/memcached.alloy index 64348632..b02b4681 100644 --- a/kubernetes/common/alloy/configs/kubernetes/integrations/memcached.alloy +++ b/kubernetes/common/alloy/configs/kubernetes/integrations/memcached.alloy @@ -12,22 +12,17 @@ declare "component_memcached" { } argument "job_label" { + comment = "job label (default: integrations/kubernetes/memcached)" optional = true - default = "integrations/kubernetes/memcached" } - argument "memcached_address" { + argument "namespace" { + comment = "kubernetes secret name (default: monitoring-system)" optional = true - default = "memcached:11211" } - argument "memcached_timeout" { - optional = true - default = "5s" - } - - argument "instance_name" { - comment = "instance of the Memcached" + argument "name" { + comment = "kubernetes secret name (default: alloy-integrations-redis)" optional = true } @@ -39,13 +34,16 @@ declare "component_memcached" { argument "scrape_interval" { comment = "How often to scrape metrics from the targets (default: 60s)" optional = true - default = "60s" } argument "scrape_timeout" { comment = "How long before a scrape times out (default: 10s)" optional = true - default = "10s" + } + + remote.kubernetes.secret "memcached" { + namespace = coalesce(argument.namespace.value, "monitoring-system") + name = coalesce(argument.name.value, "alloy-integrations-memcached") } /*************************************************************** @@ -53,8 +51,8 @@ declare "component_memcached" { ****************************************************************/ // https://grafana.com/docs/alloy/latest/reference/components/prometheus.exporter.memcached/ prometheus.exporter.memcached "integrations_memcached_exporter" { - address = argument.memcached_address.value - timeout = argument.memcached_timeout.value + address = nonsensitive(remote.kubernetes.secret.memcached.data["instance-address"]) + timeout = nonsensitive(remote.kubernetes.secret.memcached.data["instance-timeout"]) } /*************************************************************** @@ -65,12 +63,12 @@ declare "component_memcached" { rule { target_label = "job" - replacement = argument.job_label.value + replacement = coalesce(argument.job_label.value, "integrations/kubernetes/memcached") } rule { target_label = "instance" - replacement = coalesce(argument.instance_name.value, constants.hostname) + replacement = coalesce(nonsensitive(remote.kubernetes.secret.memcached.data["instance-name"]), constants.hostname) } } @@ -85,8 +83,8 @@ declare "component_memcached" { enable_protobuf_negotiation = true scrape_classic_histograms = true - scrape_interval = argument.scrape_interval.value - scrape_timeout = argument.scrape_timeout.value + scrape_interval = coalesce(argument.scrape_interval.value, "60s") + scrape_timeout = coalesce(argument.scrape_timeout.value, "10s") clustering { enabled = true diff --git a/kubernetes/common/alloy/configs/kubernetes/integrations/mysql.alloy b/kubernetes/common/alloy/configs/kubernetes/integrations/mysql.alloy index 64481b46..b7848c56 100644 --- a/kubernetes/common/alloy/configs/kubernetes/integrations/mysql.alloy +++ b/kubernetes/common/alloy/configs/kubernetes/integrations/mysql.alloy @@ -12,21 +12,17 @@ declare "component_mysql" { } argument "job_label" { + comment = "job label (default: integrations/kubernetes/mysql)" optional = true - default = "integrations/kubernetes/mysql" } argument "namespace" { + comment = "kubernetes secret name (default: monitoring-system)" optional = true - default = "monitoring-system" } argument "name" { - optional = true - default = "alloy-integrations-mysql" - } - - argument "instance_name" { + comment = "kubernetes secret name (default: alloy-integrations-mysql)" optional = true } @@ -38,18 +34,16 @@ declare "component_mysql" { argument "scrape_interval" { comment = "How often to scrape metrics from the targets (default: 60s)" optional = true - default = "60s" } argument "scrape_timeout" { comment = "How long before a scrape times out (default: 10s)" optional = true - default = "10s" } remote.kubernetes.secret "mysql" { - name = argument.name.value - namespace = argument.namespace.value + name = coalesce(argument.name.value, "alloy-integrations-mysql") + namespace = coalesce(argument.namespace.value, "monitoring-system") } /*************************************************************** @@ -67,12 +61,12 @@ declare "component_mysql" { rule { target_label = "job" - replacement = argument.job_label.value + replacement = coalesce(argument.job_label.value, "integrations/kubernetes/mysql") } rule { target_label = "instance" - replacement = coalesce(argument.instance_name.value, constants.hostname) + replacement = coalesce(nonsensitive(remote.kubernetes.secret.mysql.data["instance-name"]), constants.hostname) } } @@ -87,8 +81,8 @@ declare "component_mysql" { enable_protobuf_negotiation = true scrape_classic_histograms = true - scrape_interval = argument.scrape_interval.value - scrape_timeout = argument.scrape_timeout.value + scrape_interval = coalesce(argument.scrape_interval.value, "60s") + scrape_timeout = coalesce(argument.scrape_timeout.value, "10s") clustering { enabled = true diff --git a/kubernetes/common/alloy/configs/kubernetes/integrations/redis.alloy b/kubernetes/common/alloy/configs/kubernetes/integrations/redis.alloy index 2bdf54ae..e3474652 100644 --- a/kubernetes/common/alloy/configs/kubernetes/integrations/redis.alloy +++ b/kubernetes/common/alloy/configs/kubernetes/integrations/redis.alloy @@ -12,21 +12,17 @@ declare "component_redis_exporter" { } argument "job_label" { + comment = "job label (default: integrations/kubernetes/redis_exporter)" optional = true - default = "integrations/kubernetes/redis_exporter" } argument "namespace" { + comment = "kubernetes secret name (default: monitoring-system)" optional = true - default = "monitoring-system" } argument "name" { - optional = true - default = "alloy-integrations-redis" - } - - argument "instance_name" { + comment = "kubernetes secret name (default: alloy-integrations-redis)" optional = true } @@ -48,32 +44,32 @@ declare "component_redis_exporter" { } remote.kubernetes.secret "redis" { - name = argument.name.value - namespace = argument.namespace.value + namespace = coalesce(argument.namespace.value, "monitoring-system") + name = coalesce(argument.name.value, "alloy-integrations-redis") } /*************************************************************** * Integrations Redis ****************************************************************/ prometheus.exporter.redis "integrations_redis_exporter" { - redis_addr = nonsensitive(remote.kubernetes.secret.redis.data["redis-addr"]) - redis_password = nonsensitive(remote.kubernetes.secret.redis.data["redis-password"]) + redis_addr = nonsensitive(remote.kubernetes.secret.redis.data["instance-address"]) + redis_password = nonsensitive(remote.kubernetes.secret.redis.data["instance-password"]) } /*************************************************************** * Discovery Relabelings (pre-scrape) ****************************************************************/ discovery.relabel "integrations_redis_exporter" { - targets = prometheus.exporter.memcached.integrations_redis_exporter.targets + targets = prometheus.exporter.redis.integrations_redis_exporter.targets rule { target_label = "job" - replacement = argument.job_label.value + replacement = coalesce(argument.job_label.value, "integrations/kubernetes/redis_exporter") } rule { target_label = "instance" - replacement = coalesce(argument.instance_name.value, constants.hostname) + replacement = coalesce(nonsensitive(remote.kubernetes.secret.redis.data["instance-name"]), constants.hostname) } } diff --git a/kubernetes/common/alloy/configs/kubernetes/metrics/integrations-scrape.alloy b/kubernetes/common/alloy/configs/kubernetes/metrics/integrations-scrape.alloy index 8ec4f3d6..542f1bb0 100644 --- a/kubernetes/common/alloy/configs/kubernetes/metrics/integrations-scrape.alloy +++ b/kubernetes/common/alloy/configs/kubernetes/metrics/integrations-scrape.alloy @@ -20,51 +20,60 @@ declare "integrations_scrape" { argument "name" { comment = "Name of the integrations config" optional = true - default = "alloy-integrations" } argument "namespace" { comment = "Namespace of the integrations config" optional = true - default = "default" } /***************************************************************** * Import Integrations Components *****************************************************************/ - // integrations components local files - import.file "integrations" { - filename = coalesce(env("ALLOY_MODULES_FOLDER"), "/etc/alloy/modules") + "/kubernetes/integrations" + remote.kubernetes.configmap "integrations" { + namespace = coalesce(argument.namespace.value, "monitoring-system") + name = coalesce(argument.name.value, "alloy-integrations") } - // // integrations components kubernetes configmap - // remote.kubernetes.configmap "integrations" { - // name = argument.name.value - // namespace = argument.namespace.value - // } - // import.string "integrations" { - // content = remote.kubernetes.configmap.integrations.data["memcached.alloy"] - // } - /***************************************************************** * Memcached Integrations *****************************************************************/ - integrations.component_memcached "primary" { + import.string "memcached" { + content = remote.kubernetes.configmap.integrations.data["memcached.alloy"] + } + + memcached.component_memcached "instance" { forward_to = argument.forward_to.value - instance_name = "primary" - memcached_address = "memcached.memcached-system.svc.cluster.local:11211" - memcached_timeout = "5s" + 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 // *****************************************************************/ - // integrations.component_mysql "primary" { + // import.string "mysql" { + // content = remote.kubernetes.configmap.integrations.data["mysql.alloy"] + // } + + // mysql.component_mysql "instance" { // forward_to = argument.forward_to.value - // instance_name = "primary" - // name = "alloy-integrations-mysql" - // namespace = "monitoring-system" + // namespace = argument.namespace.value + // name = remote.kubernetes.configmap.integrations.data["MYSQL_K8S_SECRET_NAME"] // } } diff --git a/kubernetes/common/alloy/configs/kubernetes/metrics/podmonitors-scrape.alloy b/kubernetes/common/alloy/configs/kubernetes/metrics/podmonitors-scrape.alloy index 2aff0001..540e2ff0 100644 --- a/kubernetes/common/alloy/configs/kubernetes/metrics/podmonitors-scrape.alloy +++ b/kubernetes/common/alloy/configs/kubernetes/metrics/podmonitors-scrape.alloy @@ -13,12 +13,27 @@ declare "podmonitors_scrape" { optional = false } + argument "scrape_interval" { + comment = "How often to scrape metrics from the targets (default: 60s)" + optional = true + } + + argument "scrape_timeout" { + comment = "How long before a scrape times out (default: 10s)" + optional = true + } + /***************************************************************** * Kubernetes Auto Scrape PodMonitors *****************************************************************/ prometheus.operator.podmonitors "scrape" { forward_to = argument.forward_to.value + scrape { + default_scrape_interval = coalesce(argument.scrape_interval.value, "60s") + default_scrape_timeout = coalesce(argument.scrape_timeout.value, "10s") + } + clustering { enabled = true } diff --git a/kubernetes/common/alloy/configs/kubernetes/metrics/servicemonitors-scrape.alloy b/kubernetes/common/alloy/configs/kubernetes/metrics/servicemonitors-scrape.alloy index 888206be..d221e276 100644 --- a/kubernetes/common/alloy/configs/kubernetes/metrics/servicemonitors-scrape.alloy +++ b/kubernetes/common/alloy/configs/kubernetes/metrics/servicemonitors-scrape.alloy @@ -13,12 +13,27 @@ declare "servicemonitors_scrape" { optional = false } + argument "scrape_interval" { + comment = "How often to scrape metrics from the targets (default: 60s)" + optional = true + } + + argument "scrape_timeout" { + comment = "How long before a scrape times out (default: 10s)" + optional = true + } + /***************************************************************** * Kubernetes Auto Scrape ServiceMonitors *****************************************************************/ prometheus.operator.servicemonitors "scrape" { forward_to = argument.forward_to.value + scrape { + default_scrape_interval = coalesce(argument.scrape_interval.value, "60s") + default_scrape_timeout = coalesce(argument.scrape_timeout.value, "10s") + } + clustering { enabled = true } diff --git a/kubernetes/common/alloy/kustomization.yaml b/kubernetes/common/alloy/kustomization.yaml index 43d52740..47a3ff13 100644 --- a/kubernetes/common/alloy/kustomization.yaml +++ b/kubernetes/common/alloy/kustomization.yaml @@ -29,9 +29,6 @@ configMapGenerator: namespace: monitoring-system files: - configs/kubernetes/integrations/k8s-events.alloy - - configs/kubernetes/integrations/memcached.alloy - - configs/kubernetes/integrations/mysql.alloy - - configs/kubernetes/integrations/redis.alloy - name: alloy-modules-kubernetes-logs namespace: monitoring-system files: @@ -46,42 +43,49 @@ configMapGenerator: files: - configs/kubernetes/profiles/annotations-scrape.alloy -# # Agent Integrations Config -# - name: agent-integrations -# namespace: monitoring-system -# options: -# disableNameSuffixHash: true -# literals: -# - MYSQL_SECRET_NAME=integrations-mysql -# - MEMCACHED_SECRET_NAME=integrations-memcached -# - REDIS_SECRET_NAME=integrations-redis -# files: -# - integrations/mysql.river -# - integrations/memcached.river -# - integrations/redis.river - -secretGenerator: -# integrations mysql credentials -- name: alloy-integrations-mysql +# Agent Integrations Config +- name: alloy-integrations namespace: monitoring-system options: disableNameSuffixHash: true literals: - - mysql-host=mysql.mysql-system.svc.cluster.local - - mysql-username=lgtmp - - mysql-password=VD538OYxSEiGD4I9mmFfqFMCGq1vIiGm -# integrations redis credentials -- name: alloy-integrations-redis - namespace: monitoring-system - options: - disableNameSuffixHash: true + - 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: - - redis-addr=redis-master.redis-system.svc.cluster.local:6379 - - redis-password=VD538OYxSEiGD4I9mmFfqFMCGq1vIiGm + - ALLOY_LOG_LEVEL=warn # integrations memcached credentials - name: alloy-integrations-memcached namespace: monitoring-system options: disableNameSuffixHash: true literals: - - memcached-address=memcached.memcached-system.svc.cluster.local:11211 + - 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 72557d74..61875b5d 100644 --- a/kubernetes/common/alloy/manifests/k8s-all-in-one.yaml +++ b/kubernetes/common/alloy/manifests/k8s-all-in-one.yaml @@ -142,130 +142,72 @@ metadata: --- 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" + 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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/memcached\"\n\t}\n\n\targument - \"memcached_address\" {\n\t\toptional = true\n\t\tdefault = \"memcached:11211\"\n\t}\n\n\targument - \"memcached_timeout\" {\n\t\toptional = true\n\t\tdefault = \"5s\"\n\t}\n\n\targument - \"instance_name\" {\n\t\tcomment = \"instance of the Memcached\"\n\t\toptional + 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\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\t/***************************************************************\n\t* + (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 = argument.memcached_address.value\n\t\ttimeout - = argument.memcached_timeout.value\n\t}\n\n\t/***************************************************************\n\t* + \"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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, + {\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 = 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_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* + = 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" - mysql.alloy: "/*\nModule Components: component_mysql\n*/\n\ndeclare \"component_mysql\" - {\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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/mysql\"\n\t}\n\n\targument \"namespace\" - {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-mysql\"\n\t}\n\n\targument - \"instance_name\" {\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\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 - \"mysql\" {\n\t\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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 = 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_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 \"component_redis_exporter\" - {\n\n\t/*****************************************************************\n\t* +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(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/redis_exporter\"\n\t}\n\n\targument - \"namespace\" {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-redis\"\n\t}\n\n\targument - \"instance_name\" {\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\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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[\"redis-addr\"])\n\t\tredis_password - = nonsensitive(remote.kubernetes.secret.redis.data[\"redis-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.memcached.integrations_redis_exporter.targets\n\n\t\trule - {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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" + \"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-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 namespace: monitoring-system --- apiVersion: v1 @@ -401,48 +343,59 @@ data: 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\tdefault = \"alloy-integrations\"\n\t}\n\n\targument - \"namespace\" {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional - = true\n\t\tdefault = \"default\"\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\t// - integrations components local files\n\timport.file \"integrations\" {\n\t\tfilename - = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") + \"/kubernetes/integrations\"\n\t}\n\n\t// - // integrations components kubernetes configmap\n\t// remote.kubernetes.configmap - \"integrations\" {\n\t// \tname = argument.name.value\n\t// \tnamespace = - argument.namespace.value\n\t// }\n\t// import.string \"integrations\" {\n\t// - \tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t// - }\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\tintegrations.component_memcached - \"primary\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tinstance_name - \ = \"primary\"\n\t\tmemcached_address = \"memcached.memcached-system.svc.cluster.local:11211\"\n\t\tmemcached_timeout - = \"5s\"\n\t}\n\n\t// /*****************************************************************\n\t// + \"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// - integrations.component_mysql \"primary\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tinstance_name = \"primary\"\n\t// \tname = \"alloy-integrations-mysql\"\n\t// - \tnamespace = \"monitoring-system\"\n\t// }\n}\n" + 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* ARGUMENTS\n\t*****************************************************************/\n\targument \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape PodMonitors\n\t*****************************************************************/\n\tprometheus.operator.podmonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression {\n\t\t// \t\tkey - \ = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues = [\"team-infra\"]\n\t\t// - \t}\n\t\t// }\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression + {\n\t\t// \t\tkey = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues + \ = [\"team-infra\"]\n\t\t// \t}\n\t\t// }\n\t}\n}\n" servicemonitors-scrape.alloy: "/*\nModule Components: servicemonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.servicemonitors\n*/\n\ndeclare \"servicemonitors_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\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape ServiceMonitors\n\t*****************************************************************/\n\tprometheus.operator.servicemonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc namespace: monitoring-system --- apiVersion: v1 @@ -767,31 +720,21 @@ metadata: --- apiVersion: v1 data: - memcached-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + ALLOY_LOG_LEVEL: d2Fybg== kind: Secret metadata: - name: alloy-integrations-memcached + name: alloy-env-f7k229g955 namespace: monitoring-system type: Opaque --- apiVersion: v1 data: - mysql-host: bXlzcWwubXlzcWwtc3lzdGVtLnN2Yy5jbHVzdGVyLmxvY2Fs - mysql-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= - mysql-username: bGd0bXA= + instance-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + instance-name: cHJpbWFyeQ== + instance-timeout: NXM= kind: Secret metadata: - name: alloy-integrations-mysql - namespace: monitoring-system -type: Opaque ---- -apiVersion: v1 -data: - redis-addr: cmVkaXMtbWFzdGVyLnJlZGlzLXN5c3RlbS5zdmMuY2x1c3Rlci5sb2NhbDo2Mzc5 - redis-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= -kind: Secret -metadata: - name: alloy-integrations-redis + name: alloy-integrations-memcached namespace: monitoring-system type: Opaque --- @@ -933,7 +876,7 @@ spec: fieldPath: spec.nodeName envFrom: - secretRef: - name: alloy-env + name: alloy-env-f7k229g955 optional: true image: docker.io/grafana/alloy:v1.0.0 imagePullPolicy: IfNotPresent @@ -982,10 +925,10 @@ spec: name: alloy-config-ftt29f8k85 name: config - configMap: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 name: modules-kubernetes-integrations - configMap: name: alloy-modules-kubernetes-logs-d7c756mt2f diff --git a/kubernetes/common/grafana/manifests/k8s-all-in-one.yaml b/kubernetes/common/grafana/manifests/k8s-all-in-one.yaml index c5aa0d97..a6d6b35f 100644 --- a/kubernetes/common/grafana/manifests/k8s-all-in-one.yaml +++ b/kubernetes/common/grafana/manifests/k8s-all-in-one.yaml @@ -3778,7 +3778,7 @@ spec: path: /metrics port: http-metrics scheme: http - scrapeTimeout: 30s + scrapeTimeout: 10s jobLabel: grafana namespaceSelector: matchNames: diff --git a/kubernetes/common/grafana/values-k3d-k3s.yaml b/kubernetes/common/grafana/values-k3d-k3s.yaml index 9d15c903..8e5ff743 100644 --- a/kubernetes/common/grafana/values-k3d-k3s.yaml +++ b/kubernetes/common/grafana/values-k3d-k3s.yaml @@ -21,6 +21,7 @@ service: serviceMonitor: enabled: true interval: 15s + scrapeTimeout: 10s ingress: enabled: true diff --git a/kubernetes/microservices-mode/logs/k8s-all-in-one.yaml b/kubernetes/microservices-mode/logs/k8s-all-in-one.yaml index 49fed1f5..ce3e3841 100644 --- a/kubernetes/microservices-mode/logs/k8s-all-in-one.yaml +++ b/kubernetes/microservices-mode/logs/k8s-all-in-one.yaml @@ -357,130 +357,72 @@ metadata: --- 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" + 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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/memcached\"\n\t}\n\n\targument - \"memcached_address\" {\n\t\toptional = true\n\t\tdefault = \"memcached:11211\"\n\t}\n\n\targument - \"memcached_timeout\" {\n\t\toptional = true\n\t\tdefault = \"5s\"\n\t}\n\n\targument - \"instance_name\" {\n\t\tcomment = \"instance of the Memcached\"\n\t\toptional + 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\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\t/***************************************************************\n\t* + (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 = argument.memcached_address.value\n\t\ttimeout - = argument.memcached_timeout.value\n\t}\n\n\t/***************************************************************\n\t* + \"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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, + {\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 = 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_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* + = 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" - mysql.alloy: "/*\nModule Components: component_mysql\n*/\n\ndeclare \"component_mysql\" - {\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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/mysql\"\n\t}\n\n\targument \"namespace\" - {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-mysql\"\n\t}\n\n\targument - \"instance_name\" {\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\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 - \"mysql\" {\n\t\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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 = 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_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 \"component_redis_exporter\" - {\n\n\t/*****************************************************************\n\t* +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(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/redis_exporter\"\n\t}\n\n\targument - \"namespace\" {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-redis\"\n\t}\n\n\targument - \"instance_name\" {\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\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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[\"redis-addr\"])\n\t\tredis_password - = nonsensitive(remote.kubernetes.secret.redis.data[\"redis-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.memcached.integrations_redis_exporter.targets\n\n\t\trule - {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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" + \"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-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 namespace: monitoring-system --- apiVersion: v1 @@ -616,48 +558,59 @@ data: 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\tdefault = \"alloy-integrations\"\n\t}\n\n\targument - \"namespace\" {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional - = true\n\t\tdefault = \"default\"\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\t// - integrations components local files\n\timport.file \"integrations\" {\n\t\tfilename - = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") + \"/kubernetes/integrations\"\n\t}\n\n\t// - // integrations components kubernetes configmap\n\t// remote.kubernetes.configmap - \"integrations\" {\n\t// \tname = argument.name.value\n\t// \tnamespace = - argument.namespace.value\n\t// }\n\t// import.string \"integrations\" {\n\t// - \tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t// - }\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\tintegrations.component_memcached - \"primary\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tinstance_name - \ = \"primary\"\n\t\tmemcached_address = \"memcached.memcached-system.svc.cluster.local:11211\"\n\t\tmemcached_timeout - = \"5s\"\n\t}\n\n\t// /*****************************************************************\n\t// + \"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// - integrations.component_mysql \"primary\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tinstance_name = \"primary\"\n\t// \tname = \"alloy-integrations-mysql\"\n\t// - \tnamespace = \"monitoring-system\"\n\t// }\n}\n" + 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* ARGUMENTS\n\t*****************************************************************/\n\targument \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape PodMonitors\n\t*****************************************************************/\n\tprometheus.operator.podmonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression {\n\t\t// \t\tkey - \ = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues = [\"team-infra\"]\n\t\t// - \t}\n\t\t// }\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression + {\n\t\t// \t\tkey = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues + \ = [\"team-infra\"]\n\t\t// \t}\n\t\t// }\n\t}\n}\n" servicemonitors-scrape.alloy: "/*\nModule Components: servicemonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.servicemonitors\n*/\n\ndeclare \"servicemonitors_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\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape ServiceMonitors\n\t*****************************************************************/\n\tprometheus.operator.servicemonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc namespace: monitoring-system --- apiVersion: v1 @@ -1132,31 +1085,21 @@ type: Opaque --- apiVersion: v1 data: - memcached-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + ALLOY_LOG_LEVEL: d2Fybg== kind: Secret metadata: - name: alloy-integrations-memcached + name: alloy-env-f7k229g955 namespace: monitoring-system type: Opaque --- apiVersion: v1 data: - mysql-host: bXlzcWwubXlzcWwtc3lzdGVtLnN2Yy5jbHVzdGVyLmxvY2Fs - mysql-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= - mysql-username: bGd0bXA= + instance-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + instance-name: cHJpbWFyeQ== + instance-timeout: NXM= kind: Secret metadata: - name: alloy-integrations-mysql - namespace: monitoring-system -type: Opaque ---- -apiVersion: v1 -data: - redis-addr: cmVkaXMtbWFzdGVyLnJlZGlzLXN5c3RlbS5zdmMuY2x1c3Rlci5sb2NhbDo2Mzc5 - redis-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= -kind: Secret -metadata: - name: alloy-integrations-redis + name: alloy-integrations-memcached namespace: monitoring-system type: Opaque --- @@ -2997,7 +2940,7 @@ spec: fieldPath: spec.nodeName envFrom: - secretRef: - name: alloy-env + name: alloy-env-f7k229g955 optional: true image: docker.io/grafana/alloy:v1.0.0 imagePullPolicy: IfNotPresent @@ -3046,10 +2989,10 @@ spec: name: alloy-config-8t9d8htff7 name: config - configMap: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 name: modules-kubernetes-integrations - configMap: name: alloy-modules-kubernetes-logs-d7c756mt2f diff --git a/kubernetes/microservices-mode/metrics/k8s-all-in-one.yaml b/kubernetes/microservices-mode/metrics/k8s-all-in-one.yaml index cdeda304..40e6feea 100644 --- a/kubernetes/microservices-mode/metrics/k8s-all-in-one.yaml +++ b/kubernetes/microservices-mode/metrics/k8s-all-in-one.yaml @@ -180,130 +180,72 @@ metadata: --- 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" + 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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/memcached\"\n\t}\n\n\targument - \"memcached_address\" {\n\t\toptional = true\n\t\tdefault = \"memcached:11211\"\n\t}\n\n\targument - \"memcached_timeout\" {\n\t\toptional = true\n\t\tdefault = \"5s\"\n\t}\n\n\targument - \"instance_name\" {\n\t\tcomment = \"instance of the Memcached\"\n\t\toptional + 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\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\t/***************************************************************\n\t* + (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 = argument.memcached_address.value\n\t\ttimeout - = argument.memcached_timeout.value\n\t}\n\n\t/***************************************************************\n\t* + \"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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, + {\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 = 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_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* + = 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" - mysql.alloy: "/*\nModule Components: component_mysql\n*/\n\ndeclare \"component_mysql\" - {\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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/mysql\"\n\t}\n\n\targument \"namespace\" - {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-mysql\"\n\t}\n\n\targument - \"instance_name\" {\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\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 - \"mysql\" {\n\t\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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 = 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_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 \"component_redis_exporter\" - {\n\n\t/*****************************************************************\n\t* +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(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/redis_exporter\"\n\t}\n\n\targument - \"namespace\" {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-redis\"\n\t}\n\n\targument - \"instance_name\" {\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\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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[\"redis-addr\"])\n\t\tredis_password - = nonsensitive(remote.kubernetes.secret.redis.data[\"redis-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.memcached.integrations_redis_exporter.targets\n\n\t\trule - {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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" + \"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-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 namespace: monitoring-system --- apiVersion: v1 @@ -439,48 +381,59 @@ data: 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\tdefault = \"alloy-integrations\"\n\t}\n\n\targument - \"namespace\" {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional - = true\n\t\tdefault = \"default\"\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\t// - integrations components local files\n\timport.file \"integrations\" {\n\t\tfilename - = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") + \"/kubernetes/integrations\"\n\t}\n\n\t// - // integrations components kubernetes configmap\n\t// remote.kubernetes.configmap - \"integrations\" {\n\t// \tname = argument.name.value\n\t// \tnamespace = - argument.namespace.value\n\t// }\n\t// import.string \"integrations\" {\n\t// - \tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t// - }\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\tintegrations.component_memcached - \"primary\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tinstance_name - \ = \"primary\"\n\t\tmemcached_address = \"memcached.memcached-system.svc.cluster.local:11211\"\n\t\tmemcached_timeout - = \"5s\"\n\t}\n\n\t// /*****************************************************************\n\t// + \"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// - integrations.component_mysql \"primary\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tinstance_name = \"primary\"\n\t// \tname = \"alloy-integrations-mysql\"\n\t// - \tnamespace = \"monitoring-system\"\n\t// }\n}\n" + 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* ARGUMENTS\n\t*****************************************************************/\n\targument \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape PodMonitors\n\t*****************************************************************/\n\tprometheus.operator.podmonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression {\n\t\t// \t\tkey - \ = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues = [\"team-infra\"]\n\t\t// - \t}\n\t\t// }\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression + {\n\t\t// \t\tkey = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues + \ = [\"team-infra\"]\n\t\t// \t}\n\t\t// }\n\t}\n}\n" servicemonitors-scrape.alloy: "/*\nModule Components: servicemonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.servicemonitors\n*/\n\ndeclare \"servicemonitors_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\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape ServiceMonitors\n\t*****************************************************************/\n\tprometheus.operator.servicemonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc namespace: monitoring-system --- apiVersion: v1 @@ -1020,31 +973,21 @@ metadata: --- apiVersion: v1 data: - memcached-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + ALLOY_LOG_LEVEL: d2Fybg== kind: Secret metadata: - name: alloy-integrations-memcached + name: alloy-env-f7k229g955 namespace: monitoring-system type: Opaque --- apiVersion: v1 data: - mysql-host: bXlzcWwubXlzcWwtc3lzdGVtLnN2Yy5jbHVzdGVyLmxvY2Fs - mysql-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= - mysql-username: bGd0bXA= + instance-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + instance-name: cHJpbWFyeQ== + instance-timeout: NXM= kind: Secret metadata: - name: alloy-integrations-mysql - namespace: monitoring-system -type: Opaque ---- -apiVersion: v1 -data: - redis-addr: cmVkaXMtbWFzdGVyLnJlZGlzLXN5c3RlbS5zdmMuY2x1c3Rlci5sb2NhbDo2Mzc5 - redis-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= -kind: Secret -metadata: - name: alloy-integrations-redis + name: alloy-integrations-memcached namespace: monitoring-system type: Opaque --- @@ -2379,7 +2322,7 @@ spec: fieldPath: spec.nodeName envFrom: - secretRef: - name: alloy-env + name: alloy-env-f7k229g955 optional: true image: docker.io/grafana/alloy:v1.0.0 imagePullPolicy: IfNotPresent @@ -2428,10 +2371,10 @@ spec: name: alloy-config-m6chdfm49m name: config - configMap: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 name: modules-kubernetes-integrations - configMap: name: alloy-modules-kubernetes-logs-d7c756mt2f diff --git a/kubernetes/microservices-mode/profiles/k8s-all-in-one.yaml b/kubernetes/microservices-mode/profiles/k8s-all-in-one.yaml index dd87416a..72ef2f4a 100644 --- a/kubernetes/microservices-mode/profiles/k8s-all-in-one.yaml +++ b/kubernetes/microservices-mode/profiles/k8s-all-in-one.yaml @@ -242,130 +242,72 @@ metadata: --- 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" + 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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/memcached\"\n\t}\n\n\targument - \"memcached_address\" {\n\t\toptional = true\n\t\tdefault = \"memcached:11211\"\n\t}\n\n\targument - \"memcached_timeout\" {\n\t\toptional = true\n\t\tdefault = \"5s\"\n\t}\n\n\targument - \"instance_name\" {\n\t\tcomment = \"instance of the Memcached\"\n\t\toptional + 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\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\t/***************************************************************\n\t* + (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 = argument.memcached_address.value\n\t\ttimeout - = argument.memcached_timeout.value\n\t}\n\n\t/***************************************************************\n\t* + \"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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, + {\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 = 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_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* + = 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" - mysql.alloy: "/*\nModule Components: component_mysql\n*/\n\ndeclare \"component_mysql\" - {\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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/mysql\"\n\t}\n\n\targument \"namespace\" - {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-mysql\"\n\t}\n\n\targument - \"instance_name\" {\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\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 - \"mysql\" {\n\t\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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 = 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_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 \"component_redis_exporter\" - {\n\n\t/*****************************************************************\n\t* +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(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/redis_exporter\"\n\t}\n\n\targument - \"namespace\" {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-redis\"\n\t}\n\n\targument - \"instance_name\" {\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\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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[\"redis-addr\"])\n\t\tredis_password - = nonsensitive(remote.kubernetes.secret.redis.data[\"redis-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.memcached.integrations_redis_exporter.targets\n\n\t\trule - {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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" + \"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-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 namespace: monitoring-system --- apiVersion: v1 @@ -501,48 +443,59 @@ data: 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\tdefault = \"alloy-integrations\"\n\t}\n\n\targument - \"namespace\" {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional - = true\n\t\tdefault = \"default\"\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\t// - integrations components local files\n\timport.file \"integrations\" {\n\t\tfilename - = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") + \"/kubernetes/integrations\"\n\t}\n\n\t// - // integrations components kubernetes configmap\n\t// remote.kubernetes.configmap - \"integrations\" {\n\t// \tname = argument.name.value\n\t// \tnamespace = - argument.namespace.value\n\t// }\n\t// import.string \"integrations\" {\n\t// - \tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t// - }\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\tintegrations.component_memcached - \"primary\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tinstance_name - \ = \"primary\"\n\t\tmemcached_address = \"memcached.memcached-system.svc.cluster.local:11211\"\n\t\tmemcached_timeout - = \"5s\"\n\t}\n\n\t// /*****************************************************************\n\t// + \"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// - integrations.component_mysql \"primary\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tinstance_name = \"primary\"\n\t// \tname = \"alloy-integrations-mysql\"\n\t// - \tnamespace = \"monitoring-system\"\n\t// }\n}\n" + 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* ARGUMENTS\n\t*****************************************************************/\n\targument \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape PodMonitors\n\t*****************************************************************/\n\tprometheus.operator.podmonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression {\n\t\t// \t\tkey - \ = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues = [\"team-infra\"]\n\t\t// - \t}\n\t\t// }\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression + {\n\t\t// \t\tkey = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues + \ = [\"team-infra\"]\n\t\t// \t}\n\t\t// }\n\t}\n}\n" servicemonitors-scrape.alloy: "/*\nModule Components: servicemonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.servicemonitors\n*/\n\ndeclare \"servicemonitors_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\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape ServiceMonitors\n\t*****************************************************************/\n\tprometheus.operator.servicemonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc namespace: monitoring-system --- apiVersion: v1 @@ -1057,31 +1010,21 @@ metadata: --- apiVersion: v1 data: - memcached-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + ALLOY_LOG_LEVEL: d2Fybg== kind: Secret metadata: - name: alloy-integrations-memcached + name: alloy-env-f7k229g955 namespace: monitoring-system type: Opaque --- apiVersion: v1 data: - mysql-host: bXlzcWwubXlzcWwtc3lzdGVtLnN2Yy5jbHVzdGVyLmxvY2Fs - mysql-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= - mysql-username: bGd0bXA= + instance-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + instance-name: cHJpbWFyeQ== + instance-timeout: NXM= kind: Secret metadata: - name: alloy-integrations-mysql - namespace: monitoring-system -type: Opaque ---- -apiVersion: v1 -data: - redis-addr: cmVkaXMtbWFzdGVyLnJlZGlzLXN5c3RlbS5zdmMuY2x1c3Rlci5sb2NhbDo2Mzc5 - redis-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= -kind: Secret -metadata: - name: alloy-integrations-redis + name: alloy-integrations-memcached namespace: monitoring-system type: Opaque --- @@ -2113,7 +2056,7 @@ spec: fieldPath: spec.nodeName envFrom: - secretRef: - name: alloy-env + name: alloy-env-f7k229g955 optional: true image: docker.io/grafana/alloy:v1.0.0 imagePullPolicy: IfNotPresent @@ -2162,10 +2105,10 @@ spec: name: alloy-config-5k62427t46 name: config - configMap: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 name: modules-kubernetes-integrations - configMap: name: alloy-modules-kubernetes-logs-d7c756mt2f diff --git a/kubernetes/microservices-mode/traces/k8s-all-in-one.yaml b/kubernetes/microservices-mode/traces/k8s-all-in-one.yaml index ce9c226b..f97ccdae 100644 --- a/kubernetes/microservices-mode/traces/k8s-all-in-one.yaml +++ b/kubernetes/microservices-mode/traces/k8s-all-in-one.yaml @@ -254,130 +254,72 @@ metadata: --- 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" + 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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/memcached\"\n\t}\n\n\targument - \"memcached_address\" {\n\t\toptional = true\n\t\tdefault = \"memcached:11211\"\n\t}\n\n\targument - \"memcached_timeout\" {\n\t\toptional = true\n\t\tdefault = \"5s\"\n\t}\n\n\targument - \"instance_name\" {\n\t\tcomment = \"instance of the Memcached\"\n\t\toptional + 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\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\t/***************************************************************\n\t* + (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 = argument.memcached_address.value\n\t\ttimeout - = argument.memcached_timeout.value\n\t}\n\n\t/***************************************************************\n\t* + \"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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, + {\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 = 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_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* + = 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" - mysql.alloy: "/*\nModule Components: component_mysql\n*/\n\ndeclare \"component_mysql\" - {\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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/mysql\"\n\t}\n\n\targument \"namespace\" - {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-mysql\"\n\t}\n\n\targument - \"instance_name\" {\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\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 - \"mysql\" {\n\t\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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 = 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_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 \"component_redis_exporter\" - {\n\n\t/*****************************************************************\n\t* +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(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/redis_exporter\"\n\t}\n\n\targument - \"namespace\" {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-redis\"\n\t}\n\n\targument - \"instance_name\" {\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\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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[\"redis-addr\"])\n\t\tredis_password - = nonsensitive(remote.kubernetes.secret.redis.data[\"redis-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.memcached.integrations_redis_exporter.targets\n\n\t\trule - {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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" + \"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-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 namespace: monitoring-system --- apiVersion: v1 @@ -513,48 +455,59 @@ data: 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\tdefault = \"alloy-integrations\"\n\t}\n\n\targument - \"namespace\" {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional - = true\n\t\tdefault = \"default\"\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\t// - integrations components local files\n\timport.file \"integrations\" {\n\t\tfilename - = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") + \"/kubernetes/integrations\"\n\t}\n\n\t// - // integrations components kubernetes configmap\n\t// remote.kubernetes.configmap - \"integrations\" {\n\t// \tname = argument.name.value\n\t// \tnamespace = - argument.namespace.value\n\t// }\n\t// import.string \"integrations\" {\n\t// - \tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t// - }\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\tintegrations.component_memcached - \"primary\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tinstance_name - \ = \"primary\"\n\t\tmemcached_address = \"memcached.memcached-system.svc.cluster.local:11211\"\n\t\tmemcached_timeout - = \"5s\"\n\t}\n\n\t// /*****************************************************************\n\t// + \"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// - integrations.component_mysql \"primary\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tinstance_name = \"primary\"\n\t// \tname = \"alloy-integrations-mysql\"\n\t// - \tnamespace = \"monitoring-system\"\n\t// }\n}\n" + 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* ARGUMENTS\n\t*****************************************************************/\n\targument \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape PodMonitors\n\t*****************************************************************/\n\tprometheus.operator.podmonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression {\n\t\t// \t\tkey - \ = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues = [\"team-infra\"]\n\t\t// - \t}\n\t\t// }\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression + {\n\t\t// \t\tkey = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues + \ = [\"team-infra\"]\n\t\t// \t}\n\t\t// }\n\t}\n}\n" servicemonitors-scrape.alloy: "/*\nModule Components: servicemonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.servicemonitors\n*/\n\ndeclare \"servicemonitors_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\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape ServiceMonitors\n\t*****************************************************************/\n\tprometheus.operator.servicemonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc namespace: monitoring-system --- apiVersion: v1 @@ -1167,31 +1120,21 @@ metadata: --- apiVersion: v1 data: - memcached-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + ALLOY_LOG_LEVEL: d2Fybg== kind: Secret metadata: - name: alloy-integrations-memcached + name: alloy-env-f7k229g955 namespace: monitoring-system type: Opaque --- apiVersion: v1 data: - mysql-host: bXlzcWwubXlzcWwtc3lzdGVtLnN2Yy5jbHVzdGVyLmxvY2Fs - mysql-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= - mysql-username: bGd0bXA= + instance-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + instance-name: cHJpbWFyeQ== + instance-timeout: NXM= kind: Secret metadata: - name: alloy-integrations-mysql - namespace: monitoring-system -type: Opaque ---- -apiVersion: v1 -data: - redis-addr: cmVkaXMtbWFzdGVyLnJlZGlzLXN5c3RlbS5zdmMuY2x1c3Rlci5sb2NhbDo2Mzc5 - redis-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= -kind: Secret -metadata: - name: alloy-integrations-redis + name: alloy-integrations-memcached namespace: monitoring-system type: Opaque --- @@ -2458,7 +2401,7 @@ spec: fieldPath: spec.nodeName envFrom: - secretRef: - name: alloy-env + name: alloy-env-f7k229g955 optional: true image: docker.io/grafana/alloy:v1.0.0 imagePullPolicy: IfNotPresent @@ -2507,10 +2450,10 @@ spec: name: alloy-config-gt2k68744f name: config - configMap: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 name: modules-kubernetes-integrations - configMap: name: alloy-modules-kubernetes-logs-d7c756mt2f diff --git a/kubernetes/microservices-mode/traces/kustomization.yaml b/kubernetes/microservices-mode/traces/kustomization.yaml index cbe4ac53..4d9427f5 100644 --- a/kubernetes/microservices-mode/traces/kustomization.yaml +++ b/kubernetes/microservices-mode/traces/kustomization.yaml @@ -30,7 +30,7 @@ configMapGenerator: namespace: monitoring-system behavior: replace files: - - config.alloy=configs/traces.alloy + - config.alloy=traces.alloy - name: tempo-distributed-config namespace: tracing-system diff --git a/kubernetes/microservices-mode/traces/configs/traces.alloy b/kubernetes/microservices-mode/traces/traces.alloy similarity index 100% rename from kubernetes/microservices-mode/traces/configs/traces.alloy rename to kubernetes/microservices-mode/traces/traces.alloy diff --git a/kubernetes/monolithic-mode/all-in-one/configs/all-in-one.alloy b/kubernetes/monolithic-mode/all-in-one/all-in-one.alloy similarity index 100% rename from kubernetes/monolithic-mode/all-in-one/configs/all-in-one.alloy rename to kubernetes/monolithic-mode/all-in-one/all-in-one.alloy 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 a5c6e8a6..fecf6fd1 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 @@ -660,130 +660,72 @@ metadata: --- 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" + 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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/memcached\"\n\t}\n\n\targument - \"memcached_address\" {\n\t\toptional = true\n\t\tdefault = \"memcached:11211\"\n\t}\n\n\targument - \"memcached_timeout\" {\n\t\toptional = true\n\t\tdefault = \"5s\"\n\t}\n\n\targument - \"instance_name\" {\n\t\tcomment = \"instance of the Memcached\"\n\t\toptional + 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\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\t/***************************************************************\n\t* + (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 = argument.memcached_address.value\n\t\ttimeout - = argument.memcached_timeout.value\n\t}\n\n\t/***************************************************************\n\t* + \"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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, + {\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 = 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_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* + = 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" - mysql.alloy: "/*\nModule Components: component_mysql\n*/\n\ndeclare \"component_mysql\" - {\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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/mysql\"\n\t}\n\n\targument \"namespace\" - {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-mysql\"\n\t}\n\n\targument - \"instance_name\" {\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\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 - \"mysql\" {\n\t\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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 = 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_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 \"component_redis_exporter\" - {\n\n\t/*****************************************************************\n\t* +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(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/redis_exporter\"\n\t}\n\n\targument - \"namespace\" {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-redis\"\n\t}\n\n\targument - \"instance_name\" {\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\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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[\"redis-addr\"])\n\t\tredis_password - = nonsensitive(remote.kubernetes.secret.redis.data[\"redis-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.memcached.integrations_redis_exporter.targets\n\n\t\trule - {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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" + \"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-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 namespace: monitoring-system --- apiVersion: v1 @@ -919,48 +861,59 @@ data: 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\tdefault = \"alloy-integrations\"\n\t}\n\n\targument - \"namespace\" {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional - = true\n\t\tdefault = \"default\"\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\t// - integrations components local files\n\timport.file \"integrations\" {\n\t\tfilename - = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") + \"/kubernetes/integrations\"\n\t}\n\n\t// - // integrations components kubernetes configmap\n\t// remote.kubernetes.configmap - \"integrations\" {\n\t// \tname = argument.name.value\n\t// \tnamespace = - argument.namespace.value\n\t// }\n\t// import.string \"integrations\" {\n\t// - \tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t// - }\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\tintegrations.component_memcached - \"primary\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tinstance_name - \ = \"primary\"\n\t\tmemcached_address = \"memcached.memcached-system.svc.cluster.local:11211\"\n\t\tmemcached_timeout - = \"5s\"\n\t}\n\n\t// /*****************************************************************\n\t// + \"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// - integrations.component_mysql \"primary\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tinstance_name = \"primary\"\n\t// \tname = \"alloy-integrations-mysql\"\n\t// - \tnamespace = \"monitoring-system\"\n\t// }\n}\n" + 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* ARGUMENTS\n\t*****************************************************************/\n\targument \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape PodMonitors\n\t*****************************************************************/\n\tprometheus.operator.podmonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression {\n\t\t// \t\tkey - \ = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues = [\"team-infra\"]\n\t\t// - \t}\n\t\t// }\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression + {\n\t\t// \t\tkey = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues + \ = [\"team-infra\"]\n\t\t// \t}\n\t\t// }\n\t}\n}\n" servicemonitors-scrape.alloy: "/*\nModule Components: servicemonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.servicemonitors\n*/\n\ndeclare \"servicemonitors_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\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape ServiceMonitors\n\t*****************************************************************/\n\tprometheus.operator.servicemonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc namespace: monitoring-system --- apiVersion: v1 @@ -1622,31 +1575,21 @@ type: Opaque --- apiVersion: v1 data: - memcached-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + ALLOY_LOG_LEVEL: d2Fybg== kind: Secret metadata: - name: alloy-integrations-memcached + name: alloy-env-f7k229g955 namespace: monitoring-system type: Opaque --- apiVersion: v1 data: - mysql-host: bXlzcWwubXlzcWwtc3lzdGVtLnN2Yy5jbHVzdGVyLmxvY2Fs - mysql-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= - mysql-username: bGd0bXA= + instance-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + instance-name: cHJpbWFyeQ== + instance-timeout: NXM= kind: Secret metadata: - name: alloy-integrations-mysql - namespace: monitoring-system -type: Opaque ---- -apiVersion: v1 -data: - redis-addr: cmVkaXMtbWFzdGVyLnJlZGlzLXN5c3RlbS5zdmMuY2x1c3Rlci5sb2NhbDo2Mzc5 - redis-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= -kind: Secret -metadata: - name: alloy-integrations-redis + name: alloy-integrations-memcached namespace: monitoring-system type: Opaque --- @@ -2291,7 +2234,7 @@ spec: fieldPath: spec.nodeName envFrom: - secretRef: - name: alloy-env + name: alloy-env-f7k229g955 optional: true image: docker.io/grafana/alloy:v1.0.0 imagePullPolicy: IfNotPresent @@ -2340,10 +2283,10 @@ spec: name: alloy-config-6b695gbdm6 name: config - configMap: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 name: modules-kubernetes-integrations - configMap: name: alloy-modules-kubernetes-logs-d7c756mt2f diff --git a/kubernetes/monolithic-mode/all-in-one/kustomization.yaml b/kubernetes/monolithic-mode/all-in-one/kustomization.yaml index eae2817b..e9e9e651 100644 --- a/kubernetes/monolithic-mode/all-in-one/kustomization.yaml +++ b/kubernetes/monolithic-mode/all-in-one/kustomization.yaml @@ -20,7 +20,7 @@ configMapGenerator: namespace: monitoring-system behavior: replace files: - - config.alloy=configs/all-in-one.alloy + - config.alloy=all-in-one.alloy # Update LGTMP endpoint in gateway - name: nginx-templates diff --git a/kubernetes/monolithic-mode/logs/k8s-all-in-one.yaml b/kubernetes/monolithic-mode/logs/k8s-all-in-one.yaml index 01353924..00aed586 100644 --- a/kubernetes/monolithic-mode/logs/k8s-all-in-one.yaml +++ b/kubernetes/monolithic-mode/logs/k8s-all-in-one.yaml @@ -373,140 +373,83 @@ data: * 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 + = [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" kind: ConfigMap metadata: - name: alloy-config-8t9d8htff7 + name: alloy-config-bdt752b5d5 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" + 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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/memcached\"\n\t}\n\n\targument - \"memcached_address\" {\n\t\toptional = true\n\t\tdefault = \"memcached:11211\"\n\t}\n\n\targument - \"memcached_timeout\" {\n\t\toptional = true\n\t\tdefault = \"5s\"\n\t}\n\n\targument - \"instance_name\" {\n\t\tcomment = \"instance of the Memcached\"\n\t\toptional + 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\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\t/***************************************************************\n\t* + (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 = argument.memcached_address.value\n\t\ttimeout - = argument.memcached_timeout.value\n\t}\n\n\t/***************************************************************\n\t* + \"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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, + {\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 = 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_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* + = 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" - mysql.alloy: "/*\nModule Components: component_mysql\n*/\n\ndeclare \"component_mysql\" - {\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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/mysql\"\n\t}\n\n\targument \"namespace\" - {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-mysql\"\n\t}\n\n\targument - \"instance_name\" {\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\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 - \"mysql\" {\n\t\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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 = 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_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 \"component_redis_exporter\" - {\n\n\t/*****************************************************************\n\t* +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(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/redis_exporter\"\n\t}\n\n\targument - \"namespace\" {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-redis\"\n\t}\n\n\targument - \"instance_name\" {\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\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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[\"redis-addr\"])\n\t\tredis_password - = nonsensitive(remote.kubernetes.secret.redis.data[\"redis-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.memcached.integrations_redis_exporter.targets\n\n\t\trule - {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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" + \"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-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 namespace: monitoring-system --- apiVersion: v1 @@ -642,48 +585,59 @@ data: 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\tdefault = \"alloy-integrations\"\n\t}\n\n\targument - \"namespace\" {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional - = true\n\t\tdefault = \"default\"\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\t// - integrations components local files\n\timport.file \"integrations\" {\n\t\tfilename - = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") + \"/kubernetes/integrations\"\n\t}\n\n\t// - // integrations components kubernetes configmap\n\t// remote.kubernetes.configmap - \"integrations\" {\n\t// \tname = argument.name.value\n\t// \tnamespace = - argument.namespace.value\n\t// }\n\t// import.string \"integrations\" {\n\t// - \tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t// - }\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\tintegrations.component_memcached - \"primary\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tinstance_name - \ = \"primary\"\n\t\tmemcached_address = \"memcached.memcached-system.svc.cluster.local:11211\"\n\t\tmemcached_timeout - = \"5s\"\n\t}\n\n\t// /*****************************************************************\n\t// + \"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// - integrations.component_mysql \"primary\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tinstance_name = \"primary\"\n\t// \tname = \"alloy-integrations-mysql\"\n\t// - \tnamespace = \"monitoring-system\"\n\t// }\n}\n" + 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* ARGUMENTS\n\t*****************************************************************/\n\targument \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape PodMonitors\n\t*****************************************************************/\n\tprometheus.operator.podmonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression {\n\t\t// \t\tkey - \ = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues = [\"team-infra\"]\n\t\t// - \t}\n\t\t// }\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression + {\n\t\t// \t\tkey = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues + \ = [\"team-infra\"]\n\t\t// \t}\n\t\t// }\n\t}\n}\n" servicemonitors-scrape.alloy: "/*\nModule Components: servicemonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.servicemonitors\n*/\n\ndeclare \"servicemonitors_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\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape ServiceMonitors\n\t*****************************************************************/\n\tprometheus.operator.servicemonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc namespace: monitoring-system --- apiVersion: v1 @@ -1164,31 +1118,21 @@ type: Opaque --- apiVersion: v1 data: - memcached-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + ALLOY_LOG_LEVEL: d2Fybg== kind: Secret metadata: - name: alloy-integrations-memcached + name: alloy-env-f7k229g955 namespace: monitoring-system type: Opaque --- apiVersion: v1 data: - mysql-host: bXlzcWwubXlzcWwtc3lzdGVtLnN2Yy5jbHVzdGVyLmxvY2Fs - mysql-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= - mysql-username: bGd0bXA= + instance-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + instance-name: cHJpbWFyeQ== + instance-timeout: NXM= kind: Secret metadata: - name: alloy-integrations-mysql - namespace: monitoring-system -type: Opaque ---- -apiVersion: v1 -data: - redis-addr: cmVkaXMtbWFzdGVyLnJlZGlzLXN5c3RlbS5zdmMuY2x1c3Rlci5sb2NhbDo2Mzc5 - redis-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= -kind: Secret -metadata: - name: alloy-integrations-redis + name: alloy-integrations-memcached namespace: monitoring-system type: Opaque --- @@ -1672,7 +1616,7 @@ spec: fieldPath: spec.nodeName envFrom: - secretRef: - name: alloy-env + name: alloy-env-f7k229g955 optional: true image: docker.io/grafana/alloy:v1.0.0 imagePullPolicy: IfNotPresent @@ -1718,13 +1662,13 @@ spec: serviceAccountName: alloy volumes: - configMap: - name: alloy-config-8t9d8htff7 + name: alloy-config-bdt752b5d5 name: config - configMap: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 name: modules-kubernetes-integrations - configMap: name: alloy-modules-kubernetes-logs-d7c756mt2f diff --git a/kubernetes/monolithic-mode/logs/logs.alloy b/kubernetes/monolithic-mode/logs/logs.alloy index 1915e1ac..a3883dad 100644 --- a/kubernetes/monolithic-mode/logs/logs.alloy +++ b/kubernetes/monolithic-mode/logs/logs.alloy @@ -43,6 +43,9 @@ import.file "metrics" { metrics.integrations_scrape "kubernetes" { forward_to = [provider.self_hosted_stack.kubernetes.metrics_receiver] + + namespace = "monitoring-system" + name = "alloy-integrations" } metrics.podmonitors_scrape "kubernetes" { diff --git a/kubernetes/monolithic-mode/metrics/k8s-all-in-one.yaml b/kubernetes/monolithic-mode/metrics/k8s-all-in-one.yaml index 457a5979..96e28579 100644 --- a/kubernetes/monolithic-mode/metrics/k8s-all-in-one.yaml +++ b/kubernetes/monolithic-mode/metrics/k8s-all-in-one.yaml @@ -168,130 +168,72 @@ metadata: --- 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" + 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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/memcached\"\n\t}\n\n\targument - \"memcached_address\" {\n\t\toptional = true\n\t\tdefault = \"memcached:11211\"\n\t}\n\n\targument - \"memcached_timeout\" {\n\t\toptional = true\n\t\tdefault = \"5s\"\n\t}\n\n\targument - \"instance_name\" {\n\t\tcomment = \"instance of the Memcached\"\n\t\toptional + 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\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\t/***************************************************************\n\t* + (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 = argument.memcached_address.value\n\t\ttimeout - = argument.memcached_timeout.value\n\t}\n\n\t/***************************************************************\n\t* + \"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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, + {\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 = 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_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* + = 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" - mysql.alloy: "/*\nModule Components: component_mysql\n*/\n\ndeclare \"component_mysql\" - {\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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/mysql\"\n\t}\n\n\targument \"namespace\" - {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-mysql\"\n\t}\n\n\targument - \"instance_name\" {\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\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 - \"mysql\" {\n\t\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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 = 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_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 \"component_redis_exporter\" - {\n\n\t/*****************************************************************\n\t* +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(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/redis_exporter\"\n\t}\n\n\targument - \"namespace\" {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-redis\"\n\t}\n\n\targument - \"instance_name\" {\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\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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[\"redis-addr\"])\n\t\tredis_password - = nonsensitive(remote.kubernetes.secret.redis.data[\"redis-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.memcached.integrations_redis_exporter.targets\n\n\t\trule - {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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" + \"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-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 namespace: monitoring-system --- apiVersion: v1 @@ -427,48 +369,59 @@ data: 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\tdefault = \"alloy-integrations\"\n\t}\n\n\targument - \"namespace\" {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional - = true\n\t\tdefault = \"default\"\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\t// - integrations components local files\n\timport.file \"integrations\" {\n\t\tfilename - = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") + \"/kubernetes/integrations\"\n\t}\n\n\t// - // integrations components kubernetes configmap\n\t// remote.kubernetes.configmap - \"integrations\" {\n\t// \tname = argument.name.value\n\t// \tnamespace = - argument.namespace.value\n\t// }\n\t// import.string \"integrations\" {\n\t// - \tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t// - }\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\tintegrations.component_memcached - \"primary\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tinstance_name - \ = \"primary\"\n\t\tmemcached_address = \"memcached.memcached-system.svc.cluster.local:11211\"\n\t\tmemcached_timeout - = \"5s\"\n\t}\n\n\t// /*****************************************************************\n\t// + \"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// - integrations.component_mysql \"primary\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tinstance_name = \"primary\"\n\t// \tname = \"alloy-integrations-mysql\"\n\t// - \tnamespace = \"monitoring-system\"\n\t// }\n}\n" + 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* ARGUMENTS\n\t*****************************************************************/\n\targument \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape PodMonitors\n\t*****************************************************************/\n\tprometheus.operator.podmonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression {\n\t\t// \t\tkey - \ = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues = [\"team-infra\"]\n\t\t// - \t}\n\t\t// }\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression + {\n\t\t// \t\tkey = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues + \ = [\"team-infra\"]\n\t\t// \t}\n\t\t// }\n\t}\n}\n" servicemonitors-scrape.alloy: "/*\nModule Components: servicemonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.servicemonitors\n*/\n\ndeclare \"servicemonitors_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\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape ServiceMonitors\n\t*****************************************************************/\n\tprometheus.operator.servicemonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc namespace: monitoring-system --- apiVersion: v1 @@ -934,31 +887,21 @@ metadata: --- apiVersion: v1 data: - memcached-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + ALLOY_LOG_LEVEL: d2Fybg== kind: Secret metadata: - name: alloy-integrations-memcached + name: alloy-env-f7k229g955 namespace: monitoring-system type: Opaque --- apiVersion: v1 data: - mysql-host: bXlzcWwubXlzcWwtc3lzdGVtLnN2Yy5jbHVzdGVyLmxvY2Fs - mysql-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= - mysql-username: bGd0bXA= + instance-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + instance-name: cHJpbWFyeQ== + instance-timeout: NXM= kind: Secret metadata: - name: alloy-integrations-mysql - namespace: monitoring-system -type: Opaque ---- -apiVersion: v1 -data: - redis-addr: cmVkaXMtbWFzdGVyLnJlZGlzLXN5c3RlbS5zdmMuY2x1c3Rlci5sb2NhbDo2Mzc5 - redis-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= -kind: Secret -metadata: - name: alloy-integrations-redis + name: alloy-integrations-memcached namespace: monitoring-system type: Opaque --- @@ -1250,7 +1193,7 @@ spec: fieldPath: spec.nodeName envFrom: - secretRef: - name: alloy-env + name: alloy-env-f7k229g955 optional: true image: docker.io/grafana/alloy:v1.0.0 imagePullPolicy: IfNotPresent @@ -1299,10 +1242,10 @@ spec: name: alloy-config-m6chdfm49m name: config - configMap: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 name: modules-kubernetes-integrations - configMap: name: alloy-modules-kubernetes-logs-d7c756mt2f diff --git a/kubernetes/monolithic-mode/profiles/k8s-all-in-one.yaml b/kubernetes/monolithic-mode/profiles/k8s-all-in-one.yaml index 0e48d50b..eeb5c528 100644 --- a/kubernetes/monolithic-mode/profiles/k8s-all-in-one.yaml +++ b/kubernetes/monolithic-mode/profiles/k8s-all-in-one.yaml @@ -233,130 +233,72 @@ metadata: --- 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" + 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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/memcached\"\n\t}\n\n\targument - \"memcached_address\" {\n\t\toptional = true\n\t\tdefault = \"memcached:11211\"\n\t}\n\n\targument - \"memcached_timeout\" {\n\t\toptional = true\n\t\tdefault = \"5s\"\n\t}\n\n\targument - \"instance_name\" {\n\t\tcomment = \"instance of the Memcached\"\n\t\toptional + 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\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\t/***************************************************************\n\t* + (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 = argument.memcached_address.value\n\t\ttimeout - = argument.memcached_timeout.value\n\t}\n\n\t/***************************************************************\n\t* + \"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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, + {\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 = 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_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* + = 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" - mysql.alloy: "/*\nModule Components: component_mysql\n*/\n\ndeclare \"component_mysql\" - {\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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/mysql\"\n\t}\n\n\targument \"namespace\" - {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-mysql\"\n\t}\n\n\targument - \"instance_name\" {\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\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 - \"mysql\" {\n\t\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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 = 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_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 \"component_redis_exporter\" - {\n\n\t/*****************************************************************\n\t* +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(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/redis_exporter\"\n\t}\n\n\targument - \"namespace\" {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-redis\"\n\t}\n\n\targument - \"instance_name\" {\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\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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[\"redis-addr\"])\n\t\tredis_password - = nonsensitive(remote.kubernetes.secret.redis.data[\"redis-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.memcached.integrations_redis_exporter.targets\n\n\t\trule - {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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" + \"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-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 namespace: monitoring-system --- apiVersion: v1 @@ -492,48 +434,59 @@ data: 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\tdefault = \"alloy-integrations\"\n\t}\n\n\targument - \"namespace\" {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional - = true\n\t\tdefault = \"default\"\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\t// - integrations components local files\n\timport.file \"integrations\" {\n\t\tfilename - = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") + \"/kubernetes/integrations\"\n\t}\n\n\t// - // integrations components kubernetes configmap\n\t// remote.kubernetes.configmap - \"integrations\" {\n\t// \tname = argument.name.value\n\t// \tnamespace = - argument.namespace.value\n\t// }\n\t// import.string \"integrations\" {\n\t// - \tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t// - }\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\tintegrations.component_memcached - \"primary\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tinstance_name - \ = \"primary\"\n\t\tmemcached_address = \"memcached.memcached-system.svc.cluster.local:11211\"\n\t\tmemcached_timeout - = \"5s\"\n\t}\n\n\t// /*****************************************************************\n\t// + \"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// - integrations.component_mysql \"primary\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tinstance_name = \"primary\"\n\t// \tname = \"alloy-integrations-mysql\"\n\t// - \tnamespace = \"monitoring-system\"\n\t// }\n}\n" + 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* ARGUMENTS\n\t*****************************************************************/\n\targument \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape PodMonitors\n\t*****************************************************************/\n\tprometheus.operator.podmonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression {\n\t\t// \t\tkey - \ = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues = [\"team-infra\"]\n\t\t// - \t}\n\t\t// }\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression + {\n\t\t// \t\tkey = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues + \ = [\"team-infra\"]\n\t\t// \t}\n\t\t// }\n\t}\n}\n" servicemonitors-scrape.alloy: "/*\nModule Components: servicemonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.servicemonitors\n*/\n\ndeclare \"servicemonitors_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\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape ServiceMonitors\n\t*****************************************************************/\n\tprometheus.operator.servicemonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc namespace: monitoring-system --- apiVersion: v1 @@ -1047,31 +1000,21 @@ metadata: --- apiVersion: v1 data: - memcached-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + ALLOY_LOG_LEVEL: d2Fybg== kind: Secret metadata: - name: alloy-integrations-memcached + name: alloy-env-f7k229g955 namespace: monitoring-system type: Opaque --- apiVersion: v1 data: - mysql-host: bXlzcWwubXlzcWwtc3lzdGVtLnN2Yy5jbHVzdGVyLmxvY2Fs - mysql-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= - mysql-username: bGd0bXA= + instance-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + instance-name: cHJpbWFyeQ== + instance-timeout: NXM= kind: Secret metadata: - name: alloy-integrations-mysql - namespace: monitoring-system -type: Opaque ---- -apiVersion: v1 -data: - redis-addr: cmVkaXMtbWFzdGVyLnJlZGlzLXN5c3RlbS5zdmMuY2x1c3Rlci5sb2NhbDo2Mzc5 - redis-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= -kind: Secret -metadata: - name: alloy-integrations-redis + name: alloy-integrations-memcached namespace: monitoring-system type: Opaque --- @@ -1446,7 +1389,7 @@ spec: fieldPath: spec.nodeName envFrom: - secretRef: - name: alloy-env + name: alloy-env-f7k229g955 optional: true image: docker.io/grafana/alloy:v1.0.0 imagePullPolicy: IfNotPresent @@ -1495,10 +1438,10 @@ spec: name: alloy-config-5k62427t46 name: config - configMap: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 name: modules-kubernetes-integrations - configMap: name: alloy-modules-kubernetes-logs-d7c756mt2f diff --git a/kubernetes/monolithic-mode/traces/k8s-all-in-one.yaml b/kubernetes/monolithic-mode/traces/k8s-all-in-one.yaml index e65d0464..13ec029c 100644 --- a/kubernetes/monolithic-mode/traces/k8s-all-in-one.yaml +++ b/kubernetes/monolithic-mode/traces/k8s-all-in-one.yaml @@ -243,130 +243,72 @@ metadata: --- 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" + 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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/memcached\"\n\t}\n\n\targument - \"memcached_address\" {\n\t\toptional = true\n\t\tdefault = \"memcached:11211\"\n\t}\n\n\targument - \"memcached_timeout\" {\n\t\toptional = true\n\t\tdefault = \"5s\"\n\t}\n\n\targument - \"instance_name\" {\n\t\tcomment = \"instance of the Memcached\"\n\t\toptional + 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\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\t/***************************************************************\n\t* + (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 = argument.memcached_address.value\n\t\ttimeout - = argument.memcached_timeout.value\n\t}\n\n\t/***************************************************************\n\t* + \"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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, + {\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 = 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_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* + = 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" - mysql.alloy: "/*\nModule Components: component_mysql\n*/\n\ndeclare \"component_mysql\" - {\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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/mysql\"\n\t}\n\n\targument \"namespace\" - {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-mysql\"\n\t}\n\n\targument - \"instance_name\" {\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\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 - \"mysql\" {\n\t\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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 = 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_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 \"component_redis_exporter\" - {\n\n\t/*****************************************************************\n\t* +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(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/redis_exporter\"\n\t}\n\n\targument - \"namespace\" {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-redis\"\n\t}\n\n\targument - \"instance_name\" {\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\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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[\"redis-addr\"])\n\t\tredis_password - = nonsensitive(remote.kubernetes.secret.redis.data[\"redis-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.memcached.integrations_redis_exporter.targets\n\n\t\trule - {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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" + \"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-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 namespace: monitoring-system --- apiVersion: v1 @@ -502,48 +444,59 @@ data: 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\tdefault = \"alloy-integrations\"\n\t}\n\n\targument - \"namespace\" {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional - = true\n\t\tdefault = \"default\"\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\t// - integrations components local files\n\timport.file \"integrations\" {\n\t\tfilename - = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") + \"/kubernetes/integrations\"\n\t}\n\n\t// - // integrations components kubernetes configmap\n\t// remote.kubernetes.configmap - \"integrations\" {\n\t// \tname = argument.name.value\n\t// \tnamespace = - argument.namespace.value\n\t// }\n\t// import.string \"integrations\" {\n\t// - \tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t// - }\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\tintegrations.component_memcached - \"primary\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tinstance_name - \ = \"primary\"\n\t\tmemcached_address = \"memcached.memcached-system.svc.cluster.local:11211\"\n\t\tmemcached_timeout - = \"5s\"\n\t}\n\n\t// /*****************************************************************\n\t// + \"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// - integrations.component_mysql \"primary\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tinstance_name = \"primary\"\n\t// \tname = \"alloy-integrations-mysql\"\n\t// - \tnamespace = \"monitoring-system\"\n\t// }\n}\n" + 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* ARGUMENTS\n\t*****************************************************************/\n\targument \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape PodMonitors\n\t*****************************************************************/\n\tprometheus.operator.podmonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression {\n\t\t// \t\tkey - \ = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues = [\"team-infra\"]\n\t\t// - \t}\n\t\t// }\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression + {\n\t\t// \t\tkey = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues + \ = [\"team-infra\"]\n\t\t// \t}\n\t\t// }\n\t}\n}\n" servicemonitors-scrape.alloy: "/*\nModule Components: servicemonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.servicemonitors\n*/\n\ndeclare \"servicemonitors_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\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape ServiceMonitors\n\t*****************************************************************/\n\tprometheus.operator.servicemonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc namespace: monitoring-system --- apiVersion: v1 @@ -1142,31 +1095,21 @@ metadata: --- apiVersion: v1 data: - memcached-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + ALLOY_LOG_LEVEL: d2Fybg== kind: Secret metadata: - name: alloy-integrations-memcached + name: alloy-env-f7k229g955 namespace: monitoring-system type: Opaque --- apiVersion: v1 data: - mysql-host: bXlzcWwubXlzcWwtc3lzdGVtLnN2Yy5jbHVzdGVyLmxvY2Fs - mysql-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= - mysql-username: bGd0bXA= + instance-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + instance-name: cHJpbWFyeQ== + instance-timeout: NXM= kind: Secret metadata: - name: alloy-integrations-mysql - namespace: monitoring-system -type: Opaque ---- -apiVersion: v1 -data: - redis-addr: cmVkaXMtbWFzdGVyLnJlZGlzLXN5c3RlbS5zdmMuY2x1c3Rlci5sb2NhbDo2Mzc5 - redis-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= -kind: Secret -metadata: - name: alloy-integrations-redis + name: alloy-integrations-memcached namespace: monitoring-system type: Opaque --- @@ -1536,7 +1479,7 @@ spec: fieldPath: spec.nodeName envFrom: - secretRef: - name: alloy-env + name: alloy-env-f7k229g955 optional: true image: docker.io/grafana/alloy:v1.0.0 imagePullPolicy: IfNotPresent @@ -1585,10 +1528,10 @@ spec: name: alloy-config-gt2k68744f name: config - configMap: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 name: modules-kubernetes-integrations - configMap: name: alloy-modules-kubernetes-logs-d7c756mt2f diff --git a/kubernetes/monolithic-mode/traces/kustomization.yaml b/kubernetes/monolithic-mode/traces/kustomization.yaml index b49c2a10..2b355599 100644 --- a/kubernetes/monolithic-mode/traces/kustomization.yaml +++ b/kubernetes/monolithic-mode/traces/kustomization.yaml @@ -19,7 +19,7 @@ configMapGenerator: namespace: monitoring-system behavior: replace files: - - config.alloy=configs/traces.alloy + - config.alloy=traces.alloy # Update Tempo Monolithic Mode endpoint in gateway - name: nginx-templates diff --git a/kubernetes/monolithic-mode/traces/configs/traces.alloy b/kubernetes/monolithic-mode/traces/traces.alloy similarity index 100% rename from kubernetes/monolithic-mode/traces/configs/traces.alloy rename to kubernetes/monolithic-mode/traces/traces.alloy 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 9786401c..d286eb00 100644 --- a/kubernetes/read-write-mode/logs/k8s-all-in-one.yaml +++ b/kubernetes/read-write-mode/logs/k8s-all-in-one.yaml @@ -390,130 +390,72 @@ metadata: --- 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" + 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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/memcached\"\n\t}\n\n\targument - \"memcached_address\" {\n\t\toptional = true\n\t\tdefault = \"memcached:11211\"\n\t}\n\n\targument - \"memcached_timeout\" {\n\t\toptional = true\n\t\tdefault = \"5s\"\n\t}\n\n\targument - \"instance_name\" {\n\t\tcomment = \"instance of the Memcached\"\n\t\toptional + 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\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\t/***************************************************************\n\t* + (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 = argument.memcached_address.value\n\t\ttimeout - = argument.memcached_timeout.value\n\t}\n\n\t/***************************************************************\n\t* + \"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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, + {\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 = 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_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* + = 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" - mysql.alloy: "/*\nModule Components: component_mysql\n*/\n\ndeclare \"component_mysql\" - {\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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/mysql\"\n\t}\n\n\targument \"namespace\" - {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-mysql\"\n\t}\n\n\targument - \"instance_name\" {\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\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 - \"mysql\" {\n\t\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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 = 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_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 \"component_redis_exporter\" - {\n\n\t/*****************************************************************\n\t* +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(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/redis_exporter\"\n\t}\n\n\targument - \"namespace\" {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-redis\"\n\t}\n\n\targument - \"instance_name\" {\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\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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[\"redis-addr\"])\n\t\tredis_password - = nonsensitive(remote.kubernetes.secret.redis.data[\"redis-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.memcached.integrations_redis_exporter.targets\n\n\t\trule - {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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" + \"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-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 namespace: monitoring-system --- apiVersion: v1 @@ -649,48 +591,59 @@ data: 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\tdefault = \"alloy-integrations\"\n\t}\n\n\targument - \"namespace\" {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional - = true\n\t\tdefault = \"default\"\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\t// - integrations components local files\n\timport.file \"integrations\" {\n\t\tfilename - = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") + \"/kubernetes/integrations\"\n\t}\n\n\t// - // integrations components kubernetes configmap\n\t// remote.kubernetes.configmap - \"integrations\" {\n\t// \tname = argument.name.value\n\t// \tnamespace = - argument.namespace.value\n\t// }\n\t// import.string \"integrations\" {\n\t// - \tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t// - }\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\tintegrations.component_memcached - \"primary\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tinstance_name - \ = \"primary\"\n\t\tmemcached_address = \"memcached.memcached-system.svc.cluster.local:11211\"\n\t\tmemcached_timeout - = \"5s\"\n\t}\n\n\t// /*****************************************************************\n\t// + \"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// - integrations.component_mysql \"primary\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tinstance_name = \"primary\"\n\t// \tname = \"alloy-integrations-mysql\"\n\t// - \tnamespace = \"monitoring-system\"\n\t// }\n}\n" + 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* ARGUMENTS\n\t*****************************************************************/\n\targument \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape PodMonitors\n\t*****************************************************************/\n\tprometheus.operator.podmonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression {\n\t\t// \t\tkey - \ = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues = [\"team-infra\"]\n\t\t// - \t}\n\t\t// }\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression + {\n\t\t// \t\tkey = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues + \ = [\"team-infra\"]\n\t\t// \t}\n\t\t// }\n\t}\n}\n" servicemonitors-scrape.alloy: "/*\nModule Components: servicemonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.servicemonitors\n*/\n\ndeclare \"servicemonitors_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\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape ServiceMonitors\n\t*****************************************************************/\n\tprometheus.operator.servicemonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc namespace: monitoring-system --- apiVersion: v1 @@ -1165,31 +1118,21 @@ type: Opaque --- apiVersion: v1 data: - memcached-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + ALLOY_LOG_LEVEL: d2Fybg== kind: Secret metadata: - name: alloy-integrations-memcached + name: alloy-env-f7k229g955 namespace: monitoring-system type: Opaque --- apiVersion: v1 data: - mysql-host: bXlzcWwubXlzcWwtc3lzdGVtLnN2Yy5jbHVzdGVyLmxvY2Fs - mysql-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= - mysql-username: bGd0bXA= + instance-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + instance-name: cHJpbWFyeQ== + instance-timeout: NXM= kind: Secret metadata: - name: alloy-integrations-mysql - namespace: monitoring-system -type: Opaque ---- -apiVersion: v1 -data: - redis-addr: cmVkaXMtbWFzdGVyLnJlZGlzLXN5c3RlbS5zdmMuY2x1c3Rlci5sb2NhbDo2Mzc5 - redis-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= -kind: Secret -metadata: - name: alloy-integrations-redis + name: alloy-integrations-memcached namespace: monitoring-system type: Opaque --- @@ -2054,7 +1997,7 @@ spec: fieldPath: spec.nodeName envFrom: - secretRef: - name: alloy-env + name: alloy-env-f7k229g955 optional: true image: docker.io/grafana/alloy:v1.0.0 imagePullPolicy: IfNotPresent @@ -2103,10 +2046,10 @@ spec: name: alloy-config-8t9d8htff7 name: config - configMap: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 name: modules-kubernetes-integrations - configMap: name: alloy-modules-kubernetes-logs-d7c756mt2f 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 44c73036..07554e5d 100644 --- a/kubernetes/read-write-mode/metrics/k8s-all-in-one.yaml +++ b/kubernetes/read-write-mode/metrics/k8s-all-in-one.yaml @@ -168,130 +168,72 @@ metadata: --- 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" + 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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/memcached\"\n\t}\n\n\targument - \"memcached_address\" {\n\t\toptional = true\n\t\tdefault = \"memcached:11211\"\n\t}\n\n\targument - \"memcached_timeout\" {\n\t\toptional = true\n\t\tdefault = \"5s\"\n\t}\n\n\targument - \"instance_name\" {\n\t\tcomment = \"instance of the Memcached\"\n\t\toptional + 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\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\t/***************************************************************\n\t* + (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 = argument.memcached_address.value\n\t\ttimeout - = argument.memcached_timeout.value\n\t}\n\n\t/***************************************************************\n\t* + \"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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, + {\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 = 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_memcached_exporter.receiver]\n\t}\n\n\t/***************************************************************\n\t* + = 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" - mysql.alloy: "/*\nModule Components: component_mysql\n*/\n\ndeclare \"component_mysql\" - {\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\toptional - = true\n\t\tdefault = \"integrations/kubernetes/mysql\"\n\t}\n\n\targument \"namespace\" - {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-mysql\"\n\t}\n\n\targument - \"instance_name\" {\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\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 - \"mysql\" {\n\t\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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 = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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 = 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_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 \"component_redis_exporter\" - {\n\n\t/*****************************************************************\n\t* +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(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t}\n\n\targument \"job_label\" {\n\t\toptional - = true\n\t\tdefault = \"integrations/kubernetes/redis_exporter\"\n\t}\n\n\targument - \"namespace\" {\n\t\toptional = true\n\t\tdefault = \"monitoring-system\"\n\t}\n\n\targument - \"name\" {\n\t\toptional = true\n\t\tdefault = \"alloy-integrations-redis\"\n\t}\n\n\targument - \"instance_name\" {\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\tname = argument.name.value\n\t\tnamespace = argument.namespace.value\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[\"redis-addr\"])\n\t\tredis_password - = nonsensitive(remote.kubernetes.secret.redis.data[\"redis-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.memcached.integrations_redis_exporter.targets\n\n\t\trule - {\n\t\t\ttarget_label = \"job\"\n\t\t\treplacement = argument.job_label.value\n\t\t}\n\n\t\trule - {\n\t\t\ttarget_label = \"instance\"\n\t\t\treplacement = coalesce(argument.instance_name.value, - 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" + \"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-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 namespace: monitoring-system --- apiVersion: v1 @@ -427,48 +369,59 @@ data: 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\tdefault = \"alloy-integrations\"\n\t}\n\n\targument - \"namespace\" {\n\t\tcomment = \"Namespace of the integrations config\"\n\t\toptional - = true\n\t\tdefault = \"default\"\n\t}\n\n\t/*****************************************************************\n\t* - Import Integrations Components\n\t*****************************************************************/\n\t// - integrations components local files\n\timport.file \"integrations\" {\n\t\tfilename - = coalesce(env(\"ALLOY_MODULES_FOLDER\"), \"/etc/alloy/modules\") + \"/kubernetes/integrations\"\n\t}\n\n\t// - // integrations components kubernetes configmap\n\t// remote.kubernetes.configmap - \"integrations\" {\n\t// \tname = argument.name.value\n\t// \tnamespace = - argument.namespace.value\n\t// }\n\t// import.string \"integrations\" {\n\t// - \tcontent = remote.kubernetes.configmap.integrations.data[\"memcached.alloy\"]\n\t// - }\n\n\t/*****************************************************************\n\t* - Memcached Integrations\n\t*****************************************************************/\n\tintegrations.component_memcached - \"primary\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tinstance_name - \ = \"primary\"\n\t\tmemcached_address = \"memcached.memcached-system.svc.cluster.local:11211\"\n\t\tmemcached_timeout - = \"5s\"\n\t}\n\n\t// /*****************************************************************\n\t// + \"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// - integrations.component_mysql \"primary\" {\n\t// \tforward_to = argument.forward_to.value\n\n\t// - \tinstance_name = \"primary\"\n\t// \tname = \"alloy-integrations-mysql\"\n\t// - \tnamespace = \"monitoring-system\"\n\t// }\n}\n" + 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* ARGUMENTS\n\t*****************************************************************/\n\targument \"forward_to\" {\n\t\tcomment = \"Must be a list(MetricssReceiver) where collected - metrics should be forwarded to\"\n\t\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape PodMonitors\n\t*****************************************************************/\n\tprometheus.operator.podmonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression {\n\t\t// \t\tkey - \ = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues = [\"team-infra\"]\n\t\t// - \t}\n\t\t// }\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\n\t\t// selector {\n\t\t// \tmatch_expression + {\n\t\t// \t\tkey = \"team\"\n\t\t// \t\toperator = \"In\"\n\t\t// \t\tvalues + \ = [\"team-infra\"]\n\t\t// \t}\n\t\t// }\n\t}\n}\n" servicemonitors-scrape.alloy: "/*\nModule Components: servicemonitors_scrape\nDescription: Scrapes targets for metrics based on prometheus.operator.servicemonitors\n*/\n\ndeclare \"servicemonitors_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\toptional = false\n\t}\n\n\t/*****************************************************************\n\t* + metrics should be forwarded to\"\n\t\toptional = false\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\t/*****************************************************************\n\t* Kubernetes Auto Scrape ServiceMonitors\n\t*****************************************************************/\n\tprometheus.operator.servicemonitors - \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tclustering {\n\t\t\tenabled - = true\n\t\t}\n\t}\n}\n" + \"scrape\" {\n\t\tforward_to = argument.forward_to.value\n\n\t\tscrape {\n\t\t\tdefault_scrape_interval + = coalesce(argument.scrape_interval.value, \"60s\")\n\t\t\tdefault_scrape_timeout + \ = coalesce(argument.scrape_timeout.value, \"10s\")\n\t\t}\n\n\t\tclustering + {\n\t\t\tenabled = true\n\t\t}\n\t}\n}\n" kind: ConfigMap metadata: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc namespace: monitoring-system --- apiVersion: v1 @@ -935,31 +888,21 @@ metadata: --- apiVersion: v1 data: - memcached-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + ALLOY_LOG_LEVEL: d2Fybg== kind: Secret metadata: - name: alloy-integrations-memcached + name: alloy-env-f7k229g955 namespace: monitoring-system type: Opaque --- apiVersion: v1 data: - mysql-host: bXlzcWwubXlzcWwtc3lzdGVtLnN2Yy5jbHVzdGVyLmxvY2Fs - mysql-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= - mysql-username: bGd0bXA= + instance-address: bWVtY2FjaGVkLm1lbWNhY2hlZC1zeXN0ZW0uc3ZjLmNsdXN0ZXIubG9jYWw6MTEyMTE= + instance-name: cHJpbWFyeQ== + instance-timeout: NXM= kind: Secret metadata: - name: alloy-integrations-mysql - namespace: monitoring-system -type: Opaque ---- -apiVersion: v1 -data: - redis-addr: cmVkaXMtbWFzdGVyLnJlZGlzLXN5c3RlbS5zdmMuY2x1c3Rlci5sb2NhbDo2Mzc5 - redis-password: VkQ1MzhPWXhTRWlHRDRJOW1tRmZxRk1DR3ExdklpR20= -kind: Secret -metadata: - name: alloy-integrations-redis + name: alloy-integrations-memcached namespace: monitoring-system type: Opaque --- @@ -1428,7 +1371,7 @@ spec: fieldPath: spec.nodeName envFrom: - secretRef: - name: alloy-env + name: alloy-env-f7k229g955 optional: true image: docker.io/grafana/alloy:v1.0.0 imagePullPolicy: IfNotPresent @@ -1477,10 +1420,10 @@ spec: name: alloy-config-m6chdfm49m name: config - configMap: - name: alloy-modules-kubernetes-metrics-bgtb8d5hch + name: alloy-modules-kubernetes-metrics-5g24522dhc name: modules-kubernetes-metrics - configMap: - name: alloy-modules-kubernetes-integrations-2kb5k574d2 + name: alloy-modules-kubernetes-integrations-mb46d6kmf6 name: modules-kubernetes-integrations - configMap: name: alloy-modules-kubernetes-logs-d7c756mt2f