node-exporter-textfile-collector-scripts icon indicating copy to clipboard operation
node-exporter-textfile-collector-scripts copied to clipboard

Added Security Updates as separate Value

Open manuel-held opened this issue 3 years ago • 4 comments

Signed-off-by: Manuel [email protected]

manuel-held avatar Jul 12 '22 12:07 manuel-held

Isn't this already achievable with simple label matching? For example, with these source metrics:

# HELP apt_upgrades_pending Apt package pending updates by origin.
# TYPE apt_upgrades_pending gauge
apt_upgrades_pending{origin="Debian:11.4/stable",arch="all"} 2
apt_upgrades_pending{origin="Debian:11.4/stable",arch="amd64"} 14
apt_upgrades_pending{origin="Debian:11.4/stable,Debian-Security:11/stable-security",arch="all"} 2
apt_upgrades_pending{origin="Debian:11.4/stable,Debian-Security:11/stable-security",arch="amd64"} 11
apt_upgrades_pending{origin="Debian-Security:11/stable-security",arch="amd64"} 1

... I can get the number of security upgrades with sum(apt_upgrades_pending{origin=~".*Debian-Security.*"})

PS: I think we'd prefer not to tempt fate by doing precisely the thing that apt warns against doing.

$ apt list --upgradable | grep -c "\-security"

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

dswarbrick avatar Jul 12 '22 16:07 dswarbrick

Hi @dswarbrick, yes this is possible. But if you're using Grafana and use a Query like sum by(job) (apt_upgrades_pending{origin=~".*Security.*"}) you get "No Data" if there are no Updates, which is not so informative.

manuel-held avatar Jul 13 '22 07:07 manuel-held

@manuel-held How about simply changing your query to

sum by(job) (apt_upgrades_pending{origin=~".*Security.*"}) or vector(0)

dswarbrick avatar Jul 13 '22 15:07 dswarbrick

This has been superseded by https://github.com/prometheus-community/node-exporter-textfile-collector-scripts/pull/99

SuperQ avatar Jul 25 '22 19:07 SuperQ

Closing, since apt.sh has been superseded by apt_info.py.

dswarbrick avatar Oct 11 '22 15:10 dswarbrick

Hello @dswarbrick , with sum by(job) (apt_upgrades_pending{origin=~".*Security.*"}) or vector(0) you only get {} 0 as a global result when there are no match / no security upgrades on each instance. Is it possible to still have a vector with 0 for each original value of apt_upgrades_pending instead ?

copolycube avatar Dec 29 '22 22:12 copolycube