Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support calculating max rate over time #2129

Closed
bobrik opened this Issue Oct 27, 2016 · 6 comments

Comments

Projects
None yet
4 participants
@bobrik
Copy link

bobrik commented Oct 27, 2016

What did you do?

I have a metric that is a counter (cpu time). I want to calculate max 5m rate over the last 1d to get the estimate max sustained cpu usage for my thing for capacity planning reasons. Turns out, I can't construct such expression. I can only construct "5m rate over the last 1d" part with:

rate(cadvisor_container_cpu_user_seconds_total{marathon_app_id="/foo/bar"}[5m])
  • Prometheus version:
prometheus, version 1.2.1 (branch: master, revision: 05b140e6b2da83e1315518eadd9be7f185adb998)
  build user:       vagrant@53206eae2e4e
  build date:       20161013-14:14:23
  go version:       go1.7.1
@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Oct 27, 2016

You need to create a recording rule for the rate, and then use max_over_time on that.

@bobrik

This comment has been minimized.

Copy link
Author

bobrik commented Oct 30, 2016

@brian-brazil I am probably doing it wrong, but it doesn't make any difference.

Without any rules

Query:

max_over_time(rate(cadvisor_container_cpu_user_seconds_total{marathon_app_id=~"/foo/.+"}[5m]))

Gives:

Error executing query: parse error at char 95: expected type matrix in call to function "max_over_time", got vector

With rule

Used rule:

cadvisor:cpu_user:rate = rate(cadvisor_container_cpu_user_seconds_total{marathon_app_id=~".+"}[3m])

Query with that rule:

max_over_time(cadvisor:cpu_user:rate{marathon_app_id=~"/foo/.+"})

Gives:

Error executing query: parse error at char 66: expected type matrix in call to function "max_over_time", got vector

Even if it should only work with the rule, I think it's worth mentioning that in docs with explanation. It doesn't seem obvious, at least for me.

@mattbostock

This comment has been minimized.

Copy link
Contributor

mattbostock commented Oct 31, 2016

Does the following work?
max_over_time(cadvisor:cpu_user:rate{marathon_app_id=~"/foo/.+"}[5m])

On Sun, 30 Oct 2016, 19:02 Ivan Babrou, notifications@github.com wrote:

@brian-brazil https://github.com/brian-brazil I am probably doing it
wrong, but it doesn't make any difference.
Without any rules

Query:

max_over_time(rate(cadvisor_container_cpu_user_seconds_total{marathon_app_id=~"/foo/.+"}[5m]))

Gives:

Error executing query: parse error at char 95: expected type matrix in call to function "max_over_time", got vector

With rule

Used rule:

cadvisor:cpu_user:rate = rate(cadvisor_container_cpu_user_seconds_total{marathon_app_id=~".+"}[3m])

Query with that rule:

max_over_time(cadvisor:cpu_user:rate{marathon_app_id=~"/foo/.+"})

Gives:

Error executing query: parse error at char 66: expected type matrix in call to function "max_over_time", got vector

Even if it should only work with the rule, I think it's worth mentioning
that in docs with explanation. It doesn't seem obvious, at least for me.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#2129 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEJbsKPLybuzYdQo1tXPOzCsKpIoWVAnks5q5OmwgaJpZM4KihJH
.

@bobrik

This comment has been minimized.

Copy link
Author

bobrik commented Oct 31, 2016

@mattbostock that did the trick.

@donghwicha

This comment has been minimized.

Copy link

donghwicha commented Mar 3, 2018

Is this still valid? I tried but it fails to gather values
(returns empty values list)

max_over_time(cadvisor:cpu_user:rate{my_cont_id=~"/foo/.+"})

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 22, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 22, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.