Infinity plugin - Unable to create graph from JSON values

Hello,

I used the Infinity plugin to make a call to REST API.
The following is the JSON response with timestamp (epoch) and values.

{
“timeStamp”:[1609455600000,1609456500000,1609457400000,1609458300000,1609459200000,1609460100000,1609461000000],
“values”:[5,10,15,10,10,5,5]
}

I am unable to get the values from both the fields.
Here is how I am trying to access,

Thank you in advance.

Hi,

I call @yesoreyeram who worked on the plugin to help, my first guess is that your json is not well formated, can you try with only one value.

Check this out might help :

Hope it helps.

Good Luck

@wlargou: Thank you for your suggestion.

If I change to format from Time Series to table, I got below response.

All the values are displayed in single line, instead of different rows.
Also, the values are not getting displayed in Time Series format.

Hi,

Make sense, you should have your data structure in JSON as timestamp/value pairs, currently you have all timestamps as an entry and all values at entry.

Good Luck

As @wlargou mentioned, Your json needs to be array of elements something like this

[
  { "timestamp" : 12345, "value" : 0.1 },
  { "timestamp" : 12346, "value" : 0.2 }
]

@vkamath - Unfortunately, current version of plugin doesn’t support the format you have now. May be will see if I can fix this in future versions. Thanks for testing the plugin.

1 Like

Thank you @wlargou and @yesoreyeram for all the help.

1 Like

My timeseries data look like this:



 {
        "type": "machine",
        "id": "187561",
        "signal": "value.common.cu.gnss.satellites.number",
        "aggregationFunction": "raw",
        "totalDatapoints": 139,
        "timeseries": [
            {
                "time": 1667560340000,
                "value": 11.0
            },
            {
                "time": 1667560399000,
                "value": 10.0
            },
            {
                "time": 1667560459000,
                "value": 10.0
            },
            {
                "time": 1667560519000,
                "value": 13.0
            }
        ]
    }
]

So basically the data structure is very much the same as in the example from the documentation page from thingspeak.
But the data are not being parsed:


What could be the problem here?

I found the rootcause. The values are nested in an array. This is how I could fix it:
grafik

Hey @yesoreyeram. I know its an old post but do you have any updates ? can the plugin now handle the format:

{
"timeseries":
    {
      "timestamp":[12345, 12346], 
      "values": [1,2]
    }
}

Thanks for your answer

@emanueljoos , possibly something like this with uql

parse-json
| scope "timeseries"
| project "values"=array_from_entries('timestamp',"timestamp", 'values',"values")
| extend "timestamp"=unixtime_milliseconds_todatetime("timestamp")

@yesoreyeram Thank you this works perfectly.

1 Like

@yesoreyeram Hey this is wonderful plugin. But i got a question, The dev team is dumping all metrics in a endpoint as payload, How can I create a timeseries graph using the json data by hitting that url every 5 mins and show the count graphically instead of table?

Here is sample data, few fields will keep updating after the plugin auto hits the endpoint url

{
“partCount”: 2,
“hostCount”: 2,
“nodeCount”: 244760,
“agents”: {
“agentCount”: 245058,
“execRate”: 699927,
“execTime”: 76907365184
},
“downlinks”: {
“linkCount”: 460258
},
“uplinks”: {
“linkCount”: 457014,
“eventCount”: 175
},
“system”: {
“cpuUsage”: 194,
“cpuTotal”: 400,
“memUsage”: 15690321920,
“memTotal”: 16596205568,
“diskUsage”: 19375001600,
“diskTotal”: 128838533120,
“startTime”: 1687268610193
}
}

kindly help

@yesoreyeram - Can you please help in the below query to plot it as timeseries? I have tried a lot and arrived at the below jsonata to join timestamp and value as timeseries. Now it is appearing in table with tabular format but unable to use timeseries.

parse-json
|jsonata “result[0].data[*].{‘host’: dimensionMap.‘dt.entity.host’,‘dimensions’:dimensions[0],‘timeseries’:$map(timestamps,function($ts,$i) { {‘timestamp’:$fromMillis($ts),‘CPU Usage’:values[$i]}})}”

Actual JSON data:
[
{
“data”: [
{
“dimensionMap”: {
“dt.entity.host”: “HOST-XXX”
},
“dimensions”: [
“HOST-XXX”
],
“timestamps”: [
1738368000000
],
“values”: [
99.62907695770264
]
},
{
“dimensionMap”: {
“dt.entity.host”: “HOST-YYY”
},
“dimensions”: [
“HOST-YYY”
],
“timestamps”: [
1738368000000
],
“values”: [
96.59589695930481
]
}
],

}
]

@yesoreyeram - Awaiting your response please. Tried till here
parse-json

|jsonata “result[0].data[*].{‘host’: dimensionMap.‘dt.entity.host’,‘dimensions’:dimensions[0],‘timeseries’:$map(timestamps,function($ts,$i) { {‘timestamp’:$fromMillis($ts),‘CPUUsage’:values[$i]}})}”
|project “timeseries”, “dimensions”
|mv-expand “timeseries”
|project “timeseries” , “dimensions”
|project “timeseries.timestamp”,“dimensions”,“timeseries.CPUUsage”

Still I’m not able to plot as timeseries as I could not create multiple columns (for CPUUsage field). What am I missing here?

Hi @harinikalyan - Thank you for trying grafana and sorry you are having trouble. I don’t think community members can/will help you to write the exact JSONata you needed for your specific usecase. You can try using online JSONata excerciser to figure out what you need.

Since this is not related to the original post, I recommend creating new post if JSONata excerciser didn’t help.

All the best.
Sriram