Grafana for Hubot
Note: This package requires Grafana 2.0.2 or higher.
In the Hubot project repo, run:
npm install hubot-grafana --save
Then add hubot-grafana to your
[ "hubot-grafana" ]
||Yes||Host for your Grafana 2.x install, e.g.
||Yes^||Grafana API key (This can be "Viewer" role.)|
||No||Default time range for queries (defaults to 6h)|
||No||Default width for rendered images (defaults to 1000)|
||No||Default height for rendered images (defaults to 500)|
|^ Not required for
Image Hosting Configuration
By default, hubot-grafana will assume you intend to render the image, unauthenticated, directly from your Grafana instance. The limitation is that you will only receive a link to those images, but they won't appear as images in most circumstances in your chat client.
You can use one of the following strategies to host the generated images from Grafana.
export HUBOT_GRAFANA_HOST=http://play.grafana.org export HUBOT_GRAFANA_API_KEY=abcd01234deadbeef01234 export HUBOT_GRAFANA_QUERY_TIME_RANGE=1h export HUBOT_GRAFANA_S3_BUCKET=mybucket export HUBOT_GRAFANA_S3_ACCESS_KEY_ID=ABCDEF123456XYZ export HUBOT_GRAFANA_S3_SECRET_ACCESS_KEY=aBcD01234dEaDbEef01234 export HUBOT_GRAFANA_S3_PREFIX=graphs
user1>> hubot graf db graphite-carbon-metrics hubot>> Graphite Carbon Metrics: http://play.grafana.org/render/dashboard/solo/graphite-carbon-metrics/?panelId=1&width=1000&height=500&from=now-6h - http://play.grafana.org/dashboard/db/graphite-carbon-metrics/?panelId=1&fullscreen&from=now-6h
Retrieve a Dashboard
Get all panels in a dashboard. In this example,
graphite-carbon-metrics is the slug for the given dashboard.
hubot graf db graphite-carbon-metrics
Retrieve Specific Panels
Get a single panel of a dashboard. In this example, only the third panel would be returned. Note that this is the visual panel ID, counted from top to bottom, left to right, rather than the unique identifier stored with the panel itself.
hubot graf db graphite-carbon-metrics:3
If you want to refer to the API Panel ID, use the
:panel-<identifier> format to retrieve it. These will not change when the dashboard is re-arranged.
hubot graf db graphite-carbon-metrics:panel-8
Get all panels matching a particular title (case insensitive) in a dashboard. In this case, only panels containing
cpu would be returned.
hubot graf db graphite-carbon-metrics:cpu
Retrieve Dashboards in a Time Window
Specify a time range for the dashboard. In this example, the dashboard would be set to display data from 12 hours ago to now.
hubot graf db graphite-carbon-metrics now-12hr
If you don't want to show the dashboard uptil now, you can add an extra time specification, which will be the
to time slot. In this example, the dashboard would be set to display data from 24 hours ago to 12 hours ago.
hubot graf db graphite-carbon-metrics now-24hr now-12hr
You can combine multiple commands in this format as well. In this example, retrieve only the third panel of the
graphite-carbon-metrics dashboard with a window of eight days ago to yesterday.
hubot graf db graphite-carbon-metrics:3 now-8d now-1d
Grafana allows dashboards to be set up as templates and accept arguments to generate them through the API. In this example, we get a templated dashboard with the
$host parameter set to
hubot graf db graphite-carbon-metrics host=carbon-a
This command retrieves all dashboards and their slugs so they can be used in other commands.
hubot graf list
Dashboards can be tagged for easier reference. In this example, return all dashboards tagged with
hubot graf list production
Similarly, you can search the list of dashboards. In this example, return all dashboards that contain the word
hubot graf search elb