Grafana, Elasticsearch datasource and option script


Hi there,

I’m using Grafana to display metrics from Elasticsearch that came from Metricbeat.
For the CPU (system.cpu.user.pct) I have a value that is max 100% * cores (so, 4 cores could have a max of 400%).
I need to have a max at 100%.
I use different servers, so I don’t have the same amount of cores on each.
I want to do the math in the option/script box, but I don’t know how to get a value (in the same data, I have the number of core).
Basiclly, I waut to do “_value / {{system.cpu.cores}}”.
Can I do that?



Not sure how to access another field in a elasticsearch script.


Try specifying this in the script field:

_value / doc[‘system.cpu.cores’].value

Is it possible to use another field in option calculation

It worked!!! (just changing the quote to regular single quote, wysiwyg issue :slight_smile: )

thx a lot!


Or rather use double quotes ala:

_value / doc[“system.cpu.cores”].value

otherwise properly the script will be broken, it may all be enclosed within single quotes it self, I’ll assume