-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[Prometheus Receiver] Make prometheus receiver behavior compatible with Prometheus when sd_file does not exist #21680
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] Make prometheus receiver behavior compatible with Prometheus when sd_file does not exist #21680
Conversation
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 think I would prefer to keep this as a type switch to preserve easy extensibility should validation of other SDConfig
types be necessary.
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 originally kept it as type switch for type assertion - but it was giving lint error (go critic) in workflow checks as it only had one case.
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.
can you add a testcase that validates that no error happens in case the file does not exist?
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.
thanks. Updated.
564b4a7
to
6e75d0c
Compare
Description:
This PR achieves the compatibility between Prometheus Receiver and Prometheus when
sd_file
ortargetgroups
are not present at the startup:sd_file_path
is not watchable.sd_file_path
(and not fail with error) when whensd_file
ortargetgroups
are not present at the startup.In order to achieve the above objective, this PR reverts some of the changes made in this PR to add additional config validation for
file_sd
configs. These additional config validation creates incompatibility in the Prometheus and Prometheus Receiver behaviour as also highlighted in this issue:sd_file
fails Collector in error when at the startupsd_file
is not present or thetargetgroup
inside thissd_file
is not present. However, this is not the behaviour of Prometheus- Prometheus has functionality (discovery) which continues to watch thesd_file_path
provided in the config for the updates and subsequent validation.Also, Prometheus doesnt't crash the application at runtime when
sd_file
ortargetgroup
are not present orsd_file_path
does not exist (as originally thought here). Prometheus only logs the error and continues to receive update on thissd_file_path
. - so additionally ensuring the presence ofsd_file
andtagretgroup
and otherwise failing with error in config validation in Collector (like here) disrupts that process.sd_file_path
with the right naming and extension is already done in unmarshal stage in Collector (before config validation) - so providing it again in the config validation is redundant.Link to tracking Issue:
#21509
aws-observability/aws-otel-collector#2039
#5373
aws-observability/aws-otel-collector#1636
Testing:
Manual testing