diff --git a/CHANGELOG.md b/CHANGELOG.md index 19c7c0a3c19..aba480eee3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,8 +18,6 @@ Main (unreleased) - The `enable_http2` in `prometheus.remote_write` component's endpoints has been changed to `false` by default. Previously, in Prometheus v2 the remote write http client would default to use http2. In order to parallelize multiple remote write queues across multiple sockets its preferable to not default to http2. If you prefer to use http2 for remote write you must now set `enable_http2` to `true` in your `prometheus.remote_write` endpoints configuration section. - - Prometheus components such as `prometheus.scrape` and `prometheus.operator.*` now support UTF-8 in metric and label names by default. This means metric and label names can change after upgrading according to what is exposed by endpoints. Furthermore, metric and label names that would have previously been flagged as invalid no longer will be. Users wishing to preserve the original validation behavior can update their `prometheus.scrape` configuration to specify the legacy validation scheme: `metric_name_validation_scheme = "legacy"` and optionally setting the `metric_name_escaping_scheme` to a desired value. See `prometheus.scrape` reference documentation. - - The experimental CLI flag `--feature.prometheus.metric-validation-scheme` has been deprecated and has no effect. You can configure the metric validation scheme individually for each `prometheus.scrape` component. - Log message format has changed for some of the `prometheus.*` components as part of the upgrade to Prometheus v3. @@ -41,7 +39,7 @@ Main (unreleased) ### Enhancements -- `prometheus.scrape` now supports `convert_classic_histograms_to_nhcb`, `enable_compression`, `native_histogram_bucket_limit`, and `native_histogram_min_bucket_factor` arguments. (@thampiotr) +- `prometheus.scrape` now supports `convert_classic_histograms_to_nhcb`, `enable_compression`, `metric_name_validation_scheme`, `metric_name_escaping_scheme`, `native_histogram_bucket_limit`, and `native_histogram_min_bucket_factor` arguments. See reference documentation for more details. (@thampiotr) - Add `max_send_message_size` configuration option to `loki.source.api` component to control the maximum size of requests to the push API. (@thampiotr) diff --git a/docs/sources/reference/components/prometheus/prometheus.scrape.md b/docs/sources/reference/components/prometheus/prometheus.scrape.md index 6a2e89c39d7..0d78aa54dc4 100644 --- a/docs/sources/reference/components/prometheus/prometheus.scrape.md +++ b/docs/sources/reference/components/prometheus/prometheus.scrape.md @@ -37,47 +37,47 @@ If conflicting attributes are passed, for example, defining both a BearerToken a You can use the following arguments with `prometheus.scrape`: -| Name | Type | Description | Default | Required | -|--------------------------------------|-------------------------|--------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------|----------| -| `forward_to` | `list(MetricsReceiver)` | List of receivers to send scraped metrics to. | | yes | -| `targets` | `list(map(string))` | List of targets to scrape. | | yes | -| `bearer_token_file` | `string` | File containing a bearer token to authenticate with. | | no | -| `bearer_token` | `secret` | Bearer token to authenticate with. | | no | -| `body_size_limit` | `int` | An uncompressed response body larger than this many bytes causes the scrape to fail. 0 means no limit. | | no | -| `convert_classic_histograms_to_nhcb` | `bool` | Whether to convert classic histograms to native histograms with custom buckets (NHCB). | `false` | no | -| `enable_compression` | `bool` | Whether compression is enabled for the scrape. | `true` | no | -| `enable_http2` | `bool` | Whether HTTP2 is supported for requests. | `true` | no | -| `enable_protobuf_negotiation` | `bool` | Deprecated: use `scrape_protocols` instead. | `false` | no | -| `extra_metrics` | `bool` | Whether extra metrics should be generated for scrape targets. | `false` | no | -| `follow_redirects` | `bool` | Whether redirects returned by the server should be followed. | `true` | no | -| `http_headers` | `map(list(secret))` | Custom HTTP headers to be sent along with each request. The map key is the header name. | | no | -| `honor_labels` | `bool` | Indicator whether the scraped metrics should remain unmodified. | `false` | no | -| `honor_timestamps` | `bool` | Indicator whether the scraped timestamps should be respected. | `true` | no | -| `job_name` | `string` | The value to use for the job label if not already set. | component name | no | -| `label_limit` | `uint` | More than this many labels post metric-relabeling causes the scrape to fail. | | no | -| `label_name_length_limit` | `uint` | More than this label name length post metric-relabeling causes the scrape to fail. | | no | -| `label_value_length_limit` | `uint` | More than this label value length post metric-relabeling causes the scrape to fail. | | no | -| `metric_name_escaping_scheme` | `string` | The escaping scheme to use for metric names. See below for available values. | `"allow-utf-8"` | no | -| `metric_name_validation_scheme` | `string` | The validation scheme to use for metric names. See below for available values. | `"utf8"` | no | -| `metrics_path` | `string` | The HTTP resource path on which to fetch metrics from targets. | `"/metrics"` | no | -| `native_histogram_bucket_limit` | `uint` | Native histogram buckets will be merged to stay within this limit. Disabled when set to zero. | `0` | no | -| `native_histogram_min_bucket_factor` | `float64` | If the growth from one bucket to the next is smaller than this, buckets will be merged. Disabled when set to zero. | `0` | no | -| `no_proxy` | `string` | Comma-separated list of IP addresses, CIDR notations, and domain names to exclude from proxying. | | no | -| `params` | `map(list(string))` | A set of query parameters with which the target is scraped. | | no | -| `proxy_connect_header` | `map(list(secret))` | Specifies headers to send to proxies during CONNECT requests. | | no | -| `proxy_from_environment` | `bool` | Use the proxy URL indicated by environment variables. | `false` | no | -| `proxy_url` | `string` | HTTP proxy to send requests through. | | no | -| `sample_limit` | `uint` | More than this many samples post metric-relabeling causes the scrape to fail | | no | -| `scheme` | `string` | The URL scheme with which to fetch metrics from targets. | | no | -| `scrape_classic_histograms` | `bool` | Whether to scrape a classic histogram that's also exposed as a native histogram. | `false` | no | -| `scrape_failure_log_file` | `string` | File to which scrape failures are logged. | `""` | no | -| `scrape_fallback_protocol` | `string` | The fallback protocol to use if the target does not provide a valid Content-Type header. See below for available values. | `PrometheusText0_0_4` | no | -| `scrape_interval` | `duration` | How frequently to scrape the targets of this scrape configuration. | `"60s"` | no | -| `scrape_native_histograms` | `bool` | Whether to scrape native histograms. | `true` | no | -| `scrape_protocols` | `list(string)` | The protocols to negotiate during a scrape, in order of preference. See below for available values. | `["OpenMetricsText1.0.0", "OpenMetricsText0.0.1", "PrometheusText0.0.4"]` | no | -| `scrape_timeout` | `duration` | The timeout for scraping targets of this configuration. | `"10s"` | no | -| `target_limit` | `uint` | More than this many targets after the target relabeling causes the scrapes to fail. | | no | -| `track_timestamps_staleness` | `bool` | Indicator whether to track the staleness of the scraped timestamps. | `false` | no | +| Name | Type | Description | Default | Required | +|--------------------------------------|-------------------------|--------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|----------| +| `forward_to` | `list(MetricsReceiver)` | List of receivers to send scraped metrics to. | | yes | +| `targets` | `list(map(string))` | List of targets to scrape. | | yes | +| `bearer_token_file` | `string` | File containing a bearer token to authenticate with. | | no | +| `bearer_token` | `secret` | Bearer token to authenticate with. | | no | +| `body_size_limit` | `int` | An uncompressed response body larger than this many bytes causes the scrape to fail. 0 means no limit. | | no | +| `convert_classic_histograms_to_nhcb` | `bool` | Whether to convert classic histograms to native histograms with custom buckets (NHCB). | `false` | no | +| `enable_compression` | `bool` | Whether compression is enabled for the scrape. | `true` | no | +| `enable_http2` | `bool` | Whether HTTP2 is supported for requests. | `true` | no | +| `enable_protobuf_negotiation` | `bool` | Deprecated: use `scrape_protocols` instead. | `false` | no | +| `extra_metrics` | `bool` | Whether extra metrics should be generated for scrape targets. Currently, cannot be updated at runtime. | `false` | no | +| `follow_redirects` | `bool` | Whether redirects returned by the server should be followed. | `true` | no | +| `http_headers` | `map(list(secret))` | Custom HTTP headers to be sent along with each request. The map key is the header name. | | no | +| `honor_labels` | `bool` | Indicator whether the scraped metrics should remain unmodified. | `false` | no | +| `honor_timestamps` | `bool` | Indicator whether the scraped timestamps should be respected. | `true` | no | +| `job_name` | `string` | The value to use for the job label if not already set. | component name | no | +| `label_limit` | `uint` | More than this many labels post metric-relabeling causes the scrape to fail. | | no | +| `label_name_length_limit` | `uint` | More than this label name length post metric-relabeling causes the scrape to fail. | | no | +| `label_value_length_limit` | `uint` | More than this label value length post metric-relabeling causes the scrape to fail. | | no | +| `metric_name_escaping_scheme` | `string` | The escaping scheme to use for metric names. See below for available values. | `"underscores"` | no | +| `metric_name_validation_scheme` | `string` | The validation scheme to use for metric names. See below for available values. | `"legacy"` | no | +| `metrics_path` | `string` | The HTTP resource path on which to fetch metrics from targets. | `"/metrics"` | no | +| `native_histogram_bucket_limit` | `uint` | Native histogram buckets will be merged to stay within this limit. Disabled when set to zero. | `0` | no | +| `native_histogram_min_bucket_factor` | `float64` | If the growth from one bucket to the next is smaller than this, buckets will be merged. Disabled when set to zero. | `0` | no | +| `no_proxy` | `string` | Comma-separated list of IP addresses, CIDR notations, and domain names to exclude from proxying. | | no | +| `params` | `map(list(string))` | A set of query parameters with which the target is scraped. | | no | +| `proxy_connect_header` | `map(list(secret))` | Specifies headers to send to proxies during CONNECT requests. | | no | +| `proxy_from_environment` | `bool` | Use the proxy URL indicated by environment variables. | `false` | no | +| `proxy_url` | `string` | HTTP proxy to send requests through. | | no | +| `sample_limit` | `uint` | More than this many samples post metric-relabeling causes the scrape to fail | | no | +| `scheme` | `string` | The URL scheme with which to fetch metrics from targets. | | no | +| `scrape_classic_histograms` | `bool` | Whether to scrape a classic histogram that's also exposed as a native histogram. | `false` | no | +| `scrape_failure_log_file` | `string` | File to which scrape failures are logged. | `""` | no | +| `scrape_fallback_protocol` | `string` | The fallback protocol to use if the target does not provide a valid Content-Type header. See below for available values. | `PrometheusText0_0_4` | no | +| `scrape_interval` | `duration` | How frequently to scrape the targets of this scrape configuration. | `"60s"` | no | +| `scrape_native_histograms` | `bool` | Whether to scrape native histograms. Currently, cannot be updated at runtime. | `false` | no | +| `scrape_protocols` | `list(string)` | The protocols to negotiate during a scrape, in order of preference. See below for available values. | `["OpenMetricsText1.0.0", "OpenMetricsText0.0.1", "PrometheusText1.0.0", "PrometheusText0.0.4"]` | no | +| `scrape_timeout` | `duration` | The timeout for scraping targets of this configuration. | `"10s"` | no | +| `target_limit` | `uint` | More than this many targets after the target relabeling causes the scrapes to fail. | | no | +| `track_timestamps_staleness` | `bool` | Indicator whether to track the staleness of the scraped timestamps. | `false` | no | At most, one of the following can be provided: @@ -94,6 +94,7 @@ The following values are supported: * `OpenMetricsText1.0.0` * `PrometheusProto` * `PrometheusText0.0.4` +* `PrometheusText1.0.0` You can also use the `scrape_fallback_protocol` argument to specify a fallback protocol to use if the target does not provide a valid Content-Type header. @@ -102,10 +103,13 @@ If you were using the deprecated `enable_protobuf_negotiation` argument, switch For now, native histograms are only available through the Prometheus Protobuf exposition format. To scrape native histograms, `scrape_native_histograms` must be set to `true` and the first item in `scrape_protocols` must be `PrometheusProto`. +The default value for `scrape_protocols` changes to `["PrometheusProto", "OpenMetricsText1.0.0", "OpenMetricsText0.0.1", "PrometheusText1.0.0", "PrometheusText0.0.4"]` when +`scrape_native_histograms` is set to `true`. + The `metric_name_validation_scheme` controls how metric names are validated. The following values are supported: -* `"utf8"` - Uses UTF-8 validation scheme (default) -* `"legacy"` - Uses legacy validation scheme which was default in Prometheus v2. +* `"utf8"` - Uses UTF-8 validation scheme. +* `"legacy"` - Uses legacy validation scheme which was default in Prometheus v2 (default). The `metric_name_escaping_scheme` controls how metric names are escaped. The following values are supported: diff --git a/docs/sources/release-notes.md b/docs/sources/release-notes.md index 17c4ee589ff..26906e532df 100644 --- a/docs/sources/release-notes.md +++ b/docs/sources/release-notes.md @@ -24,8 +24,6 @@ Prometheus dependency had a major version upgrade from v2.55.1 to v3.4.2. - The `enable_http2` in `prometheus.remote_write` component's endpoints has been changed to `false` by default. Previously, in Prometheus v2 the remote write http client would default to use http2. In order to parallelize multiple remote write queues across multiple sockets its preferable to not default to http2. If you prefer to use http2 for remote write you must now set `enable_http2` to `true` in your `prometheus.remote_write` endpoints configuration section. -- Prometheus components such as `prometheus.scrape` and `prometheus.operator.*` now support UTF-8 in metric and label names by default. This means metric and label names can change after upgrading according to what is exposed by endpoints. Furthermore, metric and label names that would have previously been flagged as invalid no longer will be. Users wishing to preserve the original validation behavior can update their `prometheus.scrape` configuration to specify the legacy validation scheme: `metric_name_validation_scheme = "legacy"` and optionally setting the `metric_name_escaping_scheme` to a desired value. See `prometheus.scrape` reference documentation. - - The experimental CLI flag `--feature.prometheus.metric-validation-scheme` has been deprecated and has no effect. You can configure the metric validation scheme individually for each `prometheus.scrape` component. - Log message format has changed for some of the `prometheus.*` components as part of the upgrade to Prometheus v3. diff --git a/go.mod b/go.mod index 116a846657c..f541bc6ad86 100644 --- a/go.mod +++ b/go.mod @@ -188,7 +188,7 @@ require ( github.com/prometheus/blackbox_exporter v0.24.1-0.20230623125439-bd22efa1c900 github.com/prometheus/client_golang v1.22.0 github.com/prometheus/client_model v0.6.2 - github.com/prometheus/common v0.65.0 + github.com/prometheus/common v0.65.1-0.20250804173848-0ad974f9af53 github.com/prometheus/consul_exporter v0.8.0 github.com/prometheus/memcached_exporter v0.13.0 github.com/prometheus/mysqld_exporter v0.17.2 @@ -1056,7 +1056,7 @@ replace github.com/fsnotify/fsnotify v1.8.0 => github.com/fsnotify/fsnotify v1.7 // TODO: remove replace directive once: // * There is a release of Prometheus which addresses https://github.com/prometheus/prometheus/issues/14049, // for example, via this implementation: https://github.com/grafana/prometheus/pull/34 -replace github.com/prometheus/prometheus => github.com/grafana/prometheus v1.8.2-0.20250709144109-5551df55271b +replace github.com/prometheus/prometheus => github.com/thampiotr/prometheus v0.0.0-20250731131506-a28a7d9c5b3b // staleness_disabling_v3.4.2 branch replace gopkg.in/yaml.v2 => github.com/rfratto/go-yaml v0.0.0-20211119180816-77389c3526dc diff --git a/go.sum b/go.sum index b5d2d732d5b..3553507b34c 100644 --- a/go.sum +++ b/go.sum @@ -1328,8 +1328,6 @@ github.com/grafana/otel-profiling-go v0.5.1 h1:stVPKAFZSa7eGiqbYuG25VcqYksR6iWvF github.com/grafana/otel-profiling-go v0.5.1/go.mod h1:ftN/t5A/4gQI19/8MoWurBEtC6gFw8Dns1sJZ9W4Tls= github.com/grafana/postgres_exporter v0.0.0-20250714124518-c5d0a4dad445 h1:1rC8i0khfZdRA0/k7RBQQ84PhASNQLssezXHmFcWZ6Y= github.com/grafana/postgres_exporter v0.0.0-20250714124518-c5d0a4dad445/go.mod h1:0elZWWHfbwJNwKbiKgBKaEXTDewatxCt9UFZaN6LZsA= -github.com/grafana/prometheus v1.8.2-0.20250709144109-5551df55271b h1:7e6NMPNpqETo6ID2oddAl7+Vt91SrpGGP3v7qwgrgG0= -github.com/grafana/prometheus v1.8.2-0.20250709144109-5551df55271b/go.mod h1:ioGx2SGKTY+fLnJSQCdTHqARVldGNS8OlIe3kvp98so= github.com/grafana/pyroscope-go/godeltaprof v0.1.8 h1:iwOtYXeeVSAeYefJNaxDytgjKtUuKQbJqgAIjlnicKg= github.com/grafana/pyroscope-go/godeltaprof v0.1.8/go.mod h1:2+l7K7twW49Ct4wFluZD3tZ6e0SjanjcUUBPVD/UuGU= github.com/grafana/pyroscope/api v1.2.0 h1:SfHDZcEZ4Vbj/Jj3bTOSpm4IDB33wLA2xBYxROhiL4U= @@ -2372,8 +2370,8 @@ github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9 github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.31.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.65.0 h1:QDwzd+G1twt//Kwj/Ww6E9FQq1iVMmODnILtW1t2VzE= -github.com/prometheus/common v0.65.0/go.mod h1:0gZns+BLRQ3V6NdaerOhMbwwRbNh9hkGINtQAsP5GS8= +github.com/prometheus/common v0.65.1-0.20250804173848-0ad974f9af53 h1:9UzEu3LNsyYUSEkNU6mfBwG8TpiURfaJQgz1rVQKmhs= +github.com/prometheus/common v0.65.1-0.20250804173848-0ad974f9af53/go.mod h1:LL3lcZII3UXGO4InbF+BTSsiAAPUBnwFVbp4gBWIMqw= github.com/prometheus/common/assets v0.2.0 h1:0P5OrzoHrYBOSM1OigWL3mY8ZvV2N4zIE/5AahrSrfM= github.com/prometheus/common/assets v0.2.0/go.mod h1:D17UVUE12bHbim7HzwUvtqm6gwBEaDQ0F+hIGbFbccI= github.com/prometheus/common/sigv4 v0.1.0 h1:qoVebwtwwEhS85Czm2dSROY5fTo2PAPEVdDeppTwGX4= @@ -2613,6 +2611,8 @@ github.com/testcontainers/testcontainers-go/modules/mongodb v0.34.0 h1:o3bgcECyB github.com/testcontainers/testcontainers-go/modules/mongodb v0.34.0/go.mod h1:ljLR42dN7k40CX0dp30R8BRIB3OOdvr7rBANEpfmMs4= github.com/tg123/go-htpasswd v1.2.4 h1:HgH8KKCjdmo7jjXWN9k1nefPBd7Be3tFCTjc2jPraPU= github.com/tg123/go-htpasswd v1.2.4/go.mod h1:EKThQok9xHkun6NBMynNv6Jmu24A33XdZzzl4Q7H1+0= +github.com/thampiotr/prometheus v0.0.0-20250731131506-a28a7d9c5b3b h1:OIY3jwIlF38C4a4uLw8PrnzzSEmwyMRgUUGCtfmQDTg= +github.com/thampiotr/prometheus v0.0.0-20250731131506-a28a7d9c5b3b/go.mod h1:ioGx2SGKTY+fLnJSQCdTHqARVldGNS8OlIe3kvp98so= github.com/theupdateframework/notary v0.7.0 h1:QyagRZ7wlSpjT5N2qQAh/pN+DVqgekv4DzbAiAiEL3c= github.com/theupdateframework/notary v0.7.0/go.mod h1:c9DRxcmhHmVLDay4/2fUYdISnHqbFDGRSlXPO0AhYWw= github.com/tidwall/gjson v1.10.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= diff --git a/internal/cmd/integration-tests/tests/scrape-prom-metrics/config.alloy b/internal/cmd/integration-tests/tests/scrape-prom-metrics/config.alloy index 2c4b66dbb97..a1a878c00f9 100644 --- a/internal/cmd/integration-tests/tests/scrape-prom-metrics/config.alloy +++ b/internal/cmd/integration-tests/tests/scrape-prom-metrics/config.alloy @@ -1,28 +1,29 @@ +logging { + level = "debug" +} + +livedebugging {} + prometheus.scrape "scrape_prom_metrics" { targets = [ {"__address__" = "prom-gen:9001"}, ] - forward_to = [prometheus.remote_write.scrape_prom_metrics.receiver, otelcol.receiver.prometheus.scrape_prom_metrics_to_otlp.receiver] + forward_to = [prometheus.write.queue.scrape_prom_metrics.receiver, otelcol.receiver.prometheus.scrape_prom_metrics_to_otlp.receiver] scrape_classic_histograms = true - scrape_protocols = ["PrometheusProto", "OpenMetricsText1.0.0", "OpenMetricsText0.0.1", "PrometheusText0.0.4"] + scrape_native_histograms = true scrape_interval = "1s" scrape_timeout = "500ms" } -prometheus.remote_write "scrape_prom_metrics" { - endpoint { - url = "http://mimir:9009/api/v1/push" - send_native_histograms = true - metadata_config { - send_interval = "1s" +prometheus.write.queue "scrape_prom_metrics" { + endpoint "mimir" { + url = "http://mimir:9009/api/v1/push" + flush_interval = "1s" + batch_count = 10 + external_labels = { + test_name = "scrape_prom_metrics", + } } - queue_config { - max_samples_per_send = 100 - } - } - external_labels = { - test_name = "scrape_prom_metrics", - } } otelcol.receiver.prometheus "scrape_prom_metrics_to_otlp" { diff --git a/internal/component/common/net/server.go b/internal/component/common/net/server.go index ba75ddc6c88..e687d850af2 100644 --- a/internal/component/common/net/server.go +++ b/internal/component/common/net/server.go @@ -5,10 +5,11 @@ import ( "github.com/go-kit/log" "github.com/gorilla/mux" - "github.com/grafana/alloy/internal/runtime/logging/level" dskit "github.com/grafana/dskit/server" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" + + "github.com/grafana/alloy/internal/runtime/logging/level" ) // TargetServer is wrapper around dskit.Server that handles some common @@ -25,6 +26,8 @@ type TargetServer struct { // NewTargetServer creates a new TargetServer, applying some defaults to the server configuration. // If provided config is nil, a default configuration will be used instead. func NewTargetServer(logger log.Logger, metricsNamespace string, reg prometheus.Registerer, config *ServerConfig) (*TargetServer, error) { + // TODO: add support for different validation schemes. + //nolint:staticcheck if !model.IsValidMetricName(model.LabelValue(metricsNamespace)) { return nil, fmt.Errorf("metrics namespace is not prometheus compatible: %s", metricsNamespace) } diff --git a/internal/component/common/relabel/relabel.go b/internal/component/common/relabel/relabel.go index f406cbcf8c1..d3b3555720d 100644 --- a/internal/component/common/relabel/relabel.go +++ b/internal/component/common/relabel/relabel.go @@ -171,12 +171,16 @@ func (rc *Config) Validate() error { if (rc.Action == Replace || rc.Action == HashMod || rc.Action == Lowercase || rc.Action == Uppercase || rc.Action == KeepEqual || rc.Action == DropEqual) && rc.TargetLabel == "" { return fmt.Errorf("relabel configuration for %s action requires 'target_label' value", rc.Action) } + // TODO: add support for different validation schemes. + //nolint:staticcheck if rc.Action == Replace && !strings.Contains(rc.TargetLabel, "$") && !model.LabelName(rc.TargetLabel).IsValid() { return fmt.Errorf("%q is invalid 'target_label' for %s action", rc.TargetLabel, rc.Action) } if rc.Action == Replace && strings.Contains(rc.TargetLabel, "$") && !relabelTarget.MatchString(rc.TargetLabel) { return fmt.Errorf("%q is invalid 'target_label' for %s action", rc.TargetLabel, rc.Action) } + // TODO: add support for different validation schemes. + //nolint:staticcheck if (rc.Action == Lowercase || rc.Action == Uppercase || rc.Action == KeepEqual || rc.Action == DropEqual) && !model.LabelName(rc.TargetLabel).IsValid() { return fmt.Errorf("%q is invalid 'target_label' for %s action", rc.TargetLabel, rc.Action) } @@ -186,6 +190,8 @@ func (rc *Config) Validate() error { if rc.Action == LabelMap && !relabelTarget.MatchString(rc.Replacement) { return fmt.Errorf("%q is invalid 'replacement' for %s action", rc.Replacement, rc.Action) } + // TODO: add support for different validation schemes. + //nolint:staticcheck if rc.Action == HashMod && !model.LabelName(rc.TargetLabel).IsValid() { return fmt.Errorf("%q is invalid 'target_label' for %s action", rc.TargetLabel, rc.Action) } @@ -261,6 +267,8 @@ func doRelabel(cfg *Config, lb LabelBuilder) (keep bool) { break } target := model.LabelName(cfg.Regex.ExpandString([]byte{}, cfg.TargetLabel, val, indexes)) + // TODO: add support for different validation schemes. + //nolint:staticcheck if !target.IsValid() { break } diff --git a/internal/component/loki/process/metric/metricvec.go b/internal/component/loki/process/metric/metricvec.go index 9069bd555da..23e00e9fc7f 100644 --- a/internal/component/loki/process/metric/metricvec.go +++ b/internal/component/loki/process/metric/metricvec.go @@ -67,6 +67,8 @@ func cleanLabels(set model.LabelSet) model.LabelSet { for k, v := range set { // Performing the same label validity check the prometheus go client library does. // https://github.com/prometheus/client_golang/blob/618194de6ad3db637313666104533639011b470d/prometheus/labels.go#L85 + // TODO: add support for different validation schemes. + //nolint:staticcheck if !k.IsValid() || strings.HasPrefix(string(k), "__") { continue } diff --git a/internal/component/loki/process/stages/eventlogmessage.go b/internal/component/loki/process/stages/eventlogmessage.go index bd4cbd0bf77..baf039ac616 100644 --- a/internal/component/loki/process/stages/eventlogmessage.go +++ b/internal/component/loki/process/stages/eventlogmessage.go @@ -20,6 +20,8 @@ type EventLogMessageConfig struct { } func (e *EventLogMessageConfig) Validate() error { + // TODO: add support for different validation schemes. + //nolint:staticcheck if !model.LabelName(e.Source).IsValidLegacy() { return fmt.Errorf(ErrInvalidLabelName, e.Source) } @@ -82,6 +84,8 @@ func (m *eventLogMessageStage) processEntry(extracted map[string]interface{}, ke continue } mkey := parts[0] + // TODO: add support for different validation schemes. + //nolint:staticcheck if !model.LabelName(mkey).IsValidLegacy() { if m.cfg.DropInvalidLabels { if Debug { diff --git a/internal/component/loki/process/stages/labels.go b/internal/component/loki/process/stages/labels.go index 4764017184f..6ee540ccae1 100644 --- a/internal/component/loki/process/stages/labels.go +++ b/internal/component/loki/process/stages/labels.go @@ -30,6 +30,8 @@ func validateLabelsConfig(c LabelsConfig) (map[string]string, error) { return nil, errors.New(ErrEmptyLabelStageConfig) } for labelName, labelSrc := range c.Values { + // TODO: add support for different validation schemes. + //nolint:staticcheck if !model.LabelName(labelName).IsValid() { return nil, fmt.Errorf(ErrInvalidLabelName, labelName) } diff --git a/internal/component/loki/process/stages/regex.go b/internal/component/loki/process/stages/regex.go index 0c74346a2a9..3164b563619 100644 --- a/internal/component/loki/process/stages/regex.go +++ b/internal/component/loki/process/stages/regex.go @@ -123,6 +123,8 @@ func (r *regexStage) Process(labels model.LabelSet, extracted map[string]interfa labelName := model.LabelName(name) labelValue := model.LabelValue(match[i]) + // TODO: add support for different validation schemes. + //nolint:staticcheck if !labelName.IsValid() { if Debug { level.Debug(r.logger).Log("msg", "invalid label name from regex capture group", "labelName", labelName) diff --git a/internal/component/loki/process/stages/static_labels.go b/internal/component/loki/process/stages/static_labels.go index d3f372844af..75231263645 100644 --- a/internal/component/loki/process/stages/static_labels.go +++ b/internal/component/loki/process/stages/static_labels.go @@ -37,6 +37,8 @@ func validateLabelStaticConfig(c StaticLabelsConfig) error { return ErrEmptyStaticLabelStageConfig } for labelName := range c.Values { + // TODO: add support for different validation schemes. + //nolint:staticcheck if !model.LabelName(labelName).IsValid() { return fmt.Errorf(ErrInvalidLabelName, labelName) } diff --git a/internal/component/loki/process/stages/windowsevent.go b/internal/component/loki/process/stages/windowsevent.go index 57ff96e045a..a2e5b352c49 100644 --- a/internal/component/loki/process/stages/windowsevent.go +++ b/internal/component/loki/process/stages/windowsevent.go @@ -22,6 +22,8 @@ type WindowsEventConfig struct { } func (e *WindowsEventConfig) Validate() error { + // TODO: add support for different validation schemes. + //nolint:staticcheck if !model.LabelName(e.Source).IsValid() { return fmt.Errorf(ErrInvalidLabelName, e.Source) } @@ -165,6 +167,8 @@ func (w *WindowsEventStage) processEntry(extracted map[string]interface{}, key s func (w *WindowsEventStage) sanitizeKey(ekey string, extracted map[string]interface{}) (string, error) { k := w.keyReplacer.Replace(ekey) + // TODO: add support for different validation schemes. + //nolint:staticcheck if !model.LabelName(k).IsValid() { if w.cfg.DropInvalidLabels { return "", fmt.Errorf("invalid label parsed from message, key: %s", k) diff --git a/internal/component/loki/source/aws_firehose/internal/handler.go b/internal/component/loki/source/aws_firehose/internal/handler.go index e43e4ee67bd..de2c2c5997b 100644 --- a/internal/component/loki/source/aws_firehose/internal/handler.go +++ b/internal/component/loki/source/aws_firehose/internal/handler.go @@ -194,6 +194,8 @@ func (h *Handler) postProcessLabels(lbs labels.Labels) model.LabelSet { } // ignore invalid labels + // TODO: add support for different validation schemes. + //nolint:staticcheck if !model.LabelName(lbl.Name).IsValidLegacy() || !model.LabelValue(lbl.Value).IsValid() { continue } @@ -319,12 +321,16 @@ func (h *Handler) tryToGetStaticLabelsFromRequest(req *http.Request, tenantID st // construct model.LabelName from the header value, if the raw data is not valid label name, try to fix it and use rawLabelName := strings.TrimPrefix(name, commonAttributesLabelPrefix) labelName := model.LabelName(rawLabelName) + // TODO: add support for different validation schemes. + //nolint:staticcheck if !labelName.IsValidLegacy() { level.Debug(h.logger).Log(fmt.Sprintf("label name is not valid, trying to fix: %s", rawLabelName)) // try to sanitize label name sanitizedLabelName := yacepromutil.PromString(rawLabelName) labelName = model.LabelName(sanitizedLabelName) + // TODO: add support for different validation schemes. + //nolint:staticcheck if !labelName.IsValidLegacy() { // This situation can happen when: // - the header with label information is a valid JSON diff --git a/internal/component/loki/source/azure_event_hubs/internal/parser/parser.go b/internal/component/loki/source/azure_event_hubs/internal/parser/parser.go index 8b3ec7f6060..81390740e62 100644 --- a/internal/component/loki/source/azure_event_hubs/internal/parser/parser.go +++ b/internal/component/loki/source/azure_event_hubs/internal/parser/parser.go @@ -222,6 +222,8 @@ func (e *AzureEventHubsTargetMessageParser) getLabels(logRecord *azureMonitorRes continue } // ignore invalid labels + // TODO: add support for different validation schemes. + //nolint:staticcheck if !model.LabelName(lbl.Name).IsValid() || !model.LabelValue(lbl.Value).IsValid() { continue } diff --git a/internal/component/loki/source/gcplog/internal/gcplogtarget/formatter.go b/internal/component/loki/source/gcplog/internal/gcplogtarget/formatter.go index 36aa71ee6b1..5a939234c11 100644 --- a/internal/component/loki/source/gcplog/internal/gcplogtarget/formatter.go +++ b/internal/component/loki/source/gcplog/internal/gcplogtarget/formatter.go @@ -89,6 +89,8 @@ func parseGCPLogsEntry(data []byte, other model.LabelSet, otherInternal labels.L continue } // ignore invalid labels + // TODO: add support for different validation schemes. + //nolint:staticcheck if !model.LabelName(lbl.Name).IsValid() || !model.LabelValue(lbl.Value).IsValid() { continue } diff --git a/internal/component/prometheus/operator/configgen/config_gen_podmonitor_test.go b/internal/component/prometheus/operator/configgen/config_gen_podmonitor_test.go index 74e06d90f28..e2edd88d72d 100644 --- a/internal/component/prometheus/operator/configgen/config_gen_podmonitor_test.go +++ b/internal/component/prometheus/operator/configgen/config_gen_podmonitor_test.go @@ -89,8 +89,8 @@ func TestGeneratePodMonitorConfig(t *testing.T) { }, }, ConvertClassicHistogramsToNHCB: ptr.To(false), - MetricNameValidationScheme: "utf8", - MetricNameEscapingScheme: "allow-utf-8", + MetricNameValidationScheme: "legacy", + MetricNameEscapingScheme: "underscores", }, }, { @@ -150,8 +150,8 @@ func TestGeneratePodMonitorConfig(t *testing.T) { }, }, ConvertClassicHistogramsToNHCB: ptr.To(false), - MetricNameValidationScheme: "utf8", - MetricNameEscapingScheme: "allow-utf-8", + MetricNameValidationScheme: "legacy", + MetricNameEscapingScheme: "underscores", }, }, { @@ -211,8 +211,8 @@ func TestGeneratePodMonitorConfig(t *testing.T) { }, }, ConvertClassicHistogramsToNHCB: ptr.To(false), - MetricNameValidationScheme: "utf8", - MetricNameEscapingScheme: "allow-utf-8", + MetricNameValidationScheme: "legacy", + MetricNameEscapingScheme: "underscores", }, }, { @@ -272,8 +272,8 @@ func TestGeneratePodMonitorConfig(t *testing.T) { }, }, ConvertClassicHistogramsToNHCB: ptr.To(false), - MetricNameValidationScheme: "utf8", - MetricNameEscapingScheme: "allow-utf-8", + MetricNameValidationScheme: "legacy", + MetricNameEscapingScheme: "underscores", }, }, { @@ -438,8 +438,8 @@ func TestGeneratePodMonitorConfig(t *testing.T) { LabelNameLengthLimit: 104, LabelValueLengthLimit: 105, ConvertClassicHistogramsToNHCB: ptr.To(false), - MetricNameValidationScheme: "utf8", - MetricNameEscapingScheme: "allow-utf-8", + MetricNameValidationScheme: "legacy", + MetricNameEscapingScheme: "underscores", }, }, } diff --git a/internal/component/prometheus/operator/configgen/config_gen_probe_test.go b/internal/component/prometheus/operator/configgen/config_gen_probe_test.go index f0c0127e361..392f2c1bc88 100644 --- a/internal/component/prometheus/operator/configgen/config_gen_probe_test.go +++ b/internal/component/prometheus/operator/configgen/config_gen_probe_test.go @@ -102,8 +102,8 @@ func TestGenerateProbeConfig(t *testing.T) { }, }, ConvertClassicHistogramsToNHCB: ptr.To(false), - MetricNameValidationScheme: "utf8", - MetricNameEscapingScheme: "allow-utf-8", + MetricNameValidationScheme: "legacy", + MetricNameEscapingScheme: "underscores", }, }, { @@ -194,8 +194,8 @@ func TestGenerateProbeConfig(t *testing.T) { }, }, ConvertClassicHistogramsToNHCB: ptr.To(false), - MetricNameValidationScheme: "utf8", - MetricNameEscapingScheme: "allow-utf-8", + MetricNameValidationScheme: "legacy", + MetricNameEscapingScheme: "underscores", }, }, { @@ -288,8 +288,8 @@ func TestGenerateProbeConfig(t *testing.T) { }, }, ConvertClassicHistogramsToNHCB: ptr.To(false), - MetricNameValidationScheme: "utf8", - MetricNameEscapingScheme: "allow-utf-8", + MetricNameValidationScheme: "legacy", + MetricNameEscapingScheme: "underscores", }, }, } diff --git a/internal/component/prometheus/operator/configgen/config_gen_scrapeconfig_test.go b/internal/component/prometheus/operator/configgen/config_gen_scrapeconfig_test.go index b14e6622b96..d1c56434be3 100644 --- a/internal/component/prometheus/operator/configgen/config_gen_scrapeconfig_test.go +++ b/internal/component/prometheus/operator/configgen/config_gen_scrapeconfig_test.go @@ -84,8 +84,8 @@ func TestGenerateStaticScrapeConfigConfig(t *testing.T) { }, }, ConvertClassicHistogramsToNHCB: ptr.To(false), - MetricNameValidationScheme: "utf8", - MetricNameEscapingScheme: "allow-utf-8", + MetricNameValidationScheme: "legacy", + MetricNameEscapingScheme: "underscores", }, }, { @@ -137,8 +137,8 @@ func TestGenerateStaticScrapeConfigConfig(t *testing.T) { }, }, ConvertClassicHistogramsToNHCB: ptr.To(false), - MetricNameValidationScheme: "utf8", - MetricNameEscapingScheme: "allow-utf-8", + MetricNameValidationScheme: "legacy", + MetricNameEscapingScheme: "underscores", }, }, } diff --git a/internal/component/prometheus/operator/configgen/config_gen_servicemonitor_test.go b/internal/component/prometheus/operator/configgen/config_gen_servicemonitor_test.go index d48aad574f6..ffac107de1c 100644 --- a/internal/component/prometheus/operator/configgen/config_gen_servicemonitor_test.go +++ b/internal/component/prometheus/operator/configgen/config_gen_servicemonitor_test.go @@ -101,8 +101,8 @@ func TestGenerateServiceMonitorConfig(t *testing.T) { }, }, ConvertClassicHistogramsToNHCB: ptr.To(false), - MetricNameValidationScheme: "utf8", - MetricNameEscapingScheme: "allow-utf-8", + MetricNameValidationScheme: "legacy", + MetricNameEscapingScheme: "underscores", }, }, { @@ -175,8 +175,8 @@ func TestGenerateServiceMonitorConfig(t *testing.T) { }, }, ConvertClassicHistogramsToNHCB: ptr.To(false), - MetricNameValidationScheme: "utf8", - MetricNameEscapingScheme: "allow-utf-8", + MetricNameValidationScheme: "legacy", + MetricNameEscapingScheme: "underscores", }, }, { @@ -249,8 +249,8 @@ func TestGenerateServiceMonitorConfig(t *testing.T) { }, }, ConvertClassicHistogramsToNHCB: ptr.To(false), - MetricNameValidationScheme: "utf8", - MetricNameEscapingScheme: "allow-utf-8", + MetricNameValidationScheme: "legacy", + MetricNameEscapingScheme: "underscores", }, }, { @@ -323,8 +323,8 @@ func TestGenerateServiceMonitorConfig(t *testing.T) { }, }, ConvertClassicHistogramsToNHCB: ptr.To(false), - MetricNameValidationScheme: "utf8", - MetricNameEscapingScheme: "allow-utf-8", + MetricNameValidationScheme: "legacy", + MetricNameEscapingScheme: "underscores", }, }, { @@ -506,8 +506,8 @@ func TestGenerateServiceMonitorConfig(t *testing.T) { LabelNameLengthLimit: 104, LabelValueLengthLimit: 105, ConvertClassicHistogramsToNHCB: ptr.To(false), - MetricNameValidationScheme: "utf8", - MetricNameEscapingScheme: "allow-utf-8", + MetricNameValidationScheme: "legacy", + MetricNameEscapingScheme: "underscores", }, }, { @@ -585,8 +585,8 @@ func TestGenerateServiceMonitorConfig(t *testing.T) { }, }, ConvertClassicHistogramsToNHCB: ptr.To(false), - MetricNameValidationScheme: "utf8", - MetricNameEscapingScheme: "allow-utf-8", + MetricNameValidationScheme: "legacy", + MetricNameEscapingScheme: "underscores", }, }, } diff --git a/internal/component/prometheus/operator/types.go b/internal/component/prometheus/operator/types.go index 6ac2e99d550..2df849e0651 100644 --- a/internal/component/prometheus/operator/types.go +++ b/internal/component/prometheus/operator/types.go @@ -54,6 +54,8 @@ func (s *ScrapeOptions) GlobalConfig() promconfig.GlobalConfig { cfg := promconfig.DefaultGlobalConfig cfg.ScrapeInterval = model.Duration(s.DefaultScrapeInterval) cfg.ScrapeTimeout = model.Duration(s.DefaultScrapeTimeout) + cfg.MetricNameValidationScheme = promconfig.LegacyValidationConfig + cfg.MetricNameEscapingScheme = model.EscapeUnderscores return cfg } diff --git a/internal/component/prometheus/scrape/scrape.go b/internal/component/prometheus/scrape/scrape.go index 74c75b46151..f7f4d988d12 100644 --- a/internal/component/prometheus/scrape/scrape.go +++ b/internal/component/prometheus/scrape/scrape.go @@ -154,10 +154,10 @@ func (arg *Arguments) SetToDefault() { ScrapeInterval: 1 * time.Minute, // From config.DefaultGlobalConfig ScrapeTimeout: 10 * time.Second, // From config.DefaultGlobalConfig ScrapeProtocols: slices.Clone(defaultScrapeProtocols), - ScrapeFallbackProtocol: string(config.PrometheusText0_0_4), // Use same fallback protocol as Prometheus v2 - ScrapeNativeHistograms: true, + ScrapeFallbackProtocol: string(config.PrometheusText0_0_4), // Use the same fallback protocol as Prometheus v2 + ScrapeNativeHistograms: false, // NOTE: the MetricNameEscapingScheme depends on this, so its default must be set in Validate() function. - MetricNameValidationScheme: config.UTF8ValidationConfig, + MetricNameValidationScheme: config.LegacyValidationConfig, ConvertClassicHistogramsToNHCB: false, EnableCompression: true, NativeHistogramBucketLimit: 0, @@ -180,6 +180,21 @@ func (arg *Arguments) Validate() error { // For backwards-compatibility, if EnableProtobufNegotiation is set to true, the ScrapeProtocols are set to // [PrometheusProto, OpenMetricsText1.0.0, OpenMetricsText0.0.1, PrometheusText0.0.4]. arg.ScrapeProtocols = slices.Clone(defaultNativeHistogramScrapeProtocols) + // In previous Prometheus versions, EnableProtobufNegotiation would also enable native histogram scraping. + // This is no longer the case, so we need to explicitly enable it here. + arg.ScrapeNativeHistograms = true + } + + if arg.ScrapeNativeHistograms { + // When scrape_native_histograms is set to true, the default scrape protocols are overridden to + // Proto-first scrape protocols, like in upstream Prometheus. + if reflect.DeepEqual(arg.ScrapeProtocols, defaultScrapeProtocols) { + arg.ScrapeProtocols = slices.Clone(defaultNativeHistogramScrapeProtocols) + } + + if !slices.Contains(arg.ScrapeProtocols, string(config.PrometheusProto)) { + return fmt.Errorf("scrape_native_histograms is set to true, but PrometheusProto is not in scrape_protocols") + } } // Validate scrape protocols @@ -247,10 +262,11 @@ type Component struct { movedTargetsCounter client_prometheus.Counter unregisterer util.Unregisterer - mut sync.RWMutex - args Arguments - scraper *scrape.Manager - appendable *prometheus.Fanout + mut sync.RWMutex + args Arguments + scraper *scrape.Manager + appendable *prometheus.Fanout + firstUpdateDone bool dtMutex sync.Mutex distributedTargets *discovery.DistributedTargets @@ -290,10 +306,12 @@ func New(o component.Options, args Arguments) (*Component, error) { alloyAppendable := prometheus.NewFanout(args.ForwardTo, o.ID, o.Registerer, ls) scrapeOptions := &scrape.Options{ + // NOTE: This is not Update()-able. ExtraMetrics: args.ExtraMetrics, HTTPClientOptions: []config_util.HTTPClientOption{ config_util.WithDialContextFunc(httpData.DialFunc), }, + // NOTE: This is not Update()-able. EnableNativeHistogramsIngestion: args.ScrapeNativeHistograms, } @@ -435,6 +453,20 @@ func (c *Component) Update(args component.Arguments) error { c.mut.Lock() defer c.mut.Unlock() + + // Some fields are not updateable at runtime - only allow them when Update() + // is called for the first time from New(). + if !c.firstUpdateDone { + c.firstUpdateDone = true + } else { + if c.args.ScrapeNativeHistograms != newArgs.ScrapeNativeHistograms { + return fmt.Errorf("scrape_native_histograms cannot be updated at runtime") + } + if c.args.ExtraMetrics != newArgs.ExtraMetrics { + return fmt.Errorf("extra_metrics cannot be updated at runtime") + } + } + c.args = newArgs c.appendable.UpdateChildren(newArgs.ForwardTo) @@ -519,7 +551,8 @@ func getPromScrapeConfigs(jobName string, c Arguments) *config.ScrapeConfig { dec.MetricNameValidationScheme = c.MetricNameValidationScheme dec.MetricNameEscapingScheme = c.MetricNameEscapingScheme dec.ScrapeFallbackProtocol = config.ScrapeProtocol(c.ScrapeFallbackProtocol) - dec.ConvertClassicHistogramsToNHCB = &c.ConvertClassicHistogramsToNHCB + convertToNHCB := c.ConvertClassicHistogramsToNHCB + dec.ConvertClassicHistogramsToNHCB = &convertToNHCB dec.EnableCompression = c.EnableCompression dec.NativeHistogramBucketLimit = c.NativeHistogramBucketLimit dec.NativeHistogramMinBucketFactor = c.NativeHistogramMinBucketFactor diff --git a/internal/component/prometheus/scrape/scrape_test.go b/internal/component/prometheus/scrape/scrape_test.go index e7f2c653d9a..a74f858a06a 100644 --- a/internal/component/prometheus/scrape/scrape_test.go +++ b/internal/component/prometheus/scrape/scrape_test.go @@ -290,17 +290,66 @@ func TestAlloyConfigDefaultsAndValidation(t *testing.T) { assertions func(t *testing.T, args Arguments) }{ { - name: "no validation scheme specified", + name: "defaults", config: ` targets = [{ "target1" = "target1" }] forward_to = [] `, expectError: false, assertions: func(t *testing.T, args Arguments) { - require.Equal(t, "utf8", args.MetricNameValidationScheme) - require.Equal(t, "allow-utf-8", args.MetricNameEscapingScheme) + require.Equal(t, "legacy", args.MetricNameValidationScheme) + require.Equal(t, "underscores", args.MetricNameEscapingScheme) + require.Equal(t, []string{ + "OpenMetricsText1.0.0", + "OpenMetricsText0.0.1", + "PrometheusText1.0.0", + "PrometheusText0.0.4", + }, args.ScrapeProtocols) + require.Equal(t, "PrometheusText0.0.4", args.ScrapeFallbackProtocol) + require.Equal(t, false, args.ScrapeNativeHistograms) + require.Equal(t, false, args.ConvertClassicHistogramsToNHCB) + require.Equal(t, true, args.EnableCompression) + require.Equal(t, uint(0), args.NativeHistogramBucketLimit) + require.Equal(t, 0.0, args.NativeHistogramMinBucketFactor) + }, + }, + { + name: "native histogram defaults", + config: ` + targets = [{ "target1" = "target1" }] + forward_to = [] + scrape_native_histograms = true + `, + expectError: false, + assertions: func(t *testing.T, args Arguments) { + require.Equal(t, "legacy", args.MetricNameValidationScheme) + require.Equal(t, "underscores", args.MetricNameEscapingScheme) + require.Equal(t, []string{ + "PrometheusProto", + "OpenMetricsText1.0.0", + "OpenMetricsText0.0.1", + "PrometheusText1.0.0", + "PrometheusText0.0.4", + }, args.ScrapeProtocols) + require.Equal(t, "PrometheusText0.0.4", args.ScrapeFallbackProtocol) + require.Equal(t, true, args.ScrapeNativeHistograms) + require.Equal(t, false, args.ConvertClassicHistogramsToNHCB) + require.Equal(t, true, args.EnableCompression) + require.Equal(t, uint(0), args.NativeHistogramBucketLimit) + require.Equal(t, 0.0, args.NativeHistogramMinBucketFactor) }, }, + { + name: "native histogram missing PrometheusProto", + config: ` + targets = [{ "target1" = "target1" }] + forward_to = [] + scrape_native_histograms = true + scrape_protocols = ["OpenMetricsText1.0.0", "OpenMetricsText0.0.1", "PrometheusText1.0.0"] + `, + expectError: true, + errorContains: `scrape_native_histograms is set to true, but PrometheusProto is not in scrape_protocols`, + }, { name: "valid utf8 with allow-utf-8", config: ` @@ -401,17 +450,14 @@ func TestAlloyConfigDefaultsAndValidation(t *testing.T) { }, }, { - name: "escaping scheme only - validation scheme should default to utf8", + name: "escaping scheme only set to utf-8", config: ` targets = [{ "target1" = "target1" }] forward_to = [] metric_name_escaping_scheme = "allow-utf-8" `, - expectError: false, - assertions: func(t *testing.T, args Arguments) { - require.Equal(t, "utf8", args.MetricNameValidationScheme) - require.Equal(t, "allow-utf-8", args.MetricNameEscapingScheme) - }, + expectError: true, + errorContains: "metric_name_escaping_scheme cannot be set to 'allow-utf-8' while metric_name_validation_scheme is not set to 'utf8'", }, { name: "empty string validation scheme", @@ -432,8 +478,8 @@ func TestAlloyConfigDefaultsAndValidation(t *testing.T) { `, expectError: false, assertions: func(t *testing.T, args Arguments) { - require.Equal(t, "utf8", args.MetricNameValidationScheme) - require.Equal(t, "allow-utf-8", args.MetricNameEscapingScheme) + require.Equal(t, "legacy", args.MetricNameValidationScheme) + require.Equal(t, "underscores", args.MetricNameEscapingScheme) }, }, { diff --git a/internal/converter/internal/prometheusconvert/component/scrape.go b/internal/converter/internal/prometheusconvert/component/scrape.go index 435bb17d4f2..238a0f3f7f0 100644 --- a/internal/converter/internal/prometheusconvert/component/scrape.go +++ b/internal/converter/internal/prometheusconvert/component/scrape.go @@ -52,6 +52,11 @@ func toScrapeArguments(scrapeConfig *prom_config.ScrapeConfig, forwardTo []stora if fallbackProtocol == "" { fallbackProtocol = string(prom_config.PrometheusText0_0_4) } + + // Set the escaping and validation scheme to default values in Alloy for maximum compatibility with backends. + scrapeConfig.MetricNameValidationScheme = prom_config.LegacyValidationConfig + scrapeConfig.MetricNameEscapingScheme = "" // this will default to underscores given the legacy validation scheme + alloyArgs := &scrape.Arguments{ Targets: targets, ForwardTo: forwardTo, @@ -61,7 +66,7 @@ func toScrapeArguments(scrapeConfig *prom_config.ScrapeConfig, forwardTo []stora TrackTimestampsStaleness: scrapeConfig.TrackTimestampsStaleness, Params: scrapeConfig.Params, ScrapeClassicHistograms: scrapeConfig.AlwaysScrapeClassicHistograms, - ScrapeNativeHistograms: true, + ScrapeNativeHistograms: false, // this is controlled by a Prometheus feature, not the config file ScrapeInterval: time.Duration(scrapeConfig.ScrapeInterval), ScrapeTimeout: time.Duration(scrapeConfig.ScrapeTimeout), ScrapeFailureLogFile: scrapeConfig.ScrapeFailureLogFile, diff --git a/internal/converter/internal/prometheusconvert/testdata/azure.alloy b/internal/converter/internal/prometheusconvert/testdata/azure.alloy index 372d5bd4a26..631f7a5d7af 100644 --- a/internal/converter/internal/prometheusconvert/testdata/azure.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/azure.alloy @@ -35,16 +35,14 @@ prometheus.scrape "prometheus1" { __address__ = "localhost:9090", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.azure.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.azure.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/consul.alloy b/internal/converter/internal/prometheusconvert/testdata/consul.alloy index 2d344429766..d7d3f6696c3 100644 --- a/internal/converter/internal/prometheusconvert/testdata/consul.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/consul.alloy @@ -13,16 +13,14 @@ prometheus.scrape "prometheus1" { __address__ = "localhost:9090", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.consul.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.consul.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/digitalocean.alloy b/internal/converter/internal/prometheusconvert/testdata/digitalocean.alloy index 6acb0ca2e1c..4101484322f 100644 --- a/internal/converter/internal/prometheusconvert/testdata/digitalocean.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/digitalocean.alloy @@ -17,16 +17,14 @@ prometheus.scrape "prometheus1" { __address__ = "localhost:9090", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.digitalocean.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.digitalocean.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/discovery.alloy b/internal/converter/internal/prometheusconvert/testdata/discovery.alloy index 8751521b2e7..726eca77713 100644 --- a/internal/converter/internal/prometheusconvert/testdata/discovery.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/discovery.alloy @@ -47,10 +47,9 @@ discovery.relabel "prometheus1" { } prometheus.scrape "prometheus1" { - targets = discovery.relabel.prometheus1.output - forward_to = [prometheus.relabel.prometheus1.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.relabel.prometheus1.output + forward_to = [prometheus.relabel.prometheus1.receiver] + job_name = "prometheus1" } prometheus.relabel "prometheus1" { diff --git a/internal/converter/internal/prometheusconvert/testdata/discovery_relabel.alloy b/internal/converter/internal/prometheusconvert/testdata/discovery_relabel.alloy index 5bb52090fe5..380c09804a8 100644 --- a/internal/converter/internal/prometheusconvert/testdata/discovery_relabel.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/discovery_relabel.alloy @@ -57,17 +57,15 @@ discovery.relabel "prometheus2" { } prometheus.scrape "prometheus1" { - targets = discovery.relabel.prometheus1.output - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.relabel.prometheus1.output + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.relabel.prometheus2.output - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.relabel.prometheus2.output + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/dns.alloy b/internal/converter/internal/prometheusconvert/testdata/dns.alloy index 74967d3e022..e1c89092a8f 100644 --- a/internal/converter/internal/prometheusconvert/testdata/dns.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/dns.alloy @@ -16,16 +16,14 @@ prometheus.scrape "prometheus1" { __address__ = "localhost:9090", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.dns.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.dns.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/docker.alloy b/internal/converter/internal/prometheusconvert/testdata/docker.alloy index f98b8f39262..dbc0858ea8c 100644 --- a/internal/converter/internal/prometheusconvert/testdata/docker.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/docker.alloy @@ -13,16 +13,14 @@ prometheus.scrape "prometheus1" { __address__ = "localhost:9090", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.docker.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.docker.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/dockerswarm.alloy b/internal/converter/internal/prometheusconvert/testdata/dockerswarm.alloy index 8718e99b4d1..8e4013e1d78 100644 --- a/internal/converter/internal/prometheusconvert/testdata/dockerswarm.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/dockerswarm.alloy @@ -32,16 +32,14 @@ prometheus.scrape "prometheus1" { __address__ = "localhost:9090", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.dockerswarm.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.dockerswarm.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/ec2.alloy b/internal/converter/internal/prometheusconvert/testdata/ec2.alloy index 45d22526ad0..4e726413c95 100644 --- a/internal/converter/internal/prometheusconvert/testdata/ec2.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/ec2.alloy @@ -24,16 +24,14 @@ prometheus.scrape "prometheus1" { __address__ = "localhost:9090", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.ec2.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.ec2.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/file.alloy b/internal/converter/internal/prometheusconvert/testdata/file.alloy index 808b8895d75..1cb3e1f2876 100644 --- a/internal/converter/internal/prometheusconvert/testdata/file.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/file.alloy @@ -14,16 +14,14 @@ prometheus.scrape "prometheus1" { __address__ = "localhost:9090", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.file.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.file.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/gce.alloy b/internal/converter/internal/prometheusconvert/testdata/gce.alloy index 1c230dcf242..a02fad944c7 100644 --- a/internal/converter/internal/prometheusconvert/testdata/gce.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/gce.alloy @@ -17,16 +17,14 @@ prometheus.scrape "prometheus1" { __address__ = "localhost:9090", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.gce.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.gce.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/http.alloy b/internal/converter/internal/prometheusconvert/testdata/http.alloy index afa727cb071..0b3f85909b1 100644 --- a/internal/converter/internal/prometheusconvert/testdata/http.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/http.alloy @@ -64,7 +64,6 @@ prometheus.scrape "netbox_snmp" { Authorization = ["something", "something else"], Host = ["localhost"], } - metric_name_escaping_scheme = "allow-utf-8" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/ionos.alloy b/internal/converter/internal/prometheusconvert/testdata/ionos.alloy index 49f32ff8613..2468ee63d90 100644 --- a/internal/converter/internal/prometheusconvert/testdata/ionos.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/ionos.alloy @@ -20,16 +20,14 @@ prometheus.scrape "prometheus1" { __address__ = "localhost:9090", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.ionos.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.ionos.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/kubernetes.alloy b/internal/converter/internal/prometheusconvert/testdata/kubernetes.alloy index 499949ee706..0d40813e321 100644 --- a/internal/converter/internal/prometheusconvert/testdata/kubernetes.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/kubernetes.alloy @@ -13,16 +13,14 @@ prometheus.scrape "prometheus1" { __address__ = "localhost:9090", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.kubernetes.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.kubernetes.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/kuma.alloy b/internal/converter/internal/prometheusconvert/testdata/kuma.alloy index ba881b4cc09..975d29a2bbc 100644 --- a/internal/converter/internal/prometheusconvert/testdata/kuma.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/kuma.alloy @@ -16,16 +16,14 @@ prometheus.scrape "prometheus1" { __address__ = "localhost:9090", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.kuma.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.kuma.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/lightsail.alloy b/internal/converter/internal/prometheusconvert/testdata/lightsail.alloy index a5e956207b0..d6a48888f8e 100644 --- a/internal/converter/internal/prometheusconvert/testdata/lightsail.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/lightsail.alloy @@ -24,16 +24,14 @@ prometheus.scrape "prometheus1" { __address__ = "localhost:9090", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.lightsail.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.lightsail.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/linode.alloy b/internal/converter/internal/prometheusconvert/testdata/linode.alloy index 1ad47cc07a1..43181b81e93 100644 --- a/internal/converter/internal/prometheusconvert/testdata/linode.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/linode.alloy @@ -12,16 +12,14 @@ prometheus.scrape "prometheus1" { __address__ = "localhost:9090", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.linode.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.linode.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/marathon.alloy b/internal/converter/internal/prometheusconvert/testdata/marathon.alloy index 34872b475a2..cbce99207c6 100644 --- a/internal/converter/internal/prometheusconvert/testdata/marathon.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/marathon.alloy @@ -20,16 +20,14 @@ prometheus.scrape "prometheus1" { __address__ = "localhost:9090", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.marathon.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.marathon.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/metric_relabel.alloy b/internal/converter/internal/prometheusconvert/testdata/metric_relabel.alloy index 22b323a3082..2a815e58eb1 100644 --- a/internal/converter/internal/prometheusconvert/testdata/metric_relabel.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/metric_relabel.alloy @@ -12,16 +12,14 @@ prometheus.scrape "prometheus1" { username = "user" password = "pass" } - metric_name_escaping_scheme = "allow-utf-8" } prometheus.scrape "prometheus2" { targets = [{ __address__ = "localhost:9091", }] - forward_to = [prometheus.relabel.prometheus2.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.relabel.prometheus2.receiver] + job_name = "prometheus2" } prometheus.relabel "prometheus2" { diff --git a/internal/converter/internal/prometheusconvert/testdata/nerve.alloy b/internal/converter/internal/prometheusconvert/testdata/nerve.alloy index 83245b900e2..595b36fb4d5 100644 --- a/internal/converter/internal/prometheusconvert/testdata/nerve.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/nerve.alloy @@ -16,16 +16,14 @@ prometheus.scrape "prometheus1" { __address__ = "localhost:9090", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.nerve.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.nerve.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/openstack.alloy b/internal/converter/internal/prometheusconvert/testdata/openstack.alloy index da46b8de039..d9509151ee1 100644 --- a/internal/converter/internal/prometheusconvert/testdata/openstack.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/openstack.alloy @@ -38,16 +38,14 @@ prometheus.scrape "prometheus1" { __address__ = "localhost:9090", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.openstack.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.openstack.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/ovhcloud.alloy b/internal/converter/internal/prometheusconvert/testdata/ovhcloud.alloy index f578df22d7c..8396ee99b2a 100644 --- a/internal/converter/internal/prometheusconvert/testdata/ovhcloud.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/ovhcloud.alloy @@ -21,16 +21,14 @@ prometheus.scrape "prometheus1" { __address__ = "localhost:9090", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.ovhcloud.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.ovhcloud.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/scaleway.alloy b/internal/converter/internal/prometheusconvert/testdata/scaleway.alloy index 1c1ed4b4797..224816f8566 100644 --- a/internal/converter/internal/prometheusconvert/testdata/scaleway.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/scaleway.alloy @@ -19,16 +19,14 @@ prometheus.scrape "prometheus1" { __address__ = "localhost:9090", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.scaleway.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.scaleway.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/scrape.alloy b/internal/converter/internal/prometheusconvert/testdata/scrape.alloy index 9db7d7de915..ee5d81798c9 100644 --- a/internal/converter/internal/prometheusconvert/testdata/scrape.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/scrape.alloy @@ -20,7 +20,6 @@ prometheus.scrape "prometheus_1" { username = "user" password = "pass" } - metric_name_escaping_scheme = "allow-utf-8" } prometheus.scrape "prometheus2" { @@ -35,9 +34,8 @@ prometheus.scrape "prometheus2" { __address__ = "localhost:9093", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/serverset.alloy b/internal/converter/internal/prometheusconvert/testdata/serverset.alloy index 88b1755dae3..769ed1c7f34 100644 --- a/internal/converter/internal/prometheusconvert/testdata/serverset.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/serverset.alloy @@ -10,17 +10,15 @@ discovery.serverset "prometheus2" { } prometheus.scrape "prometheus1" { - targets = discovery.serverset.prometheus1.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.serverset.prometheus1.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.serverset.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.serverset.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/triton.alloy b/internal/converter/internal/prometheusconvert/testdata/triton.alloy index 8a3eb8d51f0..e12ef1f0de1 100644 --- a/internal/converter/internal/prometheusconvert/testdata/triton.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/triton.alloy @@ -17,16 +17,14 @@ prometheus.scrape "prometheus1" { __address__ = "localhost:9090", }], ) - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus1" - metric_name_escaping_scheme = "allow-utf-8" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus1" } prometheus.scrape "prometheus2" { - targets = discovery.triton.prometheus2.targets - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" - metric_name_escaping_scheme = "allow-utf-8" + targets = discovery.triton.prometheus2.targets + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" } prometheus.remote_write "default" { diff --git a/internal/converter/internal/prometheusconvert/testdata/unsupported.alloy b/internal/converter/internal/prometheusconvert/testdata/unsupported.alloy index 7e17a1f8f21..dd67312241f 100644 --- a/internal/converter/internal/prometheusconvert/testdata/unsupported.alloy +++ b/internal/converter/internal/prometheusconvert/testdata/unsupported.alloy @@ -12,7 +12,6 @@ prometheus.scrape "prometheus1" { username = "user" password = "pass" } - metric_name_escaping_scheme = "allow-utf-8" } prometheus.scrape "prometheus2" { @@ -22,7 +21,6 @@ prometheus.scrape "prometheus2" { forward_to = [prometheus.remote_write.default.receiver] job_name = "prometheus2" scrape_classic_histograms = true - metric_name_escaping_scheme = "allow-utf-8" native_histogram_bucket_limit = 2 }