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

Allow more flexible journal log filters #7096

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

goakley
Copy link

@goakley goakley commented Jan 4, 2021

What does this PR do?

Previously it was only possible to filter on the _SYSTEMD_UNIT property of journal log entries.
Users may want to filter their logs on other fields, so this change allows users to use any journal KEY=VALUE filter to include/exclude journal logs from collection.

Motivation

We have logs in our journals that are not associated with specific systemd units, but that we don't want to send to datadog.
Also addresses #5579

Describe your test plan

Unit tests have been provided.
End-to-end testing can be done by modifying the journald logging file of a datadog process to use different filters.

Previously it was only possible to filter on the _SYSTEMD_UNIT property
of journal log entries. Users may want to filter their logs on other
fields, so this change allows users to use any journal KEY=VALUE filter
to include/exclude journal logs from collection.
@goakley goakley requested review from a team as code owners January 4, 2021 23:31
@bits-bot
Copy link
Collaborator

bits-bot commented Jan 4, 2021

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@bobvanderlinden
Copy link

Yes, very much like I imagined this feature to be 👍 Thanks for the PR! I hope it will be reviewed soon.

@djmitche djmitche added this to the Triage milestone Aug 6, 2021
@djmitche djmitche added the [deprecated] team/agent-core Deprecated. Use metrics-logs / shared-components labels instead.. label Aug 6, 2021
@djmitche djmitche removed the request for review from a team April 4, 2022 18:18
Copy link
Contributor

@djmitche djmitche left a comment

Choose a reason for hiding this comment

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

Well, this has been open for a while -- sorry about that!

I think this implementation looks pretty good! The issues I see are minor:

  • We don't typically deprecate things unless it's impossible to continue to support them. So, I think we'd consider the .._units config still supported.
  • This needs a rebase, but it shouldn't be too bad (the files have moved but not changed too much)

Comment on lines +115 to +118
submatches := matchRe.FindStringSubmatch(match)
if len(submatches) < 1 {
return fmt.Errorf("incorrectly formatted ExcludeMatch (must be `[field]=[value]`: %s", match)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency, this check should be done on IncludeMatches, as well.

@@ -31,7 +32,7 @@ type Tailer struct {
source *config.LogSource
outputChan chan *message.Message
journal *sdjournal.Journal
blacklist map[string]bool
blacklist map[string]map[string]bool // a map of string to a "set" of strings
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
blacklist map[string]map[string]bool // a map of string to a "set" of strings
blacklist map[string]map[string]bool // blacklist[key][value] -> true, perhaps?

Also, and I realize you didn't introduce this issue, but since the value of the map is never false, this could be map[string]map[string]struct{}. The struct{} idiom better suggests "set" instead of "map".

@frits-v frits-v mentioned this pull request Jul 28, 2022
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[deprecated] team/agent-core Deprecated. Use metrics-logs / shared-components labels instead..
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants