0

I have a server running standard Prometheus node exporter. Metrics are properly collected. Now I need to display in Grafana rate of time spend for IO operations on all devices.

In the /metrics for my server I am getting the following (among other metrics)

# HELP node_disk_io_time_weighted_seconds_total The weighted # of seconds spent doing I/Os.
# TYPE node_disk_io_time_weighted_seconds_total counter
node_disk_io_time_weighted_seconds_total{device="dm-0"} 3800.91
node_disk_io_time_weighted_seconds_total{device="dm-1"} 37118.635
node_disk_io_time_weighted_seconds_total{device="dm-2"} 129.778
node_disk_io_time_weighted_seconds_total{device="dm-3"} 3475.8250000000003
node_disk_io_time_weighted_seconds_total{device="dm-4"} 8.892
node_disk_io_time_weighted_seconds_total{device="dm-5"} 6210.612
node_disk_io_time_weighted_seconds_total{device="dm-6"} 14.934000000000001
node_disk_io_time_weighted_seconds_total{device="dm-7"} 2228.0750000000003
node_disk_io_time_weighted_seconds_total{device="dm-8"} 1029.349
node_disk_io_time_weighted_seconds_total{device="sda"} 20042.765
node_disk_io_time_weighted_seconds_total{device="sdb"} 137.591
node_disk_io_time_weighted_seconds_total{device="sr0"} 0.007

I wrote the following query

rate(sum by(device)(node_disk_io_time_weighted_seconds_total{instance="myserver:9100"}))[1m]

and I got parsing error message: "parse error: ranges only allowed for vector selectors" If I take out [1m] from the query it suppose to reverse to default interval of 1 second, but I am getting different parsing error message: "parse error: expected type range vector in call to function "rate", got instant vector" I am pretty new to PromQL, so forgive me if I do not yet understand its functions details, but I someone point out what I am doing wrong and how to fix my query, I'll appreciate it.

4
  • First apply rate, then sum. Commented Nov 1, 2023 at 6:44
  • I did apply rate first but got the same error messages Commented Nov 1, 2023 at 18:10
  • 1
    Your query should be like this: sum by(device)(rate(node_disk_io_time_weighted_seconds_total{instance="myserver:9100"} [1m])). If it is, no error should occur. Commented Nov 1, 2023 at 18:50
  • My bad. I had extra parentheses in the query. I.e. instead of {...}[1m] I had (metric{...})[1m]. Now it is working Commented Nov 3, 2023 at 23:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.