InfluxDB query to PromQL

1.6k views Asked by At

I need to translate InfluxDB query to PromQL, please help. These are the requests: https://github.com/influxdata/telegraf/tree/master/plugins/inputs/diskio

Calculate percent IO utilization per disk and host:

SELECT non_negative_derivative(last("io_time"),1ms) FROM "diskio" WHERE time > now() - 30m GROUP BY "host","name",time(60s)

Calculate average queue depth: iops_in_progress will give you an instantaneous value. This will give you the average between polling intervals.

SELECT non_negative_derivative(last("weighted_io_time"),1ms) from "diskio" WHERE time > now() - 30m GROUP BY "host","name",time(60s)

1

There are 1 answers

0
valyala On

The following PromQL queries should work assuming this conversion scheme is used for converting InfluxDB data to Prometheus data:

max(rate(diskio_io_time[60s])/1000) by (host, name)
max(rate(diskio_weighted_io_time[60s])/1000) by (host, name)

The division by 1000 is needed in order to convert milliseconds to seconds for the corresponding time series - diskio_io_time and diskio_weighted_io_time.

Prometheus accepts time range for the query via start and end args passed to /api/v1/query_range Prometheus querying API handler, so queries above have no filters on time.