Skip to content

Commit

Permalink
feat: add exclude-list for logs in /var/log (#216)
Browse files Browse the repository at this point in the history
* feat: add exclude-list for logs in /var/log

* improve config option docs

* improve config option docs

* rename exclude_files to path_exclude
  • Loading branch information
lucabello authored Dec 6, 2024
1 parent 7af0833 commit c0382b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,17 @@ config:
Ref: https://grafana.com/docs/agent/latest/static/configuration/flags/#report-information-usage
type: boolean
default: true
path_exclude:
description: >
Glob for a set of log files present in `/var/log` that should be ignored by Grafana Agent.
For example, `/var/log/**/{app_one,app_two}.log` will result in the agent ignoring both
`/var/log/app_one.log` and `/var/log/app_two.log`.
Note that the value you provide here is not interpreted as a path, but rather as a glob matcher.
Specifically, if you want to exclude logs in the `/var/log/test` folder, you should set the
config to `/var/log/test/**`.
Ref (__path_exclude__): https://grafana.com/docs/loki/latest/send-data/promtail/scraping/
type: string
default: ""
1 change: 1 addition & 0 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ def _additional_log_configs(self) -> List[Dict[str, Any]]:
"targets": ["localhost"],
"labels": {
"__path__": "/var/log/**/*log",
"__path_exclude__": self.model.config.get("path_exclude"),
"job": "varlog",
**self._own_labels,
},
Expand Down

0 comments on commit c0382b7

Please sign in to comment.