Correct output from tg-show-flow-state and tg-show-processor-state (#846)

This commit is contained in:
cybermaggedon 2026-04-22 16:16:36 +01:00 committed by GitHub
parent 7521e152b9
commit 95c3b62ef1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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()
tbl = [
[
m["metric"]["job"],
"\U0001f49a" if int(m["value"][1]) > 0 else "\U0000274c"
]
for m in obj["data"]["result"]
]
# consumer_state is one sample per consumer (queue); a processor
# with N subscriptions shows up N times. Aggregate to one row per
# processor: green only if every consumer is running.
by_proc = {}
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:
print(f"- {row[0]:30} {row[1]}")
for name in sorted(by_proc):
icon = "\U0001f49a" if by_proc[name] else "\U0000274c"
print(f"- {name:30} {icon}")
def main():

View file

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