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

Threshold line #35

Closed
cscmvi opened this issue Jul 22, 2013 · 13 comments
Closed

Threshold line #35

cscmvi opened this issue Jul 22, 2013 · 13 comments

Comments

@cscmvi
Copy link

cscmvi commented Jul 22, 2013

Hello,

How can one draw a threshold line in giraffe?

Best regards,

Marko

@aeirola
Copy link

aeirola commented Jul 22, 2013

Do you mean a constant horizontal line? In that case, you can generate those in Graphite. So adding a metric like this in your dashboard.js file should work:

      {
        "alias": "Treshold",
        "target": "constantLine(100)",
        "renderer": "line"
      }

For more information on functions available in Graphite, check out http://graphite.readthedocs.org/en/latest/functions.html#graphite.render.functions.constantLine

@cscmvi
Copy link
Author

cscmvi commented Jul 23, 2013

Yes, a constant horizontal line across the graph. I tried your example and it works for a single target but not when there is multiple targets in metric. With multiple targets, the threshold is a bar in the middle of the graph which gets expanded in width as the graph gets refreshed (5secs). This happens when viewing the graph with the latest 10min period view.

@gingerlime
Copy link

I'm not sure I understand what you're trying to achieve, but you could perhaps try setting multiple targets with a constantLine, and you can also pass a javascript function to the target. This can allow you to calculate the value for the threshold somehow, but this is something that you'd have to take care of by yourself probably in dashboards.js.

@cscmvi
Copy link
Author

cscmvi commented Jul 24, 2013

I need to clarify my issue better.. Here is my definition and in the graph sample below the threshold line is not drawn constant as it should. Also the actual metric (logintime) is affected a bit by the threshold line.
{
"alias": "login time",
"target": [{
target: 'alias(constantLine(6000), "Threshold")',
alias: 'Threshold',
color: 'brown'
},{
target: "clients.acer.OpenERP.login",
color: "green"}],
"description": "Login time into OpenERP (ms)",
"summary": "last",
"summary_formatter": d3.format(",f"),
"renderer": "line",
"unstack": true,
"colspan": 2
}

screenshot from 2013-07-24 08 55 31

@gingerlime
Copy link

Ok, now things are a little clearer. One thing I noticed however is that constantLine doesn't seem to return a json response (on my graphite anyway). /render?from=-1440minutes&target=constantLine(4000)&format=json produced an error, whereas without the format=json it worked fine.

So it looks like maybe it's only used when graphite is rendering a graph by itself. If that's the case, and there's no way to tell graphite to simply return a an array of constant values via json, then this is something that could potentially be implemented inside Giraffe, but a) I'm not sure how much time I have right now for this; and b) I'd rather deal as little as possible with rendering or mocking data, and perhaps it makes sense to submit a pull request to the graphite project to support returning constantLine via json.

@aeirola - any thoughts?

@cscmvi
Copy link
Author

cscmvi commented Jul 24, 2013

/render?from=-1440minutes&target=constantLine(4000)&format=json on my graphite gives:
[{"target": "4000", "datapoints": [[4000, 1374563380], [4000, 1374606580]]}]

@gingerlime
Copy link

which version of graphite are you using?

On 24 July 2013 09:12, cscmvi notifications@github.com wrote:

/render?from=-1440minutes&target=constantLine(4000)&format=json on my
graphite gives:
[{"target": "4000", "datapoints": [[4000, 1374563380], [4000,
1374606580]]}]


Reply to this email directly or view it on GitHubhttps://github.com//issues/35#issuecomment-21467550
.

@cscmvi
Copy link
Author

cscmvi commented Jul 24, 2013

Installed Packages
Name : graphite-web
Arch : noarch
Version : 0.9.10

more /etc/redhat-release
CentOS release 5.9 (Final)

@gingerlime
Copy link

maybe it's a local problem on my own graphite then. I'll try to take a
look, but not sure exactly when unfortunately...

On 24 July 2013 10:01, cscmvi notifications@github.com wrote:

Installed Packages
Name : graphite-web
Arch : noarch
Version : 0.9.10

more /etc/redhat-release
CentOS release 5.9 (Final)


Reply to this email directly or view it on GitHubhttps://github.com//issues/35#issuecomment-21469314
.

@aeirola
Copy link

aeirola commented Jul 24, 2013

Yeah, apparently it doesn't work as nicely as I originally though. I just tested the function it quickly by drawing an image with the render API. Apologies for the false hope.

I have the same issue with getting an internal server error when trying to render a constantLine using JSON formatting. Rendering images or CSV works fine. I'll put up an issue on the graphite-web project for this, as there doesn't seem to be one yet.

The quick fix for your situation would be to hack together a constant value from a existing metric. So for example something like this will give you a (ugly) constant line alias(transformNull(removeAboveValue(carbon.agents.*.cpuUsage,-1),10),'Treshold')

For Giraffe, I think it would be best to rely on Graphite for all data sources. So we should work to fix the issue in Graphite and then just use the constantLine or threshold functions found there.

@aeirola
Copy link

aeirola commented Jul 24, 2013

The graphite-web issue can be found at graphite-project/graphite-web#375

@cscmvi
Copy link
Author

cscmvi commented Jul 25, 2013

The quick fix seems OK for now until the right solution arrives. I was also thinking to feed a threshold value into carbon from my metrics collector. The benefit would be to see the change history of the threshold itself(?). Also it would be easier to get alerts working if the metric threshold could be read from graphite together with the actual metric.

Thanks for your time guys and for helping me out with this so quickly.

@gingerlime
Copy link

Very clever @aeirola ! I would never have thought about this. And happy to hear it's working for you @cscmvi. Yeah, it's not an ideal solution, but hopefully graphite will fix this at some point and that would be useful also for other dashboard/projects perhaps. Hope it's ok to close this for now, but feel free to re-open or open another issue if you need more help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants