Follow

Anyone that can help?
Need to pre-process data in Grafana before displaying it in the graph (just removing a certain amount - to be calculated by script - of each value and calculating the percentage of each value compared to the highest one).
I have the code for it working in JS (from the old webpage I used to display graphs) but can't find how to do this in Grafana...
Or am I gonna have to setup _another_ service (eg.an HTTP API) just for this?

· · Web · 2 · 2 · 0

@finlaydag33k If you use Prometheus as data source you can use "-" and "/" to subtract and divide.

But you might need to turn the "certain amount" and "highest_one" into metrics to be able to use them in the query.

@lerk Well, that's kind of an issue..
I don't know _what_ to subtract (this should be calculated when updating the graph), see screenshot for how I did it in JS.

(just ignore the `samples` variable, that's not needed in Grafana).

@finlaydag33k I'm not sure about this but maybe you can use the transformation feature for this:

grafana.com/docs/grafana/next/

@lerk Aye, I did have a go at that as well and while it _did_ fix some other things for me, I wasn't able to get the thing I wanted with it :\

@finlaydag33k What would you be setting as your datasource in Grafana?

@finlaydag33k Grafana only supports basic mathematical operations:
grafana.com/docs/grafana/lates
It is a tool for data visualisation after all, so for more complex calculations you have to rely on a datasource which provides those you need via query.

@totoroot Hmm I see... So I'd have to just create another service for it then.
Not a big issue but not desirable (because well... more stuff to run).

@finlaydag33k Grafana's devs always seem to be more interested in keeping the software as lean as possible, since a visualisation tool that supports so many different types of visualisations and various datasources could easily become a slow and resource-intensive monolith

Working with Grafana on a daily basis at my job, I am quite thankful for this approach, although sometimes also frustrated by the resulting limitations

@totoroot Yea, though some kind of way to like do some scripting with the data shouldn't be too much right?

Sign in to participate in the conversation
Linux.Pizza

A instance dedicated - but not limited - to people with an interest in the GNU+Linux ecosystem and/or general tech. Sysadmins to enthusiasts, creators to movielovers - Welcome!