Skip to content
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

Prometheus Receiver: config to include instance and job labels #2683

Conversation

gracewehner
Copy link

Description:
Adds a config to choose to include the labels instance and job for metrics scraped by the Prometheus Receiver. Prometheus adds these labels to every metric but they are currently dropped in the receiver.

Link to tracking Issue:
Addresses the labels aspect of issue #2363

Testing:
Adds to the test Test_isUsefulLabel to check results when config is set to false vs. true

@gracewehner gracewehner requested a review from a team March 12, 2021 01:09
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 12, 2021

CLA Signed

The committers are authorized under a signed CLA.

@codecov
Copy link

codecov bot commented Mar 12, 2021

Codecov Report

Merging #2683 (d2910d0) into main (73b55f0) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

❗ Current head d2910d0 differs from pull request most recent head 79b05ba. Consider uploading reports for the commit 79b05ba to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2683      +/-   ##
==========================================
- Coverage   92.06%   92.04%   -0.03%     
==========================================
  Files         313      270      -43     
  Lines       15439    15431       -8     
==========================================
- Hits        14214    14203      -11     
- Misses        817      847      +30     
+ Partials      408      381      -27     
Impacted Files Coverage Δ
...ceiver/prometheusreceiver/internal/metricfamily.go 98.85% <100.00%> (+<0.01%) ⬆️
...iver/prometheusreceiver/internal/metricsbuilder.go 100.00% <100.00%> (ø)
receiver/prometheusreceiver/internal/ocastore.go 91.66% <100.00%> (+0.36%) ⬆️
...eceiver/prometheusreceiver/internal/transaction.go 90.80% <100.00%> (-0.11%) ⬇️
receiver/prometheusreceiver/metrics_receiver.go 68.75% <100.00%> (-0.95%) ⬇️
extension/pprofextension/pprofextension.go 52.17% <0.00%> (-37.57%) ⬇️
receiver/prometheusreceiver/factory.go 78.78% <0.00%> (-21.22%) ⬇️
internal/version/version.go 80.00% <0.00%> (-20.00%) ⬇️
receiver/hostmetricsreceiver/factory.go 86.84% <0.00%> (-13.16%) ⬇️
exporter/fileexporter/factory.go 88.46% <0.00%> (-11.54%) ⬇️
... and 254 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fed888c...79b05ba. Read the comment docs.

@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Mar 27, 2021
@rakyll
Copy link
Contributor

rakyll commented Mar 31, 2021

A quick question, shouldn't we always do this and not put it under a configuration setting to behave the same way the Prometheus behaves?

@bogdandrutu bogdandrutu removed the Stale label Mar 31, 2021
@gracewehner
Copy link
Author

gracewehner commented Mar 31, 2021

A quick question, shouldn't we always do this and not put it under a configuration setting to behave the same way the Prometheus behaves?

@rakyll I am good with making it always do this to match Prometheus; then the change would just be the two lines in metricbuilder. I just included the config setting in case we wanted to preserve how it works currently.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 8, 2021

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@tigrannajaryan
Copy link
Member

Please resolve the conflicts.

@gracewehner
Copy link
Author

@tigrannajaryan I have resolved the conflicts

Copy link
Member

@tigrannajaryan tigrannajaryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a description of include_resource_labels config option to README.md.

@github-actions
Copy link
Contributor

github-actions bot commented May 8, 2021

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@alolita
Copy link
Member

alolita commented May 12, 2021

@gracewehner is this PR blocked on review?

@gracewehner
Copy link
Author

@alolita This is ready for review. This is for if we want an option to add job and instance as actual labels, as they're only resource attributes right now in the receiver as per #2897

@github-actions github-actions bot removed the Stale label May 13, 2021
@bogdandrutu
Copy link
Member

@Aneurysm9 @rakyll please review

@gracewehner please rebase

```yaml
receivers:
prometheus:
include_resource_labels: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd not call "instance" and "job" resource labels which sounds like resource attributes which represents something else in Otel.

Also we should have these labels by default to make the Prometheus export work. I would add an option to exclude them.

Why not something like ignore_scrape_labels?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd second this. I think the implementation looks sound, but it would be good to avoid potential confusion of these labels with OTel resource attributes. I'd also think that they should be included by default and a name like ignore_scrape_labels makes it clear that the user is choosing to disable something otherwise useful.

Copy link

@vishiy vishiy May 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the time of this PR, both instance & job did not come from receiver. Now that they are, should we just not do anything here (meaning just close this PR) ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rakyll @Aneurysm9 Do you have an opinion about Vishwa's above comment about how the instance and job labels are now resource attributes (at the original time of this PR they were not)? Are we good with just having them as resource attributes or do we still want them as actual labels, too, which this PR would do? If so, I can make the changes with ignore_scrape_labels suggested above.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR can be closed as the job and instance labels are always included via #2897. This PR would have the advantage of exposing configuration to disable inclusion of those labels, but they are required for Prometheus remote write compatibility and giving the user more knobs to tweak isn't always ideal.

@gracewehner
Copy link
Author

Closing since job and instance labels are included as resource attributes via #2897

@gracewehner gracewehner closed this Jun 1, 2021
hughesjj pushed a commit to hughesjj/opentelemetry-collector that referenced this pull request Apr 27, 2023
Bumps golang from 1.20.1-bullseye to 1.20.2-bullseye.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants