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

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

Hi I am working on the metric script too. Could you please tell me what does it mean by writting _value/doc[‘system.cpu.cores’].value?
I tried to work on my datasource. If I just select the data.buildNum the total is 18115446666. But when I added the _value/doc[‘data.buildNum’].value in the script. The total changed to 764366.