Correct output from tg-show-flow-state and tg-show-processor-state

This commit is contained in:
Cyber MacGeddon 2026-04-22 16:14:48 +01:00
parent 7521e152b9
commit aceb0af608
2 changed files with 12 additions and 10 deletions

View file

@ -44,16 +44,18 @@ def show_processors(metrics_url, flow_label):
obj = resp.json() obj = resp.json()
tbl = [ # consumer_state is one sample per consumer (queue); a processor
[ # with N subscriptions shows up N times. Aggregate to one row per
m["metric"]["job"], # processor: green only if every consumer is running.
"\U0001f49a" if int(m["value"][1]) > 0 else "\U0000274c" by_proc = {}
] for m in obj["data"]["result"]:
for m in obj["data"]["result"] name = m["metric"].get("processor", m["metric"]["job"])
] running = int(m["value"][1]) > 0
by_proc[name] = by_proc.get(name, True) and running
for row in tbl: for name in sorted(by_proc):
print(f"- {row[0]:30} {row[1]}") icon = "\U0001f49a" if by_proc[name] else "\U0000274c"
print(f"- {name:30} {icon}")
def main(): def main():

View file

@ -17,7 +17,7 @@ def dump_status(url):
tbl = [ tbl = [
[ [
m["metric"]["job"], m["metric"].get("processor", m["metric"]["job"]),
"\U0001f49a" "\U0001f49a"
] ]
for m in obj["data"]["result"] for m in obj["data"]["result"]