Skip to content

Commit cb65473

Browse files
authored
Fix metadata propagation from scrape to otel components (#4098)
* Fix metadata propagation from scrape to otel components * Use test context * PR review polishing * Docs fixes
1 parent 6f27bc7 commit cb65473

File tree

18 files changed

+834
-84
lines changed

18 files changed

+834
-84
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ Main (unreleased)
5555

5656
- Add otel collector converter for `otelcol.receiver.googlecloudpubsub`. (@kalleep)
5757

58+
- (_Experimental_) Add a `honor_metadata` configuration argument to the `prometheus.scrape` component.
59+
When set to `true`, it will propagate metric metadata to downstream components.
60+
5861
### Enhancements
5962

6063
- Fix `pyroscope.write` component's `AppendIngest` method to respect configured timeout and implement retry logic. The method now properly uses the configured `remote_timeout`, includes retry logic with exponential backoff, and tracks metrics for sent/dropped bytes and profiles consistently with the `Append` method. (@korniltsev)

docs/sources/reference/components/loki/loki.write.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,7 @@ When `retry_on_http_429` is enabled, the retry mechanism is governed by the back
127127

128128
### `queue_config`
129129

130-
> **EXPERIMENTAL**: This is an [experimental][] feature.
131-
> Experimental features are subject to frequent breaking changes, and may be removed with no equivalent replacement.
132-
> The `stability.level` flag must be set to `experimental` to use the feature.
133-
134-
[experimental]: https://grafana.com/docs/release-life-cycle/
130+
{{< docs/shared lookup="stability/experimental_feature.md" source="alloy" version="<ALLOY_VERSION>" >}}
135131

136132
The optional `queue_config` block configures, when WAL is enabled, how the underlying client queues batches of logs sent to Loki.
137133
Refer to [Write-Ahead block](#wal) for more information.
@@ -149,9 +145,7 @@ The following arguments are supported:
149145

150146
### `wal`
151147

152-
> **EXPERIMENTAL**: This is an [experimental][] feature.
153-
> Experimental features are subject to frequent breaking changes, and may be removed with no equivalent replacement.
154-
> The `stability.level` flag must be set to `experimental` to use the feature.
148+
{{< docs/shared lookup="stability/experimental_feature.md" source="alloy" version="<ALLOY_VERSION>" >}}
155149

156150
The optional `wal` block configures the Write-Ahead Log (WAL) used in the Loki remote-write client.
157151
To enable the WAL, you must include the `wal` block in your configuration.

docs/sources/reference/components/otelcol/otelcol.exporter.loadbalancing.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,10 @@ where the list of resolved endpoints changes frequently due to deployments and s
8686

8787
> **EXPERIMENTAL**: Metrics support in `otelcol.exporter.loadbalancing` is an [experimental][] feature.
8888
> Experimental features are subject to frequent breaking changes, and may be removed with no equivalent replacement.
89-
> The `stability.level` flag must be set to `experimental` to use the feature.
89+
> To enable and use an experimental feature, you must set the `stability.level` [flag][] to `experimental`.
9090
9191
[experimental]: https://grafana.com/docs/release-life-cycle/
92+
[flag]: https://grafana.com/docs/alloy/<ALLOY_VERSION>/reference/cli/run/
9293

9394
## Blocks
9495

docs/sources/reference/components/prometheus/prometheus.scrape.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ You can use the following arguments with `prometheus.scrape`:
5353
| `http_headers` | `map(list(secret))` | Custom HTTP headers to be sent along with each request. The map key is the header name. | | no |
5454
| `honor_labels` | `bool` | Indicator whether the scraped metrics should remain unmodified. | `false` | no |
5555
| `honor_timestamps` | `bool` | Indicator whether the scraped timestamps should be respected. | `true` | no |
56+
| `honor_metadata` | `bool` | (Experimental) Indicator whether metric metadata should be sent to downstream components. | `false` | no |
5657
| `job_name` | `string` | The value to use for the job label if not already set. | component name | no |
5758
| `label_limit` | `uint` | More than this many labels post metric-relabeling causes the scrape to fail. | | no |
5859
| `label_name_length_limit` | `uint` | More than this label name length post metric-relabeling causes the scrape to fail. | | no |
@@ -79,6 +80,17 @@ You can use the following arguments with `prometheus.scrape`:
7980
| `target_limit` | `uint` | More than this many targets after the target relabeling causes the scrapes to fail. | | no |
8081
| `track_timestamps_staleness` | `bool` | Indicator whether to track the staleness of the scraped timestamps. | `false` | no |
8182

83+
> **EXPERIMENTAL**: The `honor_metadata` argument is an [experimental][] feature.
84+
> Enabling it may increase resource consumption, particularly if a lot of metrics with different names are ingested.
85+
> Not all downstream components may be compatible with Prometheus metadata yet.
86+
> For example, `otelcol.receiver.prometheus` may work, but `prometheus.remote_write` may not.
87+
> Support for more components will be added soon.
88+
> Experimental features are subject to frequent breaking changes, and may be removed with no equivalent replacement.
89+
> To enable and use an experimental feature, you must set the `stability.level` [flag][] to `experimental`.
90+
91+
[experimental]: https://grafana.com/docs/release-life-cycle/
92+
[flag]: https://grafana.com/docs/alloy/<ALLOY_VERSION>/reference/cli/run/
93+
8294
At most, one of the following can be provided:
8395

8496
* [`authorization`][authorization] block

docs/sources/reference/stdlib/array.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ Examples using discovery and exporter components:
8181
You can find more examples in the [tests][].
8282

8383
[tests]: https://github.com/grafana/alloy/blob/main/syntax/vm/vm_stdlib_test.go
84-
[experimental]: https://grafana.com/docs/release-life-cycle/
8584

8685
## array.group_by
8786

docs/sources/troubleshoot/debug.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ Click the {{< param "PRODUCT_NAME" >}} logo to navigate back to the home page.
4343

4444
### Graph page
4545

46-
> **EXPERIMENTAL**: This is an [experimental][] feature.
47-
> Experimental features are subject to frequent breaking changes, and may be removed with no equivalent replacement.
48-
49-
[experimental]: https://grafana.com/docs/release-life-cycle/
46+
{{< docs/shared lookup="stability/experimental_feature.md" source="alloy" version="<ALLOY_VERSION>" >}}
5047

5148
{{< figure src="/media/docs/alloy/ui_graph_page_new_2.png" alt="Alloy UI graph page" >}}
5249

internal/component/otelcol/exporter/prometheus/prometheus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func New(o component.Options, c Arguments) (*Component, error) {
8787
return nil, err
8888
}
8989
ls := service.(labelstore.LabelStore)
90-
fanout := prometheus.NewFanout(nil, o.ID, o.Registerer, ls)
90+
fanout := prometheus.NewFanout(nil, o.ID, o.Registerer, ls, prometheus.NoopMetadataStore{})
9191

9292
converter := convert.New(o.Logger, fanout, convertArgumentsToConvertOptions(c))
9393

internal/component/otelcol/receiver/prometheus/internal/transaction.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,9 @@ func (t *transaction) Rollback() error {
542542
return nil
543543
}
544544

545-
func (t *transaction) UpdateMetadata(_ storage.SeriesRef, _ labels.Labels, _ metadata.Metadata) (storage.SeriesRef, error) {
546-
// TODO: implement this func
545+
func (t *transaction) UpdateMetadata(_ storage.SeriesRef, lbls labels.Labels, m metadata.Metadata) (storage.SeriesRef, error) {
546+
// There's no need to implement this.
547+
// The metadata will be retrieved from the context.
547548
return 0, nil
548549
}
549550

0 commit comments

Comments
 (0)