-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix prometheusexporter droping the OTEL resource labels #2899
Fix prometheusexporter droping the OTEL resource labels #2899
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2899 +/- ##
=======================================
Coverage 91.63% 91.64%
=======================================
Files 312 312
Lines 15404 15420 +16
=======================================
+ Hits 14116 14132 +16
Misses 881 881
Partials 407 407
Continue to review full report at Codecov.
|
@@ -17,6 +17,8 @@ The following settings can be optionally configured: | |||
- `send_timestamps` (default = `false`): if true, sends the timestamp of the underlying | |||
metric sample in the response. | |||
- `metric_expiration` (default = `5m`): defines how long metrics are exposed without updates | |||
- `resource_attributes_as_tag` (default = `false`): if set to true will transform all resource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was looking into this exact same feature with the prometheusremotewriteexporter
. Was just wondering - strictly speaking it is "resource attributes as labels"? I guess Prometheus uses the term "label" instead of "tag"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @bogdandrutu I'll switch it to a convention thats used over in the contrib repo so things are kept consistent, so this will change too
resource_to_telemetry_conversion:
enabled: true
@@ -17,6 +17,8 @@ The following settings can be optionally configured: | |||
- `send_timestamps` (default = `false`): if true, sends the timestamp of the underlying | |||
metric sample in the response. | |||
- `metric_expiration` (default = `5m`): defines how long metrics are exposed without updates | |||
- `resource_attributes_as_tag` (default = `false`): if set to true will transform all resource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems to be tags
not tag
|
||
// ResourceAttributesAsTags, if sMet to true, will use the exporterhelper feature to | ||
// transform all resource attributes into metric labels. | ||
ResourceAttributesAsTags bool `mapstructure:"resource_attributes_as_tags"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In contrib where we use this, we have config like:
exporterhelper.ResourceToTelemetrySettings `mapstructure:"resource_to_telemetry_conversion"`
so the config will be:
resource_to_telemetry_conversion:
enabled: true
If you don't like that name maybe embed that settings but use the name resource_attributes_as_tags
? What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah cool, it should be consistent with existing implementations so happy to switch it up to:
resource_to_telemetry_conversion:
enabled: true
…om exporterhelper
@bogdandrutu I've pushed the required changes, sorry for the delay 👍 |
…#2899) Bumps [github.com/hashicorp/vault](https://github.com/hashicorp/vault) from 1.13.0 to 1.13.1. - [Release notes](https://github.com/hashicorp/vault/releases) - [Changelog](https://github.com/hashicorp/vault/blob/main/CHANGELOG.md) - [Commits](hashicorp/vault@v1.13.0...v1.13.1) --- updated-dependencies: - dependency-name: github.com/hashicorp/vault dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Description:
Added support for
resource_to_telemetry_conversion
to the Promethus Exporter so resource attributes are added as labels to metrics.Link to tracking Issue: Fixes #2498
Testing:
Added new test cases to ensure resource labels are included in the prometheus metrics output when
resource_to_telemetry_conversion
is enabled.Two existing test cases were amended due to their requirement via a type assertion to have access to the underlying
prometheusExporter
which is no longer the case since this was changed to a*exporterhelper.metricsExporter
. To accommodate this a wrapper was added which allowed the type assertion to work and the test cases to pass.Manual testing was done by building and running the
otelcol
locally with the following configuration:A service was written to send metrics with a resource to the locally running
otelcol
and the prometheus metrics endpoint was queried and observed that metrics now had resource labels attached to them, e.g:Documentation:
The Prometheus Exporter
README.md
was updated to include documentation about the newresource_to_telemetry_conversion
configuration option.