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

offset not honored with recording rules #1234

Closed
xbglowx opened this Issue Nov 23, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@xbglowx
Copy link

xbglowx commented Nov 23, 2015

I have the following recording rules

node_cpu_usage_user_prometheus = ((sum(node_cpu{tags=~',prometheus,',mode='user'}) - sum(node_cpu{tags=~',prometheus,',mode='user'} offset 15s)) / 150) * 100 node_cpu_usage_nice_prometheus = ((sum(node_cpu{tags=~',prometheus,',mode='nice'}) - sum(node_cpu{tags=~',prometheus,',mode='nice'} offset 15s)) / 150) * 100 node_cpu_usage_iowait_prometheus = ((sum(node_cpu{tags=~',prometheus,',mode='iowait'}) - sum(node_cpu{tags=~',prometheus,',mode='iowait'} offset 15s)) / 150) * 100 node_cpu_usage_idle_prometheus = ((sum(node_cpu{tags=~',prometheus,',mode='idle'}) - sum(node_cpu{tags=~',prometheus,',mode='idle'} offset 15s)) / 150) * 100 node_cpu_usage_softirq_prometheus = ((sum(node_cpu{tags=~',prometheus,',mode='softirq'}) - sum(node_cpu{tags=~',prometheus,',mode='softirq'} offset 15s)) / 150) * 100 node_cpu_usage_system_prometheus = ((sum(node_cpu{tags=~',prometheus,',mode='system'}) - sum(node_cpu{tags=~',prometheus,',mode='system'} offset 15s)) / 150) * 100 node_cpu_usage_irq_prometheus = ((sum(node_cpu{tags=~',prometheus,',mode='irq'}) - sum(node_cpu{tags=~',prometheus,',mode='irq'} offset 15s)) / 150) * 100 node_cpu_usage_guest_prometheus = ((sum(node_cpu{tags=~',prometheus,',mode='guest'}) - sum(node_cpu{tags=~',prometheus,',mode='quest'} offset 15s)) / 150) * 100 node_cpu_usage_steal_prometheus = ((sum(node_cpu{tags=~',prometheus,',mode='steal'}) - sum(node_cpu{tags=~',prometheus,',mode='steal'} offset 15s)) / 150) * 100

A Prometheus reload works fine, but the status doesn't show 'offset 15s'. So the end recording rule ends up being:

node_cpu_usage_user_prometheus = ((sum(node_cpu{mode="user",tags=~",prometheus,"}) - sum(node_cpu{mode="user",tags=~",prometheus,"})) / 150) * 100 node_cpu_usage_nice_prometheus = ((sum(node_cpu{mode="nice",tags=~",prometheus,"}) - sum(node_cpu{mode="nice",tags=~",prometheus,"})) / 150) * 100 node_cpu_usage_iowait_prometheus = ((sum(node_cpu{mode="iowait",tags=~",prometheus,"}) - sum(node_cpu{mode="iowait",tags=~",prometheus,"})) / 150) * 100 node_cpu_usage_idle_prometheus = ((sum(node_cpu{mode="idle",tags=~",prometheus,"}) - sum(node_cpu{mode="idle",tags=~",prometheus,"})) / 150) * 100 node_cpu_usage_softirq_prometheus = ((sum(node_cpu{mode="softirq",tags=~",prometheus,"}) - sum(node_cpu{mode="softirq",tags=~",prometheus,"})) / 150) * 100 node_cpu_usage_system_prometheus = ((sum(node_cpu{mode="system",tags=~",prometheus,"}) - sum(node_cpu{mode="system",tags=~",prometheus,"})) / 150) * 100 node_cpu_usage_irq_prometheus = ((sum(node_cpu{mode="irq",tags=~",prometheus,"}) - sum(node_cpu{mode="irq",tags=~",prometheus,"})) / 150) * 100 node_cpu_usage_guest_prometheus = ((sum(node_cpu{mode="guest",tags=~",prometheus,"}) - sum(node_cpu{mode="quest",tags=~",prometheus,"})) / 150) * 100 node_cpu_usage_steal_prometheus = ((sum(node_cpu{mode="steal",tags=~",prometheus,"}) - sum(node_cpu{mode="steal",tags=~",prometheus,"})) / 150) * 100

I am running prometheus version 0.15.1

screen shot 2015-11-23 at 11 48 28 am

screen shot 2015-11-23 at 11 50 52 am

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Nov 23, 2015

Dupe of #1223

You should be using the rate() function rather than trying to handle counters yourself.

@xbglowx

This comment has been minimized.

Copy link
Author

xbglowx commented Nov 24, 2015

@brian-brazil thanks for the tip and the quick update.

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 24, 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 24, 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.