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

promtail: exclude files from static_configs __path__ #3804

Closed
rgl opened this issue Jun 5, 2021 · 7 comments
Closed

promtail: exclude files from static_configs __path__ #3804

rgl opened this issue Jun 5, 2021 · 7 comments
Labels
component/promtail good first issue These are great first issues. If you are looking for a place to start, start here! stale A stale issue or PR that will automatically be closed. type/feature Something new we should do

Comments

@rgl
Copy link
Contributor

rgl commented Jun 5, 2021

Is your feature request related to a problem? Please describe.

my /var/log directory has files with different structures, which requires me to use different pipeline_stages for each set of different files.

Describe the solution you'd like

something like this would exclude all files that match the pattern /host/var/log/contained.*.log:

    static_configs:
      - labels:
          job: logwrite
          __path__: /host/var/log/*.log
          __path_exclude__: /host/var/log/contained.*.log

or maybe call it __exclude_path__?

or even modify __path__ to be an array where the array items that start with ! exclude paths?

if you agree, I can prepare a PR to modify the code (and docs) at:

matched, err := doublestar.Match(t.path, event.Name)
if err != nil {
level.Error(t.logger).Log("msg", "failed to match file", "error", err, "filename", event.Name)
continue
}
if !matched {
level.Debug(t.logger).Log("msg", "new file does not match glob", "filename", event.Name)
continue
}
t.startTailing([]string{event.Name})

to do a second call to doublestar.Match before calling t.startTailing.

@dannykopping dannykopping added component/promtail type/feature Something new we should do good first issue These are great first issues. If you are looking for a place to start, start here! labels Jun 16, 2021
@stale
Copy link

stale bot commented Jul 17, 2021

This issue has been automatically marked as stale because it has not had any activity in the past 30 days. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale A stale issue or PR that will automatically be closed. label Jul 17, 2021
@stale stale bot closed this as completed Jul 29, 2021
@rgl
Copy link
Contributor Author

rgl commented Jul 29, 2021

Should this be implemented as described?

Can this issue be re open?

@michaelkebe
Copy link

Please reopen this feature request to allow excluding specific paths.

@kamaradski
Copy link

kamaradski commented Aug 31, 2021

I would also like this to be re-opened for consideration.

In my case, Promtail is reading all files from /var/log/ but there is one file where the Promtail user does not have access to (on purpose) and this is spawning constant errors in my logs. path exclusion would be my preferred way to deal with this specific scenario.

@jadegouws
Copy link

I would also like this option, Please can it be reopened

@joemiller
Copy link
Contributor

+1 for re-opening this

@Brettdah
Copy link

Brettdah commented Mar 7, 2022

I would add that I'm using promtail on a synology NAS and it has a folder named synolog
for now I had somthing like :

- job_name: local
  static_configs:
  - targets:
      - localhost
    labels:
      job: varlogs
      __path__: /var/log/*log

And I found that I my want *.log or _log from that directory, cause _log are the result of the smart tests of my HDD
Or should I just create a new scrape_config for those... :/ that answer is making think xD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/promtail good first issue These are great first issues. If you are looking for a place to start, start here! stale A stale issue or PR that will automatically be closed. type/feature Something new we should do
Projects
None yet
Development

No branches or pull requests

7 participants