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

prometheusremotewrite: Don't generate target_info unless at least one identifying label is defined #32148

Merged

Conversation

aknuds1
Copy link
Contributor

@aknuds1 aknuds1 commented Apr 3, 2024

Description:
I propose modifying the Prometheus remote write translator such that it will only generate the target_info metric if at least one identifying label is defined, i.e. either job or instance (or both). The rationale is that without any identifying labels, target_info is useless (you can't join against it).

See Slack thread for background.

Testing:
I've modified the addResourceTargetInfo tests to reflect that at least one identifying label is required, and added some new ones to cover the different cases. I also modify a couple of prometheusremotewriteexporter tests that are affected by this change, as they don't define the identifying resource attributes.

Documentation:

@aknuds1 aknuds1 requested review from Aneurysm9 and a team as code owners April 3, 2024 16:15
@aknuds1 aknuds1 force-pushed the bugfix/target-info-required-attrs branch 3 times, most recently from 80658d3 to 9ed9b63 Compare April 3, 2024 16:26
@aknuds1 aknuds1 changed the title prometheusremotewrite: Don't generate target_info unless job is defined prometheusremotewrite: Don't generate target_info unless job label is defined Apr 3, 2024
@aknuds1 aknuds1 force-pushed the bugfix/target-info-required-attrs branch 2 times, most recently from cff5f2b to 19345f6 Compare April 3, 2024 16:45
@github-actions github-actions bot requested a review from rapphil April 3, 2024 16:46
@dashpole
Copy link
Contributor

dashpole commented Apr 3, 2024

May I ask which receiver you are using? OTel SDKs default service.name to unknown_service if it isn't provided by users.

We already have a config knob for disabling target_info. Does that not meet your needs?

@aknuds1
Copy link
Contributor Author

aknuds1 commented Apr 3, 2024

@dashpole I'm not aware of a specific component exhibiting this problem. I'm approaching this from the Prometheus perspective (I'm one of the Prometheus OTLP maintainers), where I think there should be a guarantee that target_info as generated by the OTel to Prometheus converter has the minimum identifying label set (i.e., job, as instance can't guaranteed with service.instance.id not being mandatory). Having this guarantee is useful when explicitly persisting the identifying metrics of info metrics (e.g. target_info) to the TSDB in Prometheus, which is something I'm prototyping.

We already have a config knob for disabling target_info. Does that not meet your needs?

I'm not looking to disable target_info, the motivation is to define that service.name (and thus the job label) is mandatory when generating target_info.

Considering that service.name is mandatory according to the spec (@jpkrohling says that an OTel metrics write payload should be considered invalid if it's missing), what would stand in the way of enforcing it in the OTel -> Prometheus converter?

@dashpole
Copy link
Contributor

dashpole commented Apr 3, 2024

Thanks for the context.

Considering that service.name is mandatory according to the spec (@jpkrohling says that an OTel metrics write payload should be considered invalid if it's missing)

My understanding is that service.name is mandatory for OTel SDKs, but not for the protocol. It comes from here: https://opentelemetry.io/docs/specs/semconv/resource/#service, which doesn't apply to the protocol.

That being said, I support requiring join keys for target_info to make it useful. I could see us doing either:

  1. Require either job or instance to be set
  2. Require job to be set
  3. Require instance to be set
  4. Require both job and instance to be set

(1) or (2) both seem reasonable to me. It would be nice to document the behavior in the conversion spec: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/compatibility/prometheus_and_openmetrics.md#resource-attributes-1

@aknuds1
Copy link
Contributor Author

aknuds1 commented Apr 4, 2024

Thanks for the feedback @dashpole! Let me confer with @jpkrohling.

@aknuds1
Copy link
Contributor Author

aknuds1 commented Apr 4, 2024

That being said, I support requiring join keys for target_info to make it useful. I could see us doing either:

Require either job or instance to be set
Require job to be set
Require instance to be set
Require both job and instance to be set

@dashpole the feedback from @jpkrohling is a preference for option 1 or 2, slightly leaning towards option 1, as it's more lenient. What I am wondering though, is whether we should have a dummy value if one of the two labels is missing? Since the expectation in Prometheus is for target_info to have both job and instance labels to join against. WDYT?

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
@aknuds1 aknuds1 force-pushed the bugfix/target-info-required-attrs branch from 19345f6 to e1da396 Compare April 4, 2024 15:41
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
@aknuds1 aknuds1 force-pushed the bugfix/target-info-required-attrs branch from e1da396 to 7ac5a7c Compare April 4, 2024 15:48
@aknuds1 aknuds1 changed the title prometheusremotewrite: Don't generate target_info unless job label is defined prometheusremotewrite: Don't generate target_info unless at least one identifying label is defined Apr 4, 2024
@aknuds1
Copy link
Contributor Author

aknuds1 commented Apr 4, 2024

I've revised the PR as per our Slack discussion @dashpole, thanks for all the feedback.

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
@aknuds1
Copy link
Contributor Author

aknuds1 commented Apr 12, 2024

CI failure looks like a flake.

…-info-required-attrs

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Copy link
Member

@Aneurysm9 Aneurysm9 left a comment

Choose a reason for hiding this comment

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

We cannot ignore existing service names.

pkg/translator/prometheusremotewrite/helper.go Outdated Show resolved Hide resolved
pkg/translator/prometheusremotewrite/helper.go Outdated Show resolved Hide resolved
aknuds1 and others added 3 commits April 25, 2024 11:22
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
@aknuds1 aknuds1 requested a review from Aneurysm9 April 25, 2024 09:30
@aknuds1
Copy link
Contributor Author

aknuds1 commented Apr 25, 2024

@Aneurysm9 applied your suggestions, PTAL :)

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
@dashpole dashpole added the ready to merge Code review completed; ready to merge by maintainers label Apr 29, 2024
@jpkrohling jpkrohling merged commit 95e8f8f into open-telemetry:main Apr 30, 2024
176 checks passed
@github-actions github-actions bot added this to the next release milestone Apr 30, 2024
@aknuds1 aknuds1 deleted the bugfix/target-info-required-attrs branch April 30, 2024 07:32
rimitchell pushed a commit to rimitchell/opentelemetry-collector-contrib that referenced this pull request May 8, 2024
…ne identifying label is defined (open-telemetry#32148)

**Description:** <Describe what has changed.>
I propose modifying the Prometheus remote write translator such that it
will only generate the `target_info` metric if at least one identifying
label is defined, i.e. either `job` or `instance` (or both). The
rationale is that without any identifying labels, `target_info` is
useless (you can't join against it).

See [Slack
thread](https://cloud-native.slack.com/archives/C01LSCJBXDZ/p1712161732017409)
for background.

**Testing:** <Describe what testing was performed and which tests were
added.>
I've modified the `addResourceTargetInfo` tests to reflect that at least
one identifying label is required, and added some new ones to cover the
different cases. I also modify a couple of
`prometheusremotewriteexporter` tests that are affected by this change,
as they don't define the identifying resource attributes.

**Documentation:** <Describe the documentation added.>

---------

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
jlg-io pushed a commit to jlg-io/opentelemetry-collector-contrib that referenced this pull request May 14, 2024
…ne identifying label is defined (open-telemetry#32148)

**Description:** <Describe what has changed.>
I propose modifying the Prometheus remote write translator such that it
will only generate the `target_info` metric if at least one identifying
label is defined, i.e. either `job` or `instance` (or both). The
rationale is that without any identifying labels, `target_info` is
useless (you can't join against it).

See [Slack
thread](https://cloud-native.slack.com/archives/C01LSCJBXDZ/p1712161732017409)
for background.

**Testing:** <Describe what testing was performed and which tests were
added.>
I've modified the `addResourceTargetInfo` tests to reflect that at least
one identifying label is required, and added some new ones to cover the
different cases. I also modify a couple of
`prometheusremotewriteexporter` tests that are affected by this change,
as they don't define the identifying resource attributes.

**Documentation:** <Describe the documentation added.>

---------

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exporter/prometheusremotewrite pkg/translator/prometheus ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants