Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleJson is deprecated - which plugin to choose #68

Open
AInteriorB opened this issue Nov 17, 2023 · 7 comments
Open

SimpleJson is deprecated - which plugin to choose #68

AInteriorB opened this issue Nov 17, 2023 · 7 comments

Comments

@AInteriorB
Copy link

SimpleJson is marked as deprecated with the following information:

Angular plugin
This data source plugin uses a deprecated, legacy platform based on AngularJS and will stop working in future releases of Grafana.

Do you have any other recommendation for a working plugin?

@cnemo-cenic
Copy link

This might be helpful grafana/grafana-infinity-datasource#740

@ColCh
Copy link

ColCh commented Oct 13, 2024

struggling with this one a bit, as I want to have alerts on smokeping data in my grafana homelab setup...

you should now use this one now, as prev was deprecated long (?) time ago

https://grafana.com/docs/plugins/yesoreyeram-infinity-datasource

examples

grafana/grafana-infinity-datasource#34
grafana/grafana-infinity-datasource#740

note that this server expects only POST and at least targets and range fields as required, defined here:

from, _ := time.Parse(time.RFC3339Nano, queryRequest.Range.From)
to, _ := time.Parse(time.RFC3339Nano, queryRequest.Range.To)

and
for _, target := range queryRequest.Targets {
ds := target.Target[strings.LastIndex(target.Target, ":")+1 : len(target.Target)]
rrdDsRep := regexp.MustCompile(`:` + ds + `$`)
fileSearchPath := rrdDsRep.ReplaceAllString(target.Target, "")
fileSearchPath = strings.TrimRight(config.Server.RrdPath, "/") + "/" + strings.Replace(fileSearchPath, ":", "/", -1) + ".rrd"

looks like it also could have glob in target, see example below

example of request is this:

###############
## URL
###############

http://smokeping-smokeping-rrd-server-1:9000/query

###############
## Curl Command
###############

curl -X 'POST' -d '{
    "targets": [
        {
            "target": "DNSProbes/*:median",
            "refId": "A",
            "hide": false,
            "type": "timeserie"
        }
    ],
    "range": {
        "from": "2024-10-11T15:04:22.044Z",
        "to": "2024-10-13T15:04:22.044Z"
    }
}' -H 'Accept: application/json;q=0.9,text/plain' -H 'Content-Type: application/json' 'http://smokeping-smokeping-rrd-server-1:9000/query'

also see test for query endpoint

// Test for a POST request
requestJSON := `{
"panelId":1,
"range":{
"from":"2017-01-17T05:14:42.237Z",
"to":"2017-01-18T05:14:42.237Z",
"raw":{
"from":"now-24h",
"to":"now"
}
},
"rangeRaw":{
"from":"now-24h",
"to":"now"
},
"interval":"1m",
"intervalMs":60000,
"targets":[
{"target":"sample:ClientJobsIdle","refId":"A","hide":false,"type":"timeserie"},
{"target":"sample:ClientJobsRunning","refId":"B","hide":false,"type":"timeserie"},
{"target":"percent-*:value","refId":"B","hide":false,"type":"timeserie"}
],
"format":"json",
"maxDataPoints":1812
}`

for grafana request body example, you can try this

{
    "targets": [
        {
            "target": "DNSProbes/*:median",
            "refId": "A",
            "hide": false,
            "type": "timeserie"
        }
    ],
    "range": {
        "from": "${__timeFrom:date}",
        "to": "${__timeTo:date}"
    }
}

__timeFrom is special variable, __timeFrom:date formats it as ISO date, looks like this is expected format by this go server.

See docs:

good luck! :)

@wolfgangr
Copy link

wolfgangr commented Oct 13, 2024

You saved my day :+1
---- edit: ---

I'm still struggling with time zones.

    "range": {
        "from": "${__timeFrom:date}",
        "to": "${__timeTo:date}"
    }

shifts the start of my data by 2hrs.
However, as far as I can see, the easiest thing were just to extend "from" and let the display window cut down to the selected area.

As far as I can see, the only literal format accepted is "2017-01-17T05:14:42.237Z".
Any similiar well known formats yield a message
Query processing error - V is undefined

Any clue how I could manipulate time (or other variables) that go into the query body?

@wolfgangr
Copy link

Any chance to retrieve combined series?
a first try yields Query error - ee is null

{
    "targets": [
        {
            "target": "SDM:mySDM_subs1_totalP:Ptot",
            "refId": "A",
            "hide": false,
            "type": "timeserie"
        }
        {
            "target": "SDM:mySDM_subs2_totalP:Ptot",
            "refId": "B",
            "hide": false,
            "type": "timeserie"
        }
    ],
    "range": {
        "from": "${__timeFrom:date}",
        "to": "${__timeTo:date}"
    }
    
}

@ColCh
Copy link

ColCh commented Oct 13, 2024

it not works in my case, as it just places array value in same cell

to get it like rows, i used root data path... pretty hacky

(but for proper use, I think it's needed to use InfluxDB in smokeping, not rrd; but I'm too tired with it and this is okay to me for now)

then I used grafana dashboard to store variables of "target" metrics, then just used "repeat" setting of visualization in grafana

image

this is what I have in "target": "target": "${metric}:median"

this comes from this smokeping rrd files structure (I just selected manually 2 values from here):

image

so graph repeats over those variables

image

you can just import my dashboard and play with it, enjoy

(you might need to customize variables, as I added Yandex here, because ... I need to monitor Russian internet segment as well; and you might not need Yandex here. This thing was configured at smokeping config at first place)

dashboard.json

@ColCh
Copy link

ColCh commented Oct 13, 2024

@wolfgangr for timezone shift, check your server timezone, that macros just takes timezone from server itself. looks like your server uses UTC timezone, and you are in another timezone

@wolfgangr
Copy link

no, actually both machines are running in MEST.
And actually bot machines run the same debian 12.7
oh, and my Browser is on a age old debian 10.whatever, but on MEST, too.

The problem must happen somewhere in the chain
WS-OS -Browser -> Grafana (grafana-machine-OS)-> grafana-rrd-server -> rrdtool (-rrdtool-machine-OS) -> grafana-rrd-server -> Grafana -> Browser

I suspect between grafan-rrd-server and rrdtool.
Mabe time zone correction is done twice.


I think in the long run I'll drop the rrd and collect anything in influx via telegraf and mqtt.
It's just a nasty 2hr gap at the left of all charts. But at least I can combine new data with historic ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants