Dashboard using JSON Infinity

Hello,
I’m using an API that returns a graph stored in InfluxDB in JSON format.
Can I generate a line chart from this file?
Here is an example of the return:
Obs.: I removed the points so it wouldn’t be too big

{
	"background_color": 16777215,
	"unit": "bits\/s",
	"from_unixtime": "1710190160",
	"until_unixtime": "1710276619",
	"graph": {
		"labels": [
			"Mon 18:00",
			"Mon 21:00",
			"Tue 00:00",
			"Tue 03:00",
			"Tue 06:00",
			"Tue 09:00",
			"Tue 12:00",
			"Tue 15:00"
		],
		"data": {
			"0": {
				"description": "",
				"color": 52275,
				"color_outbound": 5086924,
				"y_axis": {
					"positive": {
						"min": 0,
						"max": 247733,
						"avg": 11200,
						"last": 2346,
						"95th": 80746,
						"sum": 3248100,
						"points": [
						]
					},
					"negative": {
						"min": 0,
						"max": 0,
						"avg": 0,
						"last": 0,
						"95th": 0,
						"sum": 0,
						"points": [
						]
					}
				}
			}
		}
	}
}

Welcome @vitoroiticica to forum

What have you tried so far and where are you stuck?

Might want to read this doc

https://grafana.github.io/grafana-infinity-datasource/docs/uql

Thanks.
I tried to get just the points from the graphs and what would be the x-axis, labels.
I don’t know how I can use this data to create a graph. Do I have to transform the points string into numbers?
I would like to do something similar to the graphic in PNG.

I will read the indicated documentation. Thanks!

1 Like

This is as far as I was able to get by filtering only certain values ​​and transforming Y axis with extract fields.

Maybe the unixtime information isn’t even relevant.

1 Like

Looking great! Why all the hops, from grafana to api to influx. Why not grafana to influx directly?

Bureaucracy within the company, the administrator only provided us with access to the API.

Any ideas on how to polish the graph and insert information about min, max, avg, etc.?

Please post sample json payload. Obfuscated but with the skeleton intact explaining all of your requirements, which data point for min, max, etc in words not in pictures

Help us help you. Then we will point you to documents to read on how you can approach it, then after you try things out and maybe are stuck, we can provide guidance

There is no sensitive data in this JSON. Below is a complete sample.

{
    "background_color": 16777215,
    "unit": "bits\/s",
    "from_unixtime": "1710244146",
    "until_unixtime": "1710330605",
    "graph": {
        "labels": [
            "Tue 09:00",
            "Tue 12:00",
            "Tue 15:00",
            "Tue 18:00",
            "Tue 21:00",
            "Wed 00:00",
            "Wed 03:00",
            "Wed 06:00"
        ],
        "data": {
            "0": {
                "description": "",
                "color": 52275,
                "color_outbound": 5086924,
                "y_axis": {
                    "positive": {
                        "min": 0,
                        "max": 247733,
                        "avg": 9045,
                        "last": 1866,
                        "95th": 80746,
                        "sum": 2623049.5,
                        "points": [
                            0,
                            0,
                            4160,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            55306,
                            0,
                            0,
                            3893,
                            4426.5,
                            4960,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            80746,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            28053,
                            0,
                            0,
                            80746,
                            28053,
                            80746,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            4160,
                            42453,
                            80746,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            14346,
                            0,
                            0,
                            0,
                            247733,
                            164239.5,
                            80746,
                            70106,
                            59466,
                            3893,
                            102240,
                            0,
                            0,
                            0,
                            28053,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            3360,
                            42053,
                            80746,
                            0,
                            0,
                            0,
                            2346,
                            2773,
                            3200,
                            80746,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            15840,
                            0,
                            0,
                            1866,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            34080,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            8000,
                            4000,
                            0,
                            0,
                            4000,
                            4000,
                            4000,
                            0,
                            0,
                            0,
                            80746,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            2346,
                            11733,
                            0,
                            0,
                            1866,
                            0,
                            0,
                            211520,
                            57652,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            3893,
                            2266,
                            7520,
                            83119,
                            0,
                            0,
                            0,
                            14346,
                            14346,
                            32000,
                            3200,
                            0,
                            0,
                            7120,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            80746,
                            82826,
                            84906,
                            0,
                            0,
                            4160,
                            0,
                            0,
                            0,
                            95093,
                            0,
                            0,
                            1866,
                            0,
                            0,
                            0,
                            0,
                            2933,
                            4960,
                            3413,
                            1866,
                            1866,
                            0,
                            0,
                            0,
                            0,
                            1866,
                            14346,
                            0,
                            0,
                            0,
                            0,
                            0,
                            1866,
                            0,
                            0,
                            0,
                            80746,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            3946,
                            3653,
                            3799.5,
                            3946,
                            0,
                            0,
                            0,
                            0,
                            0,
                            48426,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            1866,
                            0
                        ]
                    },
                    "negative": {
                        "min": 0,
                        "max": 0,
                        "avg": 0,
                        "last": 0,
                        "95th": 0,
                        "sum": 0,
                        "points": [
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0,
                            0
                        ]
                    }
                }
            }
        }
    }
}

and now for this part.

I want a graph where the X axis is labels and the Y axis has all points.
I would like the legend to have the json information of min, max, avg, last, 95th and sum.
All information present within the graph, in this case.

I need new help.
In the API query it returns labels based on the time I selected.
Ex.: Last 1h he returns me hh:mm / Last 3 Days returns me DD (Mon, Tue, Wed…) hh:mm
How do I transform it into a date according to each query?
If I can do this, it solves all my problems.