Using predict_linear to predict if disk will fill in N hours

1,767 views
Skip to first unread message

zhug...@gmail.com

unread,
May 29, 2018, 10:56:33 AM5/29/18
to Prometheus Users
Hey guys,

Here is my current query to get the percentage of disk usage my containers:

container_fs_usage_bytes{device=~"/dev/x.*"} / container_fs_limit_bytes{device=~"/dev/x.*"} * 100

Now, based on this article: I want to use predict_linear to send an alert if the disk looks like its gonna fill in N hours.

Here is the query I've been struggling with (I just want the estimated percentage of disk utilized 4 hours from now): 

predict_linear(container_fs_usage_bytes{device=~"/dev/x.*"} / container_fs_limit_bytes{device=~"/dev/x.*"} * 100, 4 * 3600)

This query returns the following error: Error executing query: parse error at char 124: expected type matrix in call to function "predict_linear", got vector



Can anybody tell me how I am thinking about this wrong? 

Also, is there an easy way to get the type of prometheus value returned by the queries in the GUI tool?

Thanks,

Zach

Ben Kochie

unread,
May 29, 2018, 11:13:33 AM5/29/18
to zhug...@gmail.com, Prometheus Users
If you're trying to write an alerting rule, you probably want something like this:

predict_linear(container_fs_usage_bytes{device=~"/dev/x.*"}[1h]), 4 * 3600) > container_fs_limit_bytes

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/63701f48-05f5-44f9-b416-30e7653ac9dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

zhug...@gmail.com

unread,
May 29, 2018, 11:18:50 AM5/29/18
to Prometheus Users
Aaah. Thanks Ben! 

I realized now that keeping the `container_fs_limit_bytes` in the predict_linear function is silly because that is a hard limit...i.e. no need to predict what it will be in 4 hours. 

Thank you for taking the time to write this response, I still need to do some testing but this looks like it is exactly what I was looking for.


On Tuesday, May 29, 2018 at 11:13:33 AM UTC-4, Ben Kochie wrote:
If you're trying to write an alerting rule, you probably want something like this:

predict_linear(container_fs_usage_bytes{device=~"/dev/x.*"}[1h]), 4 * 3600) > container_fs_limit_bytes
On Tue, May 29, 2018 at 4:56 PM, <zhug...@gmail.com> wrote:
Hey guys,

Here is my current query to get the percentage of disk usage my containers:

container_fs_usage_bytes{device=~"/dev/x.*"} / container_fs_limit_bytes{device=~"/dev/x.*"} * 100

Now, based on this article: I want to use predict_linear to send an alert if the disk looks like its gonna fill in N hours.

Here is the query I've been struggling with (I just want the estimated percentage of disk utilized 4 hours from now): 

predict_linear(container_fs_usage_bytes{device=~"/dev/x.*"} / container_fs_limit_bytes{device=~"/dev/x.*"} * 100, 4 * 3600)

This query returns the following error: Error executing query: parse error at char 124: expected type matrix in call to function "predict_linear", got vector



Can anybody tell me how I am thinking about this wrong? 

Also, is there an easy way to get the type of prometheus value returned by the queries in the GUI tool?

Thanks,

Zach

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages