z

Commercial Support Clients: Clients with support contracts can get escalated support assistance by visiting Nagios Answer Hub. These forums are for community support services. Although we at Nagios try our best to help out on the forums here, we always give priority support to our support clients.

Getting Value from alerts api via nagios py script

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.

Getting Value from alerts api via nagios py script

Postby RajeshEzrado » Tue Sep 20, 2022 1:01 am

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 critical level:

-w 'annotation.Value,1:70'
Any help would be nice !
RajeshEzrado
 
Posts: 6
Joined: Thu Jun 02, 2022 2:52 am

Return to Open Source Nagios Projects

Who is online

Users browsing this forum: Google [Bot] and 27 guests