Search code examples
grafanainfluxdb

InfluxDB: Query From Multiple Series


I have an influxdb instance, in which an upstream server is logging measurements into. I have multiple series of the shape: web.[domain].[status], for example: web.www.foobar.com.2xx, web.www.quux.com.3xx etc. There are two "variables" encoded into the series name: the domain and the status (2xx, 3xx, etc. are already aggregated).

Now I'd like to see how many of those requests I get. One possibility would be to just list the series:

select sum("value") from "web.www.quux.com.2xx","web.www.quux.com.3xx",...

But this is neither practical (too many) nor actually feasible (new domains are added and removed all the time), so I need a more flexible approach.

Is there some kind of wildcard syntax allowed in the from clause? The documentation doesn't mention any. Or is there another way to approach this?


Solution

  • You should to avoid this kind of measurement naming convention:

    https://docs.influxdata.com/influxdb/v1.8/concepts/schema_and_data_layout/#avoid-encoding-data-in-measurement-names

    hAvoid encoding data in measurement names

    InfluxDB queries merge data that falls within the same measurement; it’s better to differentiate data with tags than with detailed measurement names. If you encode data in a measurement name, you must use a regular expression to query the data, making some queries more complicated or impossible.