Skip to content

Conversation

PaurushGarg
Copy link
Member

@PaurushGarg PaurushGarg commented May 9, 2023

Description:

This PR achieves the compatibility between Prometheus Receiver and Prometheus when sd_file or targetgroups are not present at the startup:

  1. With this PR, Collector should log error message (but not fail) if the sd_file_path is not watchable.
  2. With this PR, Collector should continue watching path if sd_file_path (and not fail with error) when when sd_file or targetgroups 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:

  1. The config validation for sd_file fails Collector in error when at the startup sd_file is not present or the targetgroup inside this sd_file is not present. However, this is not the behaviour of Prometheus- Prometheus has functionality (discovery) which continues to watch the sd_file_path provided in the config for the updates and subsequent validation.
    Also, Prometheus doesnt't crash the application at runtime when sd_file or targetgroup are not present or sd_file_path does not exist (as originally thought here). Prometheus only logs the error and continues to receive update on this sd_file_path. - so additionally ensuring the presence of sd_file and tagretgroup and otherwise failing with error in config validation in Collector (like here) disrupts that process.
  2. The check to validate presence of 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

@PaurushGarg PaurushGarg requested a review from a team May 9, 2023 16:36
@github-actions github-actions bot added the receiver/prometheus Prometheus receiver label May 9, 2023
@PaurushGarg PaurushGarg changed the title [Prometheus Receiver} Remove sd_file validations from config.go in Prometheus Receiver [Prometheus Receiver] Make prometheus receiver behaviour compatible with prometheus when sd_file does not exist May 9, 2023
@PaurushGarg PaurushGarg changed the title [Prometheus Receiver] Make prometheus receiver behaviour compatible with prometheus when sd_file does not exist [Prometheus Receiver] Make prometheus receiver behaviour compatible with Prometheus when sd_file does not exist May 9, 2023
@PaurushGarg PaurushGarg changed the title [Prometheus Receiver] Make prometheus receiver behaviour compatible with Prometheus when sd_file does not exist [Prometheus Receiver] Make prometheus receiver behavior compatible with Prometheus when sd_file does not exist May 9, 2023
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 I would prefer to keep this as a type switch to preserve easy extensibility should validation of other SDConfig types be necessary.

Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks. Updated.

@PaurushGarg PaurushGarg force-pushed the ecs_observer_issue branch from 564b4a7 to 6e75d0c Compare May 24, 2023 04:33
@PaurushGarg PaurushGarg requested a review from rapphil May 24, 2023 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to merge Code review completed; ready to merge by maintainers receiver/prometheus Prometheus receiver

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants