Hi all.
I have an issue creating LLD discovery using HTTP agent item as a prototype.
Short background:
The idea is to create items based on panels in a Grafana dashboard using the Grafana HTTP API. My logic looks as follows:
(If anyone is interested in the Grafana API: https://grafana.com/docs/grafana/lat..._api/alerting/)
To break it down with pictures, here's what the discovery rule looks like:

with the LLD macros:

And the item prototype:

with the following preprocessing steps:

Step 1 works as it should. Or at least it seems like it. The returned JSON looks as such:
(I've masked some stuff here, obviously).
And if I add a javascript preprocessing step with the following code
It shows up in the Zabbix Proxy log.
The HTTP request in the item should get a response that looks as follows:
However, the item doesn't show up. If I add a similar preprocessing step with Zabbix.Log, I don't see anything in the log. I'm assuming it should be the proxy log here as well, but the documentation only states: "Writes <message> into Zabbix log using <loglevel> log level (see configuration file DebugLevel parameter)", and when using the test functionality it logs in the Zabbix Server log. (https://www.zabbix.com/documentation...script_objects)
Does anyone have any idea of what's going on? Debugging of the proxy doesn't give me much either.
I have an issue creating LLD discovery using HTTP agent item as a prototype.
Short background:
The idea is to create items based on panels in a Grafana dashboard using the Grafana HTTP API. My logic looks as follows:
- Use the Grafana alerting HTTP API to get all panels on a dashboard with configured alerts.
- Store the returned names and alert ids in LLD macros.
- Create items using panel name as item name and alert id as a part of the HTTP agent URL.
(If anyone is interested in the Grafana API: https://grafana.com/docs/grafana/lat..._api/alerting/)
To break it down with pictures, here's what the discovery rule looks like:
with the LLD macros:
And the item prototype:
with the following preprocessing steps:
Step 1 works as it should. Or at least it seems like it. The returned JSON looks as such:
[
{
"dashboardId": 74,
"dashboardSlug": "dashboard-zabbix",
"dashboardUid": "XXXXXXXX",
"evalData": {},
"evalDate": "0001-01-01T00:00:00Z",
"executionError": "",
"id": 39,
"name": "alert name",
"newStateDate": "2020-02-25T14:11:37+01:00",
"panelId": 2,
"state": "ok",
"url": "/d/XXXXXXXX/dashboard-zabbix"
}
]
{
"dashboardId": 74,
"dashboardSlug": "dashboard-zabbix",
"dashboardUid": "XXXXXXXX",
"evalData": {},
"evalDate": "0001-01-01T00:00:00Z",
"executionError": "",
"id": 39,
"name": "alert name",
"newStateDate": "2020-02-25T14:11:37+01:00",
"panelId": 2,
"state": "ok",
"url": "/d/XXXXXXXX/dashboard-zabbix"
}
]
And if I add a javascript preprocessing step with the following code
Zabbix.Log(3, "Grafana response: " + value);
return value;
return value;
The HTTP request in the item should get a response that looks as follows:
{
"Id": 39,
"Version": 0,
"OrgId": 1,
"DashboardId": 74,
"PanelId": 2,
"Name": "alert name",
"Message": "",
"Severity": "",
"State": "ok",
"Handler": 1,
"Silenced": false,
"ExecutionError": " ",
"Frequency": 900,
"For": 900000000000,
"EvalData": {},
"NewStateDate": "2020-02-25T14:11:37+01:00",
"StateChanges": 3,
"Created": "2020-02-04T15:57:33+01:00",
"Updated": "2020-02-25T13:57:48+01:00",
"Settings": {
"conditions": [
{
"evaluator": {
"params": [
400
],
"type": "lt"
},
"operator": {
"type": "and"
},
"query": {
"datasourceId": 11,
"model": {
"bucketAggs": [
{
"field": "@timestamp",
"id": "2",
"settings": {
"interval": "auto",
"min_doc_count": 0,
"trimEdges": 0
},
"type": "date_histogram"
}
],
"metrics": [
{
"field": "select field",
"id": "1",
"type": "count"
}
],
"query": "REDACTED",
"refId": "A",
"timeField": "@timestamp"
},
"params": [
"A",
"5m",
"now-1m"
]
},
"reducer": {
"params": [],
"type": "count"
},
"type": "query"
}
],
"executionErrorState": "alerting",
"for": "15m",
"frequency": "15m",
"handler": 1,
"name": "alert name",
"noDataState": "alerting",
"notifications": []
}
}
"Id": 39,
"Version": 0,
"OrgId": 1,
"DashboardId": 74,
"PanelId": 2,
"Name": "alert name",
"Message": "",
"Severity": "",
"State": "ok",
"Handler": 1,
"Silenced": false,
"ExecutionError": " ",
"Frequency": 900,
"For": 900000000000,
"EvalData": {},
"NewStateDate": "2020-02-25T14:11:37+01:00",
"StateChanges": 3,
"Created": "2020-02-04T15:57:33+01:00",
"Updated": "2020-02-25T13:57:48+01:00",
"Settings": {
"conditions": [
{
"evaluator": {
"params": [
400
],
"type": "lt"
},
"operator": {
"type": "and"
},
"query": {
"datasourceId": 11,
"model": {
"bucketAggs": [
{
"field": "@timestamp",
"id": "2",
"settings": {
"interval": "auto",
"min_doc_count": 0,
"trimEdges": 0
},
"type": "date_histogram"
}
],
"metrics": [
{
"field": "select field",
"id": "1",
"type": "count"
}
],
"query": "REDACTED",
"refId": "A",
"timeField": "@timestamp"
},
"params": [
"A",
"5m",
"now-1m"
]
},
"reducer": {
"params": [],
"type": "count"
},
"type": "query"
}
],
"executionErrorState": "alerting",
"for": "15m",
"frequency": "15m",
"handler": 1,
"name": "alert name",
"noDataState": "alerting",
"notifications": []
}
}
Does anyone have any idea of what's going on? Debugging of the proxy doesn't give me much either.
Comment