I am testing Grafana to read and graph data from the Graphite system.
Here's how Grafana expects json data from Graphite:
{ "data": [ { "target": "test-series-0", "datapoints": [ [ 22.504392773143504, 1.476693264195e+12 ], [ 22.719552781746028, 1.476693301825e+12 ] ] } ] }
The system with which I want to read data, swap and metric value, for example
{ "data": [ { "target": "test-series-0", "datapoints": [ [ 1.476693264195e+12 22.504392773143504, ], [ 1.476693301825e+12 22.719552781746028, ] ] } ] }
Is it possible to create a new data source (a copy from the default graphic object data source) that either swaps the values back before processing, or works with the values as is?
I looked at the .js files, but it's hard for me to determine where I need to make changes so that all pointers are appreciated!
EDIT: I tried this: I made a copy of the Graphite plugin by default and renamed it to a graphical copy and adjusted the identifier in plugin.json .
Then I edited datasource.js and datasource.ts as follows:
var e = { method: "POST", url: "/render", data: d.join("&"), headers: { "Content-Type": "application/x-www-form-urlencoded" } }; return a.panelId && (e.requestId = this.name + ".panelId." + a.panelId), this.doGraphiteRequest(e).then(this.convertDataPointsToMs) }, this.convertDataPointsToMs = function(a) { if (!a || !a.data) return []; for (var b = 0; b < a.data.length; b++) for (var c = a.data[b], d = 0; d < c.datapoints.length; d++) { var t = c.datapoints[d][0]; c.datapoints[d][0] = c.datapoints[d][1]; c.datapoints[d][0] = t; c.datapoints[d][1] *= 1e3; }
With a change:
var t = c.datapoints[d][0]; c.datapoints[d][0] = c.datapoints[d][1]; c.datapoints[d][0] = t;
I did this for both GET and POST datasource.js/ts in datasource.js/ts , but it gives me the same result (timestamp and metric).