I need to use the number of CPU cores in multiple calculations on a Grafana dashboard and was hoping to perform the query once and store in a variable. I can't find a way to return the data in a format that Grafana will accept.
Grafana Error:
Template variables could not be initialized: parse error at char 1: vector selector must contain label matchers or metric name
I have tried (PromQL):
count(node_cpu{instance="$host",mode="system"})
Returns:
Element {}, Value 2
Also (PromQL):
scalar(count(node_cpu{instance="$host",mode="system"}))
Returns:
Element scalar, Value 2
Using Grafana's query_result
function like so:
query_result(count(node_cpu{instance="$host",mode="system"}))
I get the following values in the preview:
{} 2 1521669355000
The 2
in the middle is the one I want.
Any ideas how to make this work?