prometheus: add detail to unit failed (#62348)

This commit is contained in:
Guillaume Baffoin 2022-03-03 12:03:57 +01:00
parent b75e10d06a
commit 5a0dd085e9
1 changed files with 3 additions and 2 deletions

View File

@ -49,7 +49,7 @@ eo_nginx = Gauge("eo_nginx", "nginx", ["ctn", "name"], registry=registry)
eo_postgresql = Gauge("eo_postgresql", "postgresql", ["ctn", "role", "name"], registry=registry)
eo_rabbitmq = Gauge("eo_rabbitmq", "rabbitmq", ["ctn"], registry=registry)
eo_threads = Gauge("eo_threads", "system threads", ["ctn"], registry=registry)
eo_units = Gauge("eo_units", "systemd units", ["ctn", "state"], registry=registry)
eo_units = Gauge("eo_units", "systemd units", ["ctn", "name", "state"], registry=registry)
eo_packages = Gauge("eo_packages", "packages", ["ctn", "state"], registry=registry)
@ -230,7 +230,8 @@ def units(ctn):
manager = dbus.Interface(s, "org.freedesktop.systemd1.Manager")
units = manager.ListUnits()
n = len([u for u in units if u[3] == "failed" and not u[0].startswith("user@")])
eo_units.labels(ctn, "failed").set(n)
name = [u[0].replace('dbus.String', '') for u in units if u[3] == "failed" and not u[0].startswith("user@")]
eo_units.labels(ctn, name, "failed").set(n)
def run_in_machines(ctn):