0

I have multiple trivy result entries in prometheus that look like this:

trivy_vulnerability{critical="0", high="12"} 0

Is there a way in prometheus where i retrieve all the trivy_vulnerability entries and get a total sum of the total high cve count?

  • Could you elaborate please: metric `trivy_vulnerability` has 12 as label `high` and this means that you have 12 high vulnerabilities? – markalex Mar 28 '23 at 18:18
  • Yes, excuses that indeed means there are 12 high vulnerabilties found. We have many entries with different numbers. We want to know the total amount of high vulnerabilities (same with critical) – Ginokok1996 Mar 28 '23 at 18:18
  • You can't do it using promQL. And frankly speaking - it's misuse of metrics. – markalex Mar 28 '23 at 18:20
  • If grafana you could try to use [label_values](https://stackoverflow.com/a/61914010/21363224), but I'm not sure if grafana will allow you to aggregate results in some way. – markalex Mar 28 '23 at 18:22
  • 1
    Your issue is that your label (`critical`, `high`) values (`0`,`12`) should be represented as metric values. Something of the form `trivy_vulnerability{severity="high"} 12` and `trivy_vulnerability{severity="critical"} 0`. If that were the structure of your metrics, then you **would** be able to aggregate (sum) values. What are you using to produce the metrics? – DazWilkin Mar 28 '23 at 18:40

0 Answers0