feat: add various infrastructure check and automation scripts
This commit is contained in:
28
scripts/check_prom_labels.py
Normal file
28
scripts/check_prom_labels.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import requests
|
||||
import json
|
||||
import urllib3
|
||||
urllib3.disable_warnings()
|
||||
|
||||
auth = ("admin", "Katzir476!!!")
|
||||
def prom_query(q):
|
||||
url = "https://grafana.snarfnet.net/api/datasources/proxy/1/api/v1/query"
|
||||
resp = requests.get(url, params={"query": q}, auth=auth, verify=False, timeout=10)
|
||||
return resp.json().get("data", {}).get("result", [])
|
||||
|
||||
res_nodes = prom_query("node_load1")
|
||||
print(f"Node Exporter targets ({len(res_nodes)}):")
|
||||
for r in res_nodes:
|
||||
m = r.get("metric", {})
|
||||
print(f" instance: {m.get('instance')}, job: {m.get('job')}, nodename: {m.get('nodename')}, cluster: {m.get('cluster')}")
|
||||
|
||||
res_containers = prom_query("count by (cluster, job, node) (container_last_seen{container!=''})")
|
||||
print("\nContainer metric groupings:")
|
||||
for r in res_containers:
|
||||
print(" ", r.get("metric"))
|
||||
|
||||
# Check all label values for 'cluster' or 'job'
|
||||
res_jobs = prom_query("count by (job) (up)")
|
||||
print("\nPrometheus jobs:")
|
||||
for r in res_jobs:
|
||||
print(" ", r.get("metric"))
|
||||
|
||||
Reference in New Issue
Block a user