graphite-dev team mailing list archive
-
graphite-dev team
-
Mailing list archive
-
Message #00071
Re: [Question #80372]: Applying math functions to targets
Question #80372 on Graphite changed:
https://answers.launchpad.net/graphite/+question/80372
Status: Open => Answered
chrismd proposed the following answer:
Yes you can do this with the offset() function (grab the latest trunk
code).
For (100 - instance.cpu_idle) / 100 you would do something like this:
target=scale(offset(scale(instance.cpu_idle,-1),100),0.01)
The result would be a series whose values range from 0.0 to 1.0
indicating the percentage of non-idle cpu.
As for multiplying two series there is not currently a function
implemented that supports this but it would be pretty easy to do. Look
in $GRAPHITE_ROOT/webapp/web/render/functions.py if your are interested.
One thing I would note about your example of calculating capacity. This
would only be accurate if there is a linear relationship between cpu use
and requests per second (which may not be possible to assert if you have
more than one instance per machine & uneven load balancing, or multi-
core machines & a threaded application, etc...). Then again, it may turn
out that it works fine in practice. Plus it might still be a useful
metric even if it does not exactly represent remaining capacity in
requests per second. It is definitely an interesting idea.
--
You received this question notification because you are a member of
graphite-dev, which is an answer contact for Graphite.