2

I am collecting metrics using telegraf and the system plugin on influxdb, I am trying to create some singlestats pannels to measure the load average on multiple instances with accurate "warnings"

For doing this I need to create a template variable with the number of existing CPUs based on the selected $host in the gauge meter and coloring thresholds options:

SHOW TAG VALUES WITH KEY=host

The dashboard should return only information from the selected host, therefore, I need to dynamically configure the Gauge values max and coloring thresholds so that the colors could change for example to red when the load is matching the number of cores - 1.

Currently, I am hardcoding the values in max = 4 and in the Coloring threshold using 1,3 that is ncpus -1. (this works only for instances having 4 cores, but not for instances having less or more than 4)

enter image description here

My try to create a variable named $ncpus is this:

> SELECT last("n_cpus") FROM "system" WHERE ("host" =~ /^my-host$/) 
name: system
time                last
----                ----
1526379330000000000 4

I want to get the 4 but I am getting the time, this is what I am using currently:

enter image description here

Any idea about how to get only the number of cpus n_cpus so that could be stored in a variable removing the time and also been available to use it in the singlestat options?

nbari
  • 25,603
  • 10
  • 76
  • 131
  • Load value can be more than number of CPUs. Especially if you have modern fast CPU and old slow storage. Really, there is no upper limit for that value. Also is load normalization by using number of CPUs is not correct. It should be number of online CPUs. – Jan Garaj May 15 '18 at 11:33

1 Answers1

1

You should write a query similar to the following

SHOW TAG VALUES ON "DATABASE_NAME" FROM "elasticsearch_cluster_health" WITH KEY = "name"

enter image description here

jbuddy
  • 180
  • 4
  • 14
Abdul Gaffar
  • 340
  • 3
  • 5