Page 1 of 1

Getting Value from alerts api via nagios py script

PostPosted: Thu Aug 04, 2022 7:15 am
by SandraLewisFrin
So basicly my problem is :
There is a JSON output : asd.local/api/alertmanager/grafana/api/v2/alerts site,

and I figured I can find the value:
curl http://secret:secret@asd.local/api/aler ... /v2/alerts | jq '.[2] | {summary: .annotations.Value}'

And Im really want to use this nagios plugin: https://github.com/drewkerrigan/nagios- ... n#examples

But every time I try to pass the thing I want , the key doesnt exist. I have 5 alerts , all similar to the one I want to check. What am I doing wrong ? I cant even find the value.

./check_http_json.py -H asd.local -p api/alertmanager/grafana/api/v2/alerts -B secret:secret '--key_exists' 'annotations.Value'
WARNING: Status WARNING. Key annotations.Value did not exist.
My 2nd alert JSON output (i have 5 alerts atm, and I want to do a check for all ):



{
"annotations": {
"Value": "79.15237728630086",
"__dashboardUid__": "oImjCZw7k",
"__panelId__": "13",
"__value_string__": "[ var='B' labels={app=rook-ceph-mgr, ceph_daemon_id=a, ceph_daemon_type=mgr, instance=a, job=kubernetes-pods, kubernetes_namespace=rook-ceph, kubernetes_pod_name=rook-ceph-mgr-a-756f8f9db7-2lwrh, mgr=a, pod_template_hash=756f8f9db7, rook_cluster=rook-ceph} value=79.15237728630086 ], [ var='C' labels={app=rook-ceph-mgr, ceph_daemon_id=a, ceph_daemon_type=mgr, instance=a, job=kubernetes-pods, kubernetes_namespace=rook-ceph, kubernetes_pod_name=rook-ceph-mgr-a-756f8f9db7-2lwrh, mgr=a, pod_template_hash=756f8f9db7, rook_cluster=rook-ceph} value=1 ]",
"summary": "rook-ceph disk usage reach 70% tmo-preprod"
},
"endsAt": "2022-05-08T17:39:26.509Z",
"fingerprint": "46e38998309bd18d",
"receivers": [
{
"name": "asd"
}
],
"startsAt": "2022-05-08T16:58:36.509Z",
"status": {
"inhibitedBy": [],
"silencedBy": [],
"state": "active"
},
"updatedAt": "2022-05-08T17:38:01.540Z",
"generatorURL": "http://localhost:3000/alerting/mjIAVt_nk/edit",
"labels": {
"__alert_rule_uid__": "mjIAVt_nk",
"alertname": "High Disk Usage > 70%",
"app": "rook-ceph-mgr",
"ceph_daemon_id": "a",
"ceph_daemon_type": "mgr",
"instance": "a",
"job": "kubernetes-pods",
"kubernetes_namespace": "rook-ceph",
"kubernetes_pod_name": "rook-ceph-mgr-a-756f8f9db7-2lwrh",
"mgr": "a",
"pod_template_hash": "756f8f9db7",
"rook_cluster": "rook-ceph"
}
}
The goal would be setting a warning and omegle shagle voojio critical level:

-w 'annotation.Value,1:70'