sensu / sensu-influxdb-handler

Sensu Go InfluxDB Metrics Handler
https://sensu.io
MIT License
14 stars 16 forks source link

Add support for stripping host from metics! #35

Open DoctorOgg opened 4 years ago

DoctorOgg commented 4 years ago

I'm working on migration to sensu-go, and I'm using the legacy sensu, the older influxdb handler supports stripping the hostname from the metric. I have included my configs and a sample query I'm using on the older sensu install. this older format allows systems to be added and removed from my dashboards without changing the query.

{
  "influxdb": {
    "host": "sensu_influxdb",
    "port": 8086,
    "database": "sensu",
    "username": "sensu",
    "password": "sensu",
    "strip_metric": "host"
  }
}
q:"SELECT "value" FROM "memory_percent.usedWOBuffersCaches" WHERE ("host" =~ /^node/) AND time >= now() - 6h GROUP BY "host""

Thanks

nikkictl commented 3 years ago

@DoctorOgg can you provide me with the link to the repo or documentation for the InfluxDB handler you are referring to? I can not validate the strip_metric argument in the supported Sensu Enterprise InfluxDB integration.

magnuslarsen commented 3 years ago

Not OP, but I have to same request :-)

In our old Sensu Core installation, we used Telegraf (from Influx) to pick up metrics in the Graphite format. Telegraf then sent it to a Sensu handler (UDP, listens on a socket, only_check_output mutator attached). That stripped the hostnames of the metric it self, allowing you to create queries like this:

SELECT mean("all_cpus") FROM "ipmi" WHERE ("host" = 'my_hostname') AND $timeFilter GROUP BY time($__interval) fill(null)

The new influxdb-handler already sets a entity_name-tag, with the entity name in it. Having it also in the metric name is redundant:

SELECT mean("ipmi.all_cpus") FROM "my_hostname" WHERE ("sensu_entity_name" = 'my_hostname') AND $timeFilter GROUP BY time($__interval) fill(null)

This also means that you can't create graphs on spanning multiple hosts (here I'm thinking Grafana's variable for entity_name), since the hostname is also the name of the series (instead of just the metric)

Being able to strip the hostnames of the metrics, allows the "Sensu Core metrics" to be compatible with Sensu Go :-)

nikkictl commented 3 years ago

@magnuslarsen Thanks for sharing your support of this issue. It sounds like this feature would be useful to a good number of users, so I'll do my best to keep https://github.com/sensu/sensu-influxdb-handler/pull/39 moving along.

DoctorOgg commented 3 years ago

sorry, just flowing up, I thought it was the official influx handler that was doing this for sensu core. this was a blocker for me moving to sensu go, however, in the long run, i ended up dropping the dataset, and rebuilding all my queries to get moving... so I haven't been using sensu core for a while now.