From 4d2f5ae53030fb57ab7accedd6fa1a8f028124f4 Mon Sep 17 00:00:00 2001 From: Adam Hackl Date: Mon, 4 Nov 2024 16:28:53 -0500 Subject: [PATCH] fix: update all depreciated stdlib string functions --- modules/broker/rabbitmq/metrics.alloy | 6 ++--- modules/collector/agent/metrics.alloy | 6 ++--- modules/collector/push-gateway/metrics.alloy | 4 ++-- modules/databases/kv/etcd/metrics.alloy | 6 ++--- modules/databases/kv/memcached/metrics.alloy | 6 ++--- modules/databases/kv/redis/metrics.alloy | 6 ++--- modules/databases/sql/mysql/metrics.alloy | 6 ++--- modules/databases/sql/postgres/metrics.alloy | 6 ++--- .../databases/timeseries/loki/metrics.alloy | 6 ++--- .../databases/timeseries/mimir/metrics.alloy | 6 ++--- .../timeseries/pyroscope/metrics.alloy | 6 ++--- .../databases/timeseries/tempo/metrics.alloy | 6 ++--- modules/kubernetes/annotations/logs/README.md | 12 +++++----- .../kubernetes/annotations/logs/drop.alloy | 2 +- .../kubernetes/annotations/logs/embed.alloy | 2 +- .../kubernetes/annotations/logs/json.alloy | 4 ++-- .../kubernetes/annotations/logs/logs.alloy | 6 ++--- .../kubernetes/annotations/logs/mask.alloy | 14 +++++------ .../kubernetes/annotations/logs/utils.alloy | 8 +++---- modules/kubernetes/annotations/metrics.alloy | 14 +++++------ modules/kubernetes/annotations/probes.alloy | 6 ++--- modules/kubernetes/cert-manager/metrics.alloy | 4 ++-- modules/kubernetes/core/metrics.alloy | 24 +++++++++---------- .../konnectivity-agent/metrics.alloy | 4 ++-- .../kube-state-metrics/metrics.alloy | 4 ++-- modules/kubernetes/opencost/metrics.alloy | 4 ++-- modules/networking/consul/metrics.alloy | 6 ++--- modules/networking/haproxy/metrics.alloy | 6 ++--- modules/source-control/gitlab/metrics.alloy | 6 ++--- modules/system/node-exporter/metrics.alloy | 6 ++--- modules/ui/grafana/metrics.alloy | 6 ++--- 31 files changed, 104 insertions(+), 104 deletions(-) diff --git a/modules/broker/rabbitmq/metrics.alloy b/modules/broker/rabbitmq/metrics.alloy index d454485..d9fff9f 100644 --- a/modules/broker/rabbitmq/metrics.alloy +++ b/modules/broker/rabbitmq/metrics.alloy @@ -37,8 +37,8 @@ declare "kubernetes" { selectors { role = "pod" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=prometheus-rabbitmq-exporter"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=prometheus-rabbitmq-exporter"]), ",") } namespaces { @@ -153,7 +153,7 @@ declare "local" { discovery.relabel "local" { targets = [ { - "__address__" = "localhost" + format("%s", coalesce(argument.port.value, "9419")), + "__address__" = "localhost" + string.format("%s", coalesce(argument.port.value, "9419")), "source" = "local", }, ] diff --git a/modules/collector/agent/metrics.alloy b/modules/collector/agent/metrics.alloy index 59c6f79..7e82a6e 100644 --- a/modules/collector/agent/metrics.alloy +++ b/modules/collector/agent/metrics.alloy @@ -37,8 +37,8 @@ declare "kubernetes" { selectors { role = "pod" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=grafana-agent"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=grafana-agent"]), ",") } namespaces { @@ -154,7 +154,7 @@ declare "local" { discovery.relabel "local" { targets = [ { - "__address__" = "localhost" + format("%s", coalesce(argument.port.value, "12345")), + "__address__" = "localhost" + string.format("%s", coalesce(argument.port.value, "12345")), "source" = "local", }, ] diff --git a/modules/collector/push-gateway/metrics.alloy b/modules/collector/push-gateway/metrics.alloy index a335b50..62ab23f 100644 --- a/modules/collector/push-gateway/metrics.alloy +++ b/modules/collector/push-gateway/metrics.alloy @@ -37,8 +37,8 @@ declare "kubernetes" { selectors { role = "service" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=prometheus-pushgateway"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=prometheus-pushgateway"]), ",") } namespaces { diff --git a/modules/databases/kv/etcd/metrics.alloy b/modules/databases/kv/etcd/metrics.alloy index d7f8d4d..710c847 100644 --- a/modules/databases/kv/etcd/metrics.alloy +++ b/modules/databases/kv/etcd/metrics.alloy @@ -37,8 +37,8 @@ declare "kubernetes" { selectors { role = "pod" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/component=etcd"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/component=etcd"]), ",") } namespaces { @@ -153,7 +153,7 @@ declare "local" { discovery.relabel "local" { targets = [ { - "__address__" = "localhost" + format("%s", coalesce(argument.port.value, "9150")), + "__address__" = "localhost" + string.format("%s", coalesce(argument.port.value, "9150")), "source" = "local", }, ] diff --git a/modules/databases/kv/memcached/metrics.alloy b/modules/databases/kv/memcached/metrics.alloy index da224e0..7992b85 100644 --- a/modules/databases/kv/memcached/metrics.alloy +++ b/modules/databases/kv/memcached/metrics.alloy @@ -37,8 +37,8 @@ declare "kubernetes" { selectors { role = "pod" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=memcached"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=memcached"]), ",") } namespaces { @@ -153,7 +153,7 @@ declare "local" { discovery.relabel "local" { targets = [ { - "__address__" = "localhost" + format("%s", coalesce(argument.port.value, "9150")), + "__address__" = "localhost" + string.format("%s", coalesce(argument.port.value, "9150")), "source" = "local", }, ] diff --git a/modules/databases/kv/redis/metrics.alloy b/modules/databases/kv/redis/metrics.alloy index 088b28b..ca74edd 100644 --- a/modules/databases/kv/redis/metrics.alloy +++ b/modules/databases/kv/redis/metrics.alloy @@ -37,8 +37,8 @@ declare "kubernetes" { selectors { role = "pod" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=prometheus-redis-exporter"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=prometheus-redis-exporter"]), ",") } namespaces { @@ -153,7 +153,7 @@ declare "local" { discovery.relabel "local" { targets = [ { - "__address__" = "localhost" + format("%s", coalesce(argument.port.value, "9150")), + "__address__" = "localhost" + string.format("%s", coalesce(argument.port.value, "9150")), "source" = "local", }, ] diff --git a/modules/databases/sql/mysql/metrics.alloy b/modules/databases/sql/mysql/metrics.alloy index 8a99262..c21f404 100644 --- a/modules/databases/sql/mysql/metrics.alloy +++ b/modules/databases/sql/mysql/metrics.alloy @@ -37,8 +37,8 @@ declare "kubernetes" { selectors { role = "pod" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=prometheus-mysql-exporter"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=prometheus-mysql-exporter"]), ",") } namespaces { @@ -154,7 +154,7 @@ declare "local" { discovery.relabel "local" { targets = [ { - "__address__" = "localhost" + format("%s", coalesce(argument.port.value, "9104")), + "__address__" = "localhost" + string.format("%s", coalesce(argument.port.value, "9104")), "source" = "local", }, ] diff --git a/modules/databases/sql/postgres/metrics.alloy b/modules/databases/sql/postgres/metrics.alloy index 609dea5..a8e53db 100644 --- a/modules/databases/sql/postgres/metrics.alloy +++ b/modules/databases/sql/postgres/metrics.alloy @@ -37,8 +37,8 @@ declare "kubernetes" { selectors { role = "pod" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=prometheus-postgres-exporter"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=prometheus-postgres-exporter"]), ",") } namespaces { @@ -154,7 +154,7 @@ declare "local" { discovery.relabel "local" { targets = [ { - "__address__" = "localhost" + format("%s", coalesce(argument.port.value, "9187")), + "__address__" = "localhost" + string.format("%s", coalesce(argument.port.value, "9187")), "source" = "local", }, ] diff --git a/modules/databases/timeseries/loki/metrics.alloy b/modules/databases/timeseries/loki/metrics.alloy index bfa0645..e89ec31 100644 --- a/modules/databases/timeseries/loki/metrics.alloy +++ b/modules/databases/timeseries/loki/metrics.alloy @@ -37,8 +37,8 @@ declare "kubernetes" { selectors { role = "pod" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=loki"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=loki"]), ",") } namespaces { @@ -154,7 +154,7 @@ declare "local" { discovery.relabel "local" { targets = [ { - "__address__" = "localhost" + format("%s", coalesce(argument.port.value, "3000")), + "__address__" = "localhost" + string.format("%s", coalesce(argument.port.value, "3000")), "source" = "local", }, ] diff --git a/modules/databases/timeseries/mimir/metrics.alloy b/modules/databases/timeseries/mimir/metrics.alloy index 64c2e99..aa4c4d0 100644 --- a/modules/databases/timeseries/mimir/metrics.alloy +++ b/modules/databases/timeseries/mimir/metrics.alloy @@ -37,8 +37,8 @@ declare "kubernetes" { selectors { role = "pod" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=mimir"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=mimir"]), ",") } namespaces { @@ -154,7 +154,7 @@ declare "local" { discovery.relabel "local" { targets = [ { - "__address__" = "localhost" + format("%s", coalesce(argument.port.value, "8080")), + "__address__" = "localhost" + string.format("%s", coalesce(argument.port.value, "8080")), "source" = "local", }, ] diff --git a/modules/databases/timeseries/pyroscope/metrics.alloy b/modules/databases/timeseries/pyroscope/metrics.alloy index 2183e7d..8209e73 100644 --- a/modules/databases/timeseries/pyroscope/metrics.alloy +++ b/modules/databases/timeseries/pyroscope/metrics.alloy @@ -37,8 +37,8 @@ declare "kubernetes" { selectors { role = "pod" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=pyroscope"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=pyroscope"]), ",") } namespaces { @@ -154,7 +154,7 @@ declare "local" { discovery.relabel "local" { targets = [ { - "__address__" = "localhost" + format("%s", coalesce(argument.port.value, "4040")), + "__address__" = "localhost" + string.format("%s", coalesce(argument.port.value, "4040")), "source" = "local", }, ] diff --git a/modules/databases/timeseries/tempo/metrics.alloy b/modules/databases/timeseries/tempo/metrics.alloy index fb055f2..4c2cb00 100644 --- a/modules/databases/timeseries/tempo/metrics.alloy +++ b/modules/databases/timeseries/tempo/metrics.alloy @@ -37,8 +37,8 @@ declare "kubernetes" { selectors { role = "pod" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=tempo"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=tempo"]), ",") } namespaces { @@ -154,7 +154,7 @@ declare "local" { discovery.relabel "local" { targets = [ { - "__address__" = "localhost" + format("%s", coalesce(argument.port.value, "3200")), + "__address__" = "localhost" + string.format("%s", coalesce(argument.port.value, "3200")), "source" = "local", }, ] diff --git a/modules/kubernetes/annotations/logs/README.md b/modules/kubernetes/annotations/logs/README.md index df23b86..bb4b6b1 100644 --- a/modules/kubernetes/annotations/logs/README.md +++ b/modules/kubernetes/annotations/logs/README.md @@ -475,18 +475,18 @@ log_utils.post_process_metrics "default" {} loki.write "local" { endpoint { - url = env("LOGS_PRIMARY_URL") + url = sys.env("LOGS_PRIMARY_URL") basic_auth { - username = env("LOGS_PRIMARY_TENANT") - password = env("LOGS_PRIMARY_TOKEN") + username = sys.env("LOGS_PRIMARY_TENANT") + password = sys.env("LOGS_PRIMARY_TOKEN") } } external_labels = { - "cluster" = coalesce(env("CLUSTER_NAME"), env("CLUSTER"), ""), - "env" = coalesce(env("ENV"), ""), - "region" = coalesce(env("REGION"), ""), + "cluster" = coalesce(sys.env("CLUSTER_NAME"), sys.env("CLUSTER"), ""), + "env" = coalesce(sys.env("ENV"), ""), + "region" = coalesce(sys.env("REGION"), ""), } } ``` diff --git a/modules/kubernetes/annotations/logs/drop.alloy b/modules/kubernetes/annotations/logs/drop.alloy index 1375b80..ce9cb1b 100644 --- a/modules/kubernetes/annotations/logs/drop.alloy +++ b/modules/kubernetes/annotations/logs/drop.alloy @@ -68,7 +68,7 @@ declare "drop_levels" { 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.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") + default = string.replace(string.replace(string.replace(coalesce(argument.annotation.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") } export "annotation" { diff --git a/modules/kubernetes/annotations/logs/embed.alloy b/modules/kubernetes/annotations/logs/embed.alloy index 28bd055..7076d88 100644 --- a/modules/kubernetes/annotations/logs/embed.alloy +++ b/modules/kubernetes/annotations/logs/embed.alloy @@ -39,7 +39,7 @@ declare "embed_pod" { 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.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") + default = string.replace(string.replace(string.replace(coalesce(argument.annotation.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") } export "annotation" { diff --git a/modules/kubernetes/annotations/logs/json.alloy b/modules/kubernetes/annotations/logs/json.alloy index bda7444..49ae8b1 100644 --- a/modules/kubernetes/annotations/logs/json.alloy +++ b/modules/kubernetes/annotations/logs/json.alloy @@ -32,7 +32,7 @@ declare "json_scrub_empties" { 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.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") + default = string.replace(string.replace(string.replace(coalesce(argument.annotation.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") } export "annotation" { @@ -99,7 +99,7 @@ declare "json_scrub_nulls" { 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.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") + default = string.replace(string.replace(string.replace(coalesce(argument.annotation.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") } export "annotation" { diff --git a/modules/kubernetes/annotations/logs/logs.alloy b/modules/kubernetes/annotations/logs/logs.alloy index fe0d003..b403700 100644 --- a/modules/kubernetes/annotations/logs/logs.alloy +++ b/modules/kubernetes/annotations/logs/logs.alloy @@ -46,7 +46,7 @@ declare "pods" { 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.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") + default = string.replace(string.replace(string.replace(coalesce(argument.annotation.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") } // export the discovered targets @@ -65,8 +65,8 @@ declare "pods" { selectors { role = "pod" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, []), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, []), ",") } namespaces { diff --git a/modules/kubernetes/annotations/logs/mask.alloy b/modules/kubernetes/annotations/logs/mask.alloy index d0faeb6..865eb86 100644 --- a/modules/kubernetes/annotations/logs/mask.alloy +++ b/modules/kubernetes/annotations/logs/mask.alloy @@ -42,7 +42,7 @@ declare "mask_luhn" { 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.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") + default = string.replace(string.replace(string.replace(coalesce(argument.annotation.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") } export "annotation" { @@ -106,7 +106,7 @@ declare "mask_credit_card" { 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.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") + default = string.replace(string.replace(string.replace(coalesce(argument.annotation.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") } export "annotation" { @@ -177,7 +177,7 @@ declare "mask_email" { 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.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") + default = string.replace(string.replace(string.replace(coalesce(argument.annotation.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") } export "annotation" { @@ -242,7 +242,7 @@ declare "mask_ipv4" { 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.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") + default = string.replace(string.replace(string.replace(coalesce(argument.annotation.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") } export "annotation" { @@ -307,7 +307,7 @@ declare "mask_ipv6" { 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.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") + default = string.replace(string.replace(string.replace(coalesce(argument.annotation.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") } export "annotation" { @@ -372,7 +372,7 @@ declare "mask_phone" { 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.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") + default = string.replace(string.replace(string.replace(coalesce(argument.annotation.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") } export "annotation" { @@ -437,7 +437,7 @@ declare "mask_ssn" { 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.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") + default = string.replace(string.replace(string.replace(coalesce(argument.annotation.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") } export "annotation" { diff --git a/modules/kubernetes/annotations/logs/utils.alloy b/modules/kubernetes/annotations/logs/utils.alloy index 71c4454..122663a 100644 --- a/modules/kubernetes/annotations/logs/utils.alloy +++ b/modules/kubernetes/annotations/logs/utils.alloy @@ -32,7 +32,7 @@ declare "decolorize" { 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.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") + default = string.replace(string.replace(string.replace(coalesce(argument.annotation.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") } export "annotation" { @@ -91,7 +91,7 @@ declare "trim" { 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.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") + default = string.replace(string.replace(string.replace(coalesce(argument.annotation.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") } export "annotation" { @@ -156,7 +156,7 @@ declare "dedup_spaces" { 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.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") + default = string.replace(string.replace(string.replace(coalesce(argument.annotation.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") } export "annotation" { @@ -230,7 +230,7 @@ declare "sampling" { 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.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") + default = string.replace(string.replace(string.replace(coalesce(argument.annotation.value, "logs.grafana.com"),".", "_"),"/", "_"),"-", "_") } export "annotation" { diff --git a/modules/kubernetes/annotations/metrics.alloy b/modules/kubernetes/annotations/metrics.alloy index 3416859..e4a1f21 100644 --- a/modules/kubernetes/annotations/metrics.alloy +++ b/modules/kubernetes/annotations/metrics.alloy @@ -145,19 +145,19 @@ declare "kubernetes" { argument "__pod_role" { comment = "Most annotation targets service or pod that is all you want, however if the role is endpoints you want the pod" optional = true - default = replace(coalesce(argument.role.value, "endpoints"), "endpoints", "pod") + default = string.replace(coalesce(argument.role.value, "endpoints"), "endpoints", "pod") } argument "__service_role" { comment = "Most annotation targets service or pod that is all you want, however if the role is endpoints you we also want to consider service annotations" optional = true - default = replace(coalesce(argument.role.value, "endpoints"), "endpoints", "service") + default = string.replace(coalesce(argument.role.value, "endpoints"), "endpoints", "service") } 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.value, "metrics.grafana.com"),".", "_"),"/", "_"),"-", "_") + default = string.replace(string.replace(string.replace(coalesce(argument.annotation.value, "metrics.grafana.com"),".", "_"),"/", "_"),"-", "_") } // annotations service discovery @@ -166,8 +166,8 @@ declare "kubernetes" { selectors { role = coalesce(argument.role.value, "endpoints") - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, []), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, []), ",") } namespaces { @@ -210,7 +210,7 @@ declare "kubernetes" { // add a __tmp_scrape_port_named_metrics from the argument.scrape_port_named_metrics rule { - replacement = format("%t", argument.scrape_port_named_metrics.value) + replacement = string.format("%t", argument.scrape_port_named_metrics.value) target_label = "__tmp_scrape_port_named_metrics" } @@ -221,7 +221,7 @@ declare "kubernetes" { "__tmp_scrape", "__tmp_scrape_port_named_metrics", // endpoints is the role and most meta labels started with "endpoints", however the port name is an exception and starts with "endpoint" - "__meta_kubernetes_" + replace(coalesce(argument.role.value, "endpoints"), "endpoints", "endpoint") + "_port_name", + "__meta_kubernetes_" + string.replace(coalesce(argument.role.value, "endpoints"), "endpoints", "endpoint") + "_port_name", ] separator = ";" regex = "^(true;.*|(|true);true;(.*metrics.*))$" diff --git a/modules/kubernetes/annotations/probes.alloy b/modules/kubernetes/annotations/probes.alloy index 109d154..3bfdf96 100644 --- a/modules/kubernetes/annotations/probes.alloy +++ b/modules/kubernetes/annotations/probes.alloy @@ -108,7 +108,7 @@ declare "kubernetes" { 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.value, "probes.grafana.com"),".", "_"),"/", "_"),"-", "_") + default = string.replace(string.replace(string.replace(coalesce(argument.annotation.value, "probes.grafana.com"),".", "_"),"/", "_"),"-", "_") } // annotations service discovery @@ -117,8 +117,8 @@ declare "kubernetes" { selectors { role = coalesce(argument.role.value, "service") - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, []), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, []), ",") } namespaces { diff --git a/modules/kubernetes/cert-manager/metrics.alloy b/modules/kubernetes/cert-manager/metrics.alloy index aba4e8d..883553f 100644 --- a/modules/kubernetes/cert-manager/metrics.alloy +++ b/modules/kubernetes/cert-manager/metrics.alloy @@ -37,8 +37,8 @@ declare "kubernetes" { selectors { role = "pod" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=cert-manager"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=cert-manager"]), ",") } namespaces { diff --git a/modules/kubernetes/core/metrics.alloy b/modules/kubernetes/core/metrics.alloy index 4cd3cb8..3052952 100644 --- a/modules/kubernetes/core/metrics.alloy +++ b/modules/kubernetes/core/metrics.alloy @@ -61,8 +61,8 @@ declare "cadvisor" { selectors { role = "node" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, []), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, []), ",") } } @@ -280,8 +280,8 @@ declare "resources" { selectors { role = "node" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, []), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, []), ",") } } @@ -427,8 +427,8 @@ declare "kubelet" { selectors { role = "node" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, []), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, []), ",") } } @@ -588,8 +588,8 @@ declare "apiserver" { selectors { role = "service" - field = join(coalesce(argument.field_selectors.value, ["metadata.name=kubernetes"]), ",") - label = join(coalesce(argument.label_selectors.value, []), ",") + field = string.join(coalesce(argument.field_selectors.value, ["metadata.name=kubernetes"]), ",") + label = string.join(coalesce(argument.label_selectors.value, []), ",") } namespaces { @@ -750,8 +750,8 @@ declare "probes" { selectors { role = "node" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, []), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, []), ",") } } @@ -906,8 +906,8 @@ declare "kube_dns" { selectors { role = "endpoints" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["k8s-app=kube-dns"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["k8s-app=kube-dns"]), ",") } namespaces { diff --git a/modules/kubernetes/konnectivity-agent/metrics.alloy b/modules/kubernetes/konnectivity-agent/metrics.alloy index 023b255..03aadb2 100644 --- a/modules/kubernetes/konnectivity-agent/metrics.alloy +++ b/modules/kubernetes/konnectivity-agent/metrics.alloy @@ -38,8 +38,8 @@ declare "kubernetes" { selectors { role = "pod" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["k8s-app=konnectivity-agent"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["k8s-app=konnectivity-agent"]), ",") } namespaces { diff --git a/modules/kubernetes/kube-state-metrics/metrics.alloy b/modules/kubernetes/kube-state-metrics/metrics.alloy index 300bdd2..9d8445a 100644 --- a/modules/kubernetes/kube-state-metrics/metrics.alloy +++ b/modules/kubernetes/kube-state-metrics/metrics.alloy @@ -39,8 +39,8 @@ declare "kubernetes" { selectors { role = "service" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=kube-state-metrics"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=kube-state-metrics"]), ",") } namespaces { diff --git a/modules/kubernetes/opencost/metrics.alloy b/modules/kubernetes/opencost/metrics.alloy index b114f25..56b03cb 100644 --- a/modules/kubernetes/opencost/metrics.alloy +++ b/modules/kubernetes/opencost/metrics.alloy @@ -37,8 +37,8 @@ declare "kubernetes" { selectors { role = "service" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=opencost"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=opencost"]), ",") } namespaces { diff --git a/modules/networking/consul/metrics.alloy b/modules/networking/consul/metrics.alloy index 18d50fe..49637a4 100644 --- a/modules/networking/consul/metrics.alloy +++ b/modules/networking/consul/metrics.alloy @@ -37,8 +37,8 @@ declare "kubernetes" { selectors { role = "pod" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["app=consul"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["app=consul"]), ",") } namespaces { @@ -153,7 +153,7 @@ declare "local" { discovery.relabel "local" { targets = [ { - "__address__" = "localhost" + format("%s", coalesce(argument.port.value, "9150")), + "__address__" = "localhost" + string.format("%s", coalesce(argument.port.value, "9150")), "source" = "local", }, ] diff --git a/modules/networking/haproxy/metrics.alloy b/modules/networking/haproxy/metrics.alloy index 244ed19..c837831 100644 --- a/modules/networking/haproxy/metrics.alloy +++ b/modules/networking/haproxy/metrics.alloy @@ -37,8 +37,8 @@ declare "kubernetes" { selectors { role = "pod" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/component=haproxy"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/component=haproxy"]), ",") } namespaces { @@ -153,7 +153,7 @@ declare "local" { discovery.relabel "local" { targets = [ { - "__address__" = "localhost" + format("%s", coalesce(argument.port.value, "8405")), + "__address__" = "localhost" + string.format("%s", coalesce(argument.port.value, "8405")), "source" = "local", }, ] diff --git a/modules/source-control/gitlab/metrics.alloy b/modules/source-control/gitlab/metrics.alloy index 9120c49..e4e70c9 100644 --- a/modules/source-control/gitlab/metrics.alloy +++ b/modules/source-control/gitlab/metrics.alloy @@ -37,8 +37,8 @@ declare "kubernetes" { selectors { role = "service" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=gitlab-ci-pipelines-exporter"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=gitlab-ci-pipelines-exporter"]), ",") } namespaces { @@ -119,7 +119,7 @@ declare "local" { discovery.relabel "local" { targets = [ { - "__address__" = "localhost" + format("%s", coalesce(argument.port.value, "9168")), + "__address__" = "localhost" + string.format("%s", coalesce(argument.port.value, "9168")), "source" = "local", }, ] diff --git a/modules/system/node-exporter/metrics.alloy b/modules/system/node-exporter/metrics.alloy index 5fdeed9..fa66dc5 100644 --- a/modules/system/node-exporter/metrics.alloy +++ b/modules/system/node-exporter/metrics.alloy @@ -37,8 +37,8 @@ declare "kubernetes" { selectors { role = "pod" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=prometheus-node-exporter"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=prometheus-node-exporter"]), ",") } namespaces { @@ -153,7 +153,7 @@ declare "local" { discovery.relabel "local" { targets = [ { - "__address__" = "localhost" + format("%s", coalesce(argument.port.value, "9100")), + "__address__" = "localhost" + string.format("%s", coalesce(argument.port.value, "9100")), "source" = "local", }, ] diff --git a/modules/ui/grafana/metrics.alloy b/modules/ui/grafana/metrics.alloy index b21cb26..c54fce5 100644 --- a/modules/ui/grafana/metrics.alloy +++ b/modules/ui/grafana/metrics.alloy @@ -37,8 +37,8 @@ declare "kubernetes" { selectors { role = "pod" - field = join(coalesce(argument.field_selectors.value, []), ",") - label = join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=grafana"]), ",") + field = string.join(coalesce(argument.field_selectors.value, []), ",") + label = string.join(coalesce(argument.label_selectors.value, ["app.kubernetes.io/name=grafana"]), ",") } namespaces { @@ -153,7 +153,7 @@ declare "local" { discovery.relabel "local" { targets = [ { - "__address__" = "localhost" + format("%s", coalesce(argument.port.value, "3000")), + "__address__" = "localhost" + string.format("%s", coalesce(argument.port.value, "3000")), "source" = "local", }, ]