Problem with Grafana and .RRD file reads

Hi,

We are trying to get Grafana to use the sni-pnp-datasource on an updated install with everything at the latest version. We have an existing setup that is working just fine but it is at an older version of everything. We had to make some changes to the api.php (class issues in latest php release) and we now have pnp4nagios correctly providing graphs etc.

When we try to graph using the .rrd files we are getting zero values in the graph but when I check the rrd files (using rrdtool) I can see that the query provided should return the data for Grafana.

Here is the text (I cannot upload files as a new user)
This is the output of the rrdtool fetch request

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
1713444120: 1.7000000000e-01 8.0000000000e-02 2.0000000000e-02
1713444180: 1.7000000000e-01 8.0000000000e-02 2.0000000000e-02
1713444240: 1.4400000000e-01 7.5666666667e-02 2.0000000000e-02
1713444300: 5.0000000000e-02 6.0000000000e-02 2.0000000000e-02
1713444360: 5.0000000000e-02 6.0000000000e-02 2.0000000000e-02

This is the query shown in the grafana interface
{
“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
],

Here is the query run through rrdtool.
rrdtool fetch Current_Load.rrd AVERAGE -s 1713441475 -e 1713445075 > test.dta

As you can see the data returned from the rrdtool is correct but the data returned into the grafana is incorrect? The dates and times look the same for the output as well (Grafana has extended dates with 3 extra ‘000’ but I cannot see how that would effect the data in the value columns?

I have gone as far as my knowledge can take me in figuring out why the mismatch causes the values to be 0 (maybe the date?) so I am asking if anyone has any idea about what is causing this problem.

Chris…

try using ${__from:date:seconds} instead of ${__from}

the extra 3 0’s are for millisecond resolution:

So, based on your response this is not a problem and would not cause the issue? The data is correctly formed based on the request made.

Chris…

I found the error, looks like someone sabotaged the api.php script so that it would always return 0 for the values. All fixed up now and the data is returned correctly.

1 Like