Skip to content

app/vlagent/kubernetescollector: add metadata-based filtering for Kubernetes logs#927

Merged
valyala merged 1 commit intomasterfrom
filter-containers
Dec 19, 2025
Merged

app/vlagent/kubernetescollector: add metadata-based filtering for Kubernetes logs#927
valyala merged 1 commit intomasterfrom
filter-containers

Conversation

@vadimalekseev
Copy link
Member

Describe Your Changes

Fixes #923

Checklist

The following checks are mandatory:

@vadimalekseev vadimalekseev force-pushed the filter-containers branch 6 times, most recently from d82441f to fe255ed Compare December 18, 2025 21:37
@valyala valyala merged commit 9ca3ab7 into master Dec 19, 2025
8 checks passed
@valyala valyala deleted the filter-containers branch December 19, 2025 08:00
@valyala
Copy link
Contributor

valyala commented Dec 19, 2025

@vadimalekseev , thank you for the pull request!

@vadimalekseev
Copy link
Member Author

@valyala, I've been giving this some thought: do you think we should invert the logic of the filter flag? For example, which would be more intuitive for a user who wants to avoid collecting logs from the frontend namespace:
-kubernetesCollector.filter="namespace:=frontend"
or
-kubernetesCollector.filter="not namespace:=frontend"?

Current logic is the first one.

valyala added a commit that referenced this pull request Dec 19, 2025
…or.excludeFilter

This should reduce confusion for the users who use this command-line flag,
since this flag excludeds logs from containers matching the given filter.

This is a follow-up for the commit 9ca3ab7

Updates #923
Updates #927
@valyala
Copy link
Contributor

valyala commented Dec 19, 2025

@vadimalekseev , I renamed -kubernetesCollector.filter command-line flag to -kubernetesCollector.excludeFilter in the commit 612d8af in order to make it less confusing for users to use. This flag accepts filters for exclusion of the logs, not for inclusion of the logs.

@func25
Copy link
Contributor

func25 commented Dec 19, 2025

How about pod annotations? I was expecting to be able to filter similarly to Prometheus-style scrape annotations :s

@valyala
Copy link
Contributor

valyala commented Dec 19, 2025

How about pod annotations? I was expecting to be able to filter similarly to Prometheus-style scrape annotations

Agreed :) @vadimalekseev , what do you think about adding the ability to filter by node / pod annotations? There is no need to add these annotations to the set of log stream labels.

@vadimalekseev
Copy link
Member Author

Yes, the is a good idea, already working on it

@vadimalekseev
Copy link
Member Author

The implementation might take longer than I planned because we store commonFields on disk in checkpointsDB without any mechanism to update them.

As a result, even if we add this information, it won't work for existing (old) pods. I want to move away from storing commonFields on disk. This is better architectural solution, but we need to come up with a workaround for restoring file reading in restarts case and still being able to remove checkpoints for deleted files. I have an idea and I'm currently working on it.

I will create an issue for this.

@valyala
Copy link
Contributor

valyala commented Dec 20, 2025

I think it should be OK to assume that labels and annotations are immutable for already deployed pods. In this case you don't need to update this data in the checkpointsDB. This can be documented. This should be easier to do than dynamic update of the labels and annotations for already discovered pods.

@vadimalekseev
Copy link
Member Author

@valyala agree. Created PR to include and exclude Node/Pod labels and annotations: #934
I will continue working on the metadata update issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vlagent: add pod filtering for kubernetes collector

3 participants

Comments