fix(trivy): deduplicate vulnerability counts to avoid per-container m…#175
Merged
dotdc merged 1 commit intodotdc:masterfrom Mar 18, 2026
Merged
fix(trivy): deduplicate vulnerability counts to avoid per-container m…#175dotdc merged 1 commit intodotdc:masterfrom
dotdc merged 1 commit intodotdc:masterfrom
Conversation
Contributor
Author
|
@dotdc hi. Could you please review the PR? Thanks ❤️ |
dotdc
approved these changes
Mar 18, 2026
Owner
|
🎉 This PR is included in version 3.0.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The

trivy_image_vulnerabilitiesmetric is emitted once per container instancethat uses a given image, not once per unique image. When the same image (e.g.
bitnami/kubectl:1.35.0) is used by N containers in a namespace, the currentsum(trivy_image_vulnerabilities{...})multiplies the actual vulnerability countby N.
Example: 40 unique Medium vulnerabilities in an image used by 8 containers →
dashboard shows 320 instead of 40.
Fix
Wrap each
sum()withmax by (namespace, image_registry, image_repository, image_tag, severity)to deduplicate across container instances before summing:The
max byselects one representative time series per unique image+severitycombination, discarding the per-pod/container labels (
container_name,pod,resource_name, etc.) that cause the inflation.Panels affected (9)
Notes