Counting from string values

Hi all,

I’m adding a few things in my influxdb from telegraf clients and I’m struggling with “string” values.
My linux clients are sending every 48h their

  • linux_version (ie “CentOS Linux”)
  • pretty_name (ie “Debian GNU/Linux 11 (bullseye)”)
  • kernel version (ie “5.10.0-18-amd64”)

Now I’m trying to make a simple “count” of how many machines I have per “linux_version” and displays that in grafana with one gauge per version and the corresponding count.
So something like

Debian Linux:  ||||||||||||||| 48
CentOS Linux:  |||| 12
SomethingElse: ||3

As flux is not the clearest language, I’m a bit lost and for now the only thing I could get is a table with each machine and it’s “linux_name”.

from(bucket: "servers")
  |> range(start: -48h)
  |> filter(fn: (r) => r["_measurement"] == "os-information")
  |> filter(fn: (r) => r["_field"] == "linux_version")
  |> drop(columns: ["_time", "_measurement", "_start", "_stop", "tag1", "_field"])
  |> last()
  |> group()
| Debian GNU/Linux | prod-server    |
| Debian GNU/Linux | test-server    |
| Debian GNU/Linux | backup-server  |
| CentOS Linux     | other-server   |
| CentOS Linux     | file-server    |

Every time I’m trying to “count()” things, I end up with an unique number.

What should I do to get what I need?

Many thanks in advance!


  |> last()
  |> duplicate(column: "_value", as: "linux_version")
  |> group(columns: ["linux_version"])
  |> count()
  |> group()

Without duplicate() this should work as well

  |> last()
  |> group(columns: ["_value"])
  |> count(column: "xxx") // some existing column other than `_value`
  |> group()

Perfect, thanks!
By the way is there any course or something for influx language? This stuff is really not clear :-x