sni / grafana-pnp-datasource

PNP4Nagios/RRD Datasource for Grafana
MIT License
28 stars 12 forks source link

Grafana not receiving values #76

Closed ChrisHird closed 5 months ago

ChrisHird commented 5 months ago

Error when pulling in data to grafana.

Here is a sample of the data available in .rrd files generated by pnp4nagios. Command used to extract the data : rrdtool fetch Current_Load.rrd AVERAGE -s 1713441475 -e 1713445075

1713441480: 2.0000000000e-02 4.0000000000e-02 0.0000000000e+00 1713441540: 3.7333333333e-02 4.4333333333e-02 2.1666666667e-03 1713441600: 1.0000000000e-01 6.0000000000e-02 1.0000000000e-02 1713441660: 1.0000000000e-01 6.0000000000e-02 1.0000000000e-02 1713441720: 1.0000000000e-01 6.0000000000e-02 1.0000000000e-02 1713441780: 1.0000000000e-01 6.0000000000e-02 1.0000000000e-02 1713441840: 8.4833333333e-02 5.7833333333e-02 7.8333333333e-03 1713441900: 3.0000000000e-02 5.0000000000e-02 0.0000000000e+00 1713441960: 3.0000000000e-02 5.0000000000e-02 0.0000000000e+00 1713442020: 3.0000000000e-02 5.0000000000e-02 0.0000000000e+00 1713442080: 3.0000000000e-02 5.0000000000e-02 0.0000000000e+00 1713442140: 2.5666666667e-02 5.0000000000e-02 0.0000000000e+00 1713442200: 1.0000000000e-02 5.0000000000e-02 0.0000000000e+00 1713442260: 1.0000000000e-02 5.0000000000e-02 0.0000000000e+00 1713442320: 1.0000000000e-02 5.0000000000e-02 0.0000000000e+00 1713442380: 1.0000000000e-02 5.0000000000e-02 0.0000000000e+00 1713442440: 1.8666666667e-02 5.4333333333e-02 2.1666666667e-03 1713442500: 5.0000000000e-02 7.0000000000e-02 1.0000000000e-02 1713442560: 5.0000000000e-02 7.0000000000e-02 1.0000000000e-02 1713442620: 5.0000000000e-02 7.0000000000e-02 1.0000000000e-02 1713442680: 5.0000000000e-02 7.0000000000e-02 1.0000000000e-02 1713442740: 6.9500000000e-02 7.0000000000e-02 1.0000000000e-02 1713442800: 1.4000000000e-01 7.0000000000e-02 1.0000000000e-02 1713442860: 1.4000000000e-01 7.0000000000e-02 1.0000000000e-02 1713442920: 1.4000000000e-01 7.0000000000e-02 1.0000000000e-02 1713442980: 1.4000000000e-01 7.0000000000e-02 1.0000000000e-02 1713443040: 1.2050000000e-01 7.0000000000e-02 1.0000000000e-02 1713443100: 5.0000000000e-02 7.0000000000e-02 1.0000000000e-02 1713443160: 5.0000000000e-02 7.0000000000e-02 1.0000000000e-02 1713443220: 5.0000000000e-02 7.0000000000e-02 1.0000000000e-02 1713443280: 5.0000000000e-02 7.0000000000e-02 1.0000000000e-02 1713443340: 6.9500000000e-02 7.6500000000e-02 1.4333333333e-02 1713443400: 1.4000000000e-01 1.0000000000e-01 3.0000000000e-02 1713443460: 1.4000000000e-01 1.0000000000e-01 3.0000000000e-02 1713443520: 1.4000000000e-01 1.0000000000e-01 3.0000000000e-02 1713443580: 1.4000000000e-01 1.0000000000e-01 3.0000000000e-02 1713443640: 1.3783333333e-01 9.5666666667e-02 2.7833333333e-02 1713443700: 1.3000000000e-01 8.0000000000e-02 2.0000000000e-02 1713443760: 1.3000000000e-01 8.0000000000e-02 2.0000000000e-02 1713443820: 1.3000000000e-01 8.0000000000e-02 2.0000000000e-02 1713443880: 1.3000000000e-01 8.0000000000e-02 2.0000000000e-02 1713443940: 1.3866666667e-01 8.0000000000e-02 2.0000000000e-02 1713444000: 1.7000000000e-01 8.0000000000e-02 2.0000000000e-02 1713444060: 1.7000000000e-01 8.0000000000e-02 2.0000000000e-02

This is the query run from Grafana and the output (truncated). { "request": { "url": "api/datasources/proxy/uid/cdhqub3mm2wowb/index.php/api/metrics", "method": "POST", "data": { "app": "explore", "timezone": "browser", "startTime": 1713445074677, "interval": "2s", "intervalMs": 2000, "panelId": 21594, "targets": [ { "refId": "A", "datasource": { "type": "sni-pnp-datasource", "uid": "cdhqub3mm2wowb" }, "host": "localhost", "service": "Current_Load", "perflabel": "load1", "type": "AVERAGE", "fill": "fill", "factor": "1", "alias": "" } ], "range": { "from": "2024-04-18T11:57:54.675Z", "to": "2024-04-18T12:57:54.675Z", "raw": { "from": "now-1h", "to": "now" } }, "requestId": "explore_gnu", "rangeRaw": { "from": "now-1h", "to": "now" }, "scopedVars": { "interval": { "text": "2s", "value": "2s" }, "interval_ms": { "text": 2000, "value": 2000 } }, "maxDataPoints": 2377, "liveStreaming": false, "start": "1713441475", "end": "1713445075" }, "hideFromInspector": false }, "response": { "targets": [ [ { "start": 1713441480000, "end": 1713445080000, "host": "localhost", "service": "Current_Load", "perflabel": "load1", "type": "AVERAGE", "datapoints": [ [ 0, 1713441480000 ], [ 0, 1713441540000 ], [ 0, 1713441600000 ], [ 0, 1713441660000 ], [ 0, 1713441720000 ], [ 0, 1713441780000 ], [ 0, 1713441840000 ], [ 0, 1713441900000 ], [ 0, 1713441960000 ], [ 0, 1713442020000 ], [ 0, 1713442080000 ], [ 0, 1713442140000 ], [ 0, 1713442200000 ], [ 0, 1713442260000 ], [ 0, 1713442320000 ],

As you can see we are being returned 0 values for some reason. I have looked through all of the logs available and I cannot find anything that would explain the reason for the invalid values. We are running php 8.2 which did cause a number of issues with the api.php file (we corrected the class use issue) and Grafana now states the datasource is valid.

Any pointers would be appreciated.

ChrisHird commented 5 months ago

OK I have found the problem, looks like someone sabotaged the api.php script so that it would always return 0. Fixed up the script on our fork so it now works.

sni commented 5 months ago

glad to hear it's working now :-)