ripienaar / gdash

A dashboard for Graphite
http://www.devco.net/
Apache License 2.0
754 stars 117 forks source link

Export json for all templates that contains warning or critical #119

Closed simonjohansson closed 10 years ago

simonjohansson commented 10 years ago

Given a template like

title "Beanstalkd default Tube Reserved Jobs in #{environment}"
timezone "Europe/London"
vtitle "count"
linewidth 2
linemode "connected"
description "Beanstalkd default tube stats for #{environment}"
ymin 0

servers = @properties[:servers]
environment = @properties[:environment]

warning :value => 1000
critical :value => 2000

field "current_jobs_reserved".to_sym,
        :alias => "Current Jobs Reserved",
        :data => "servers.#{servers[0]}.beanstalkd.counter-default-current-jobs-reserved.value"

The new endpoint returns a list of dicts like so

[ { "critical" : [ 2000 ],
    "graph_properties" : { "app_environment" : "qa1",
        "area" : "none",
        "area_alpha" : null,
        "background_color" : "black",
        "description" : "Beanstalkd default tube buried jobs for ",
        "draw_null_as_zero" : false,
        "environment" : "qa1",
        "fontbold" : false,
        "fontname" : null,
        "fontsize" : null,
        "foreground_color" : "white",
        "from" : "-1hour",
        "height" : 250,
        "hide_grid" : null,
        "hide_legend" : false,
        "javaid" : "beanstalkd",
        "linemode" : "connected",
        "linewidth" : 2,
        "logbase" : null,
        "major_grid_line_color" : null,
        "minor_grid_line_color" : null,
        "placeholders" : null,
        "servers" : [ "server" ],
        "surpress" : false,
        "timezone" : "Europe/London",
        "title" : "Beanstalkd default Tube buried jobs in ",
        "until" : "now",
        "vertical_mark_color" : "#330000",
        "virtual_server_identifier" : "vs-core_qa1_springer_com_80",
        "vtitle" : "count",
        "vtitle_right" : null,
        "width" : 500,
        "xformat" : null,
        "ymax" : null,
        "ymaxright" : null,
        "ymin" : 0,
        "yminright" : null,
        "yunit_system" : null
      },
    "graphite_url" : "http://graphite-url.com/render/?title=Beanstalkd+default+Tube+buried+jobs+in+&vtitle=count&from=-1hour&width=500&height=250&until=now&areaMode=none&hideLegend=false&yMin=0&lineWidth=2&lineMode=connected&tz=Europe%2FLondon&bgcolor=black&fgcolor=white&target=alias%28dashed%28color%28threshold%281000%29%2C%22orange%22%29%29%2C%22warn_0%22%29&target=alias%28dashed%28color%28threshold%282000%29%2C%22red%22%29%29%2C%22crit_0%22%29&target=alias%server.beanstalkd.counter-default-current-jobs-buried.value%2C%22Current+Jobs+Buried%22%29",
    "warning" : [ 1000 ]
  }, .....]

Useful for generating nagios checks(for example) for all graphs that contains warning/critical

ripienaar commented 10 years ago

thanks