fix(promtail): validate scrape_config job name - #13719
Conversation
Signed-off-by: François Gouteroux <francois.gouteroux@gmail.com>
4d0a9e3 to
c020273
Compare
|
I think this is a good thing to fix, but imo we should do it as early as possible. We can reuse the same model Prometheus does and override the structs yaml unmarshal function: https://github.com/prometheus/prometheus/blob/main/config/config.go#L371-L382 @grafana/agent-squad does this seem like the right fix to you guys? |
|
Hi, I gave the PR a ✅ since I don't mind the fix staying like this, but I do agree that checking the config during the unmarshal stage would be better. @fgouteroux, would it be possible for you to do the check during the unmarshal? |
|
|
||
| cfg.Setup(p.logger) | ||
| var err error | ||
| err = scrapeconfig.ValidateJobName(cfg.ScrapeConfig) |
There was a problem hiding this comment.
Do we only need the check during a config reload? Is it not also necessary when Promtail starts?
ptodev
left a comment
There was a problem hiding this comment.
I'm going to remove the ✅ until we clarify how we'd like to proceed 😄
|
Do you want I implement what @cstyan suggest ? |
@fgouteroux yes, it sounds reasonable. |
@cstyan implementation done |
cstyan
left a comment
There was a problem hiding this comment.
@fgouteroux sorry, I was out on vacation
LGTM, thanks!
What this PR does / why we need it:
Fix the panic error when there is duplicate job name defined in scrape config:
Which issue(s) this PR fixes:
n/a
Special notes for your reviewer:
I've also tested the code in branch k190 (removing v3 version in import statement) and I built the grafana-agent with it.
In case of duplicate job_name it failed at the startup with this error message:
Checklist
CONTRIBUTING.mdguide (required)featPRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.docs/sources/setup/upgrade/_index.mdproduction/helm/loki/Chart.yamland updateproduction/helm/loki/CHANGELOG.mdandproduction/helm/loki/README.md. Example PRdeprecated-config.yamlanddeleted-config.yamlfiles respectively in thetools/deprecated-config-checkerdirectory. Example PR