-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
fix(promtail): validate scrape_config job name #13719
fix(promtail): validate scrape_config job name #13719
Conversation
Signed-off-by: François Gouteroux <[email protected]>
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? |
clients/pkg/promtail/promtail.go
Outdated
@@ -139,10 +140,16 @@ func (p *Promtail) reloadConfig(cfg *config.Config) error { | |||
} | |||
|
|||
cfg.Setup(p.logger) | |||
var err error | |||
err = scrapeconfig.ValidateJobName(cfg.ScrapeConfig) |
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.
Do we only need the check during a config reload? Is it not also necessary when Promtail starts?
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'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 |
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.
@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.md
guide (required)feat
PRs 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.md
production/helm/loki/Chart.yaml
and updateproduction/helm/loki/CHANGELOG.md
andproduction/helm/loki/README.md
. Example PRdeprecated-config.yaml
anddeleted-config.yaml
files respectively in thetools/deprecated-config-checker
directory. Example PR