hubot-grafana 0 editorconfig travis-ci grunt npm

Query Grafana dashboards.

Grafana for Hubot

npm version Build Status Coverage Status


Use Hubot to query Grafana dashboards. Inspired by the work of hubot-graphite and hubot-graphme. Check out the HOWTO to get started with the bot.

Note: This package requires Grafana 2.x or higher.


In the Hubot project repo, run:

npm install hubot-grafana --save

Then add hubot-grafana to your external-scripts.json:


Configuration Variables

General Settings

Configuration Variable Required Description
HUBOT_GRAFANA_HOST Yes Host for your Grafana 2.x install, e.g.
HUBOT_GRAFANA_API_KEY Yes^ Grafana API key (This can be “Viewer” role.)
HUBOT_GRAFANA_QUERY_TIME_RANGE No Default time range for queries (defaults to 6h)

^ Not required for auth.anonymous Grafana configurations. All other authentication models will require a user-specific API key.

Amazon S3 Image Hosting

Recommended if you use a service such as Slack or HipChat. You can omit all of these settings if you do not plan to use S3.

Graphs are downloaded to the box running hubot-grafana and then uploaded to S3 with world-readable rights, so you do not have to do anything special to your S3 bucket in order to serve the graph images suitable for Slack or HipChat. E.g., you do not have to set up web hosting for your S3 bucket.

Configuration Variable Required Description
HUBOT_GRAFANA_S3_BUCKET Yes Name of the S3 bucket to copy the graph into
HUBOT_GRAFANA_S3_SECRET_ACCESS_KEY Yes Secret access key for S3
HUBOT_GRAFANA_S3_PREFIX No Bucket prefix (useful for shared buckets)
HUBOT_GRAFANA_S3_REGION No Bucket region (defaults to us-standard)
HUBOT_GRAFANA_S3_ENDPOINT No Endpoint of the S3 API (useful for S3 compatible API, defaults to
HUBOT_GRAFANA_S3_PORT No Port of the S3 endpoint
HUBOT_GRAFANA_S3_STYLE No Bucket style of the S3 endpoint ‘virtualHosted’ or ‘path’ defaults to ‘virtualHosted’

You most likely want to add an S3 Life Cycle Configuration that will “Permanently Delete” the graphs after 1 hour or 1 day, as appropriate for your organization.

Hosting hubot-grafana within AWS.

EC2 IAM Roles will not be used. In order for your hubot-grafana to be allowed to store graphs in S3 that can be referenced via Slack or HipChat, the IAM user with the credentials you run hubot-grafana as should have an IAM user policy such as:

    "Version": "2012-10-17",
    "Statement": [
            "Effect": "Allow",
            "Action": [
            "Resource": [
            "Effect": "Allow",
            "Action": [
            "Resource": [

Example Configuration

export HUBOT_GRAFANA_API_KEY=abcd01234deadbeef01234
export HUBOT_GRAFANA_S3_BUCKET=mybucket

Sample Interaction

user1>> hubot graf db graphite-carbon-metrics
hubot>> Graphite Carbon Metrics: -

Grafana Commands

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

Templated Dashboards

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 carbon-a

hubot graf db graphite-carbon-metrics host=carbon-a

Utility Commands

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 production.

hubot graf list production

Similarly, you can search the list of dashboards. In this example, return all dashboards that contain the word elb.

hubot graf search elb

Top Contributors

stephenyeargin Tenzer klynch zyegfryed lanyonm neilcronin


package version
knox ^0.9.2
request ^2.58.0
dev blanket ^1.2.1
chai ^2.1.1
coffee-script 1.10.0
coveralls ^2.11.6
grunt ^0.4.5
grunt-cli ^0.1.13
grunt-contrib-watch ~0.6.1
grunt-mocha-test ~0.12.7
grunt-release ~0.11.0
hubot 2.x
hubot-test-helper 0.0.6
husky ^0.13.3
matchdep ~0.3.0
mocha ^2.1.0
mocha-lcov-reporter ^1.0.0
nock ^2.3.0
require-dir ^0.3.0
sinon ^1.13.0
sinon-chai ^2.7.0
travis-cov ^0.2.5
peer hubot 2.x


-   v1.4.9 zip tar
-   v1.4.8 zip tar
-   v1.4.7 zip tar
-   v1.4.6 zip tar
-   v1.4.5 zip tar
-   v1.4.4 zip tar
-   v1.4.3 zip tar
-   v1.4.2 zip tar
-   v1.4.1 zip tar
-   v1.4.0 zip tar
-   v1.3.2 zip tar
-   v1.3.1 zip tar
-   v1.3.0 zip tar
-   v1.2.0 zip tar
-   v1.0.0 zip tar
-   v0.0.1 zip tar