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

Targets not required in promtail config #2026

Merged

Conversation

adityacs
Copy link
Contributor

@adityacs adityacs commented May 1, 2020

What this PR does / why we need it:
Targets are not required in promtail config. If defined in config we will just use that otherwise we will just add dummy host.

Which issue(s) this PR fixes:
Fixes #1929

Checklist

  • Documentation added
  • Tests updated

@adityacs
Copy link
Contributor Author

adityacs commented May 1, 2020

@slim-bean Does this change has any impact on docker driver and any other module? I am not aware of other uses of this. Hope this change doesn't break anything

@adityacs adityacs force-pushed the 1929_targets_not_required_for_scrape branch from eb59543 to 40fd630 Compare May 1, 2020 07:19
@pull-request-size pull-request-size bot added size/M and removed size/XS labels May 1, 2020
@adityacs adityacs force-pushed the 1929_targets_not_required_for_scrape branch from 40fd630 to 6181cb6 Compare May 1, 2020 07:23
for i, tg := range cfg.ServiceDiscoveryConfig.StaticConfigs {
tg.Source = fmt.Sprintf("%d", i)
if !(len(tg.Targets) > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if !(len(tg.Targets) > 0) {
if len(tg.Targets) == 0 {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perfect. Thanks @owen-d

@adityacs adityacs force-pushed the 1929_targets_not_required_for_scrape branch from 6181cb6 to 94f71ce Compare May 1, 2020 13:39
@codecov-io
Copy link

Codecov Report

Merging #2026 into master will increase coverage by 0.00%.
The diff coverage is 0.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2026   +/-   ##
=======================================
  Coverage   63.82%   63.82%           
=======================================
  Files         133      133           
  Lines       10208    10211    +3     
=======================================
+ Hits         6515     6517    +2     
- Misses       3204     3206    +2     
+ Partials      489      488    -1     
Impacted Files Coverage Δ
pkg/promtail/targets/filetargetmanager.go 0.00% <0.00%> (ø)
pkg/logql/evaluator.go 91.27% <0.00%> (+0.58%) ⬆️

Copy link
Member

@owen-d owen-d left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Everything looks good, but I'm not informed enough on this part of the project to know if we want this change.

I have a few questions:

  • Why do we assign dummy? These must be localhost in all cases as promtail can only scrape a file system.
  • Do we want this shortcut? Is it worth the confusion of having identical-behaving configs, one which uses targets and one which omits it?

Part of me thinks we could make the case for removing the targets field entirely b/c it's not relevant to promtail. However this would create difficulties trying to copy/paste prometheus service discovery code into promtail.

@cyriltovena suggested silently omitting this and removing targets from the docs, which would keep compatibility while minimizing confusion in many cases.

@slim-bean Can you weigh in?

@adityacs
Copy link
Contributor Author

adityacs commented May 8, 2020

@owen-d We don't have to name it dummy, we can make it localhost. But we should assign some target name otherwise target sync code will be skipped and file targets won't be initialized.

Also, I am completely for "removing this(targets) silently from the docs". Just that it should not confuse the existing users.

However this would create difficulties trying to copy/paste prometheus service discovery code into promtail.

Agree on this but I think users will eventually get adjusted to this

…s will be more intuitive for people, also re-worded the docs a bit.

Signed-off-by: Ed Welch <edward.welch@grafana.com>
@slim-bean
Copy link
Collaborator

Wanted to get this into the 1.5 RC so I inserted my opinions via git push :)

I think using localhost instead of dummy will be more intuitive for people and less confusing/alarming if they are looking at the promtail /targets and /service-discovery http pages.

I also re-worded the docs a bit.

Copy link
Collaborator

@slim-bean slim-bean left a comment

Choose a reason for hiding this comment

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

I ran this locally with and without targets and it LGTM!

@slim-bean slim-bean merged commit 11937d3 into grafana:master May 13, 2020
@adityacs
Copy link
Contributor Author

Thank you @slim-bean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

targets should not be required for promtail scrape config
4 participants