lusis / sensu_influxdb_handler

A sensu handler for sending metrics to influxdb
Other
43 stars 36 forks source link

query optimization #8

Open jcmartins opened 9 years ago

jcmartins commented 9 years ago

Hi, I'm using Influxdb v0.8.8 with this handler.

this handler created a Serie with the same plugin name, exemple: metric_cpu_pcnt with the columns below:

time sequence_number value host metric 1421090211000 193692360001 1 i.5e2e894b.lb.tnt.portal.core.uat.sa.east.1.test.net lb.tnt-portal.core.uat.sa-east-1.cpu.total.user

I would like be a query to find a CPU consume per host like this:

select value from "metric_cpu_pcnt" where host =~ /^i.5e2e894b/ AND metric =~ /cpu.total.user$/ and time > now() - 15m;

This query is very slow because when the query use regex in the columns the regex needs to be match for EVERY measurement, and measurements for ALL "metrics" needs to be loaded.

Why this extension work this away?

The correct are not this: (serie name = hostname + metric) ? series name: i.5e2e894b.lb.tnt-portal.core.uat.sa-east-1.cpu.total.user , columns: [time, value]

Because: when the query use regex on the series names, not the column values, the series names are in memory in influxdb and the lookup and regex mach is quick as it only needs to be done once.

tks Joao