Giter Site home page Giter Site logo

grafana-influx-dashboard's Introduction

Grafana InfluxDB scripted dashboard

Javascript dashboard auto-generation script to mimic comfortable Munin behaviour in Grafana. Main project goal is to be able to see all the stats for the added machine in one dashboard (to have possibility to add auto-generated URL to the existing monitoring system alarm notification for faster incident investigation). Project is written and tested with CollectD->InfluxDB+(input_plugins.collectd) as a system stats collector but with minor configuration changes should be collector independent.

✅ Tested for Grafana 2.6.0 and InfluxDB v0.8.8
✅ Tested for Grafana 2.6.0 and InfluxDB v0.11.1
✅ Tested for Grafana 3.1.1 and InfluxDB v1.0.2
✅ Tested for Grafana 4.1.2 and InfluxDB v1.2.0

Demonstration

Installation

There is a bash installation script included. Substitute GRAFANA_ROOT_DIR with a path to your Grafana installation (e.g. /usr/share/grafana).

# for grafana 2.6.0 and influxdb v0.8
git clone -b influxdb_v0.8 --depth=1 https://github.com/anryko/grafana-influx-dashboard.git

# for grafana 2.6.0 and influxdb >= v0.9
git clone -b grafana2.6_influxdb0.11 --depth=1 https://github.com/anryko/grafana-influx-dashboard.git

# for grafana 3.1 and influxdb >= v0.9
git clone -b grafana3.1_influxdb1.0 --depth=1 https://github.com/anryko/grafana-influx-dashboard.git

# for grafana >= 4.0 and influxdb >= v0.9
git clone --depth=1 https://github.com/anryko/grafana-influx-dashboard.git

cd grafana-influx-dashboard
sudo ./install.sh GRAFANA_ROOT_DIR

README is branch-specific. Please refer to the correct README when cloning branches.

Usage examples

http://grafanaIP/dashboard/script/getdash.js
http://grafanaIP/dashboard/script/getdash.js?host=hostname
http://grafanaIP/dashboard/script/getdash.js?host=hostname&metric=cpu,load
http://grafanaIP/dashboard/script/getdash.js?host=hostname&metric=load,database
http://grafanaIP/dashboard/script/getdash.js?host=hostname&metric=load&time=7d
http://grafanaIP/dashboard/script/getdash.js?host=hostname&metric=disk&time=12h&span=6
http://grafanaIP/dashboard/script/getdash.js?metric=redis&span=4&legend=false
http://grafanaIP/dashboard/script/getdash.js?host=hostname0*&span=6&legend=false
http://grafanaIP/dashboard/script/getdash.js?host=hostname64,hostname01&span=6
http://grafanaIP/dashboard/script/getdash.js?host=hostname(01|64)&span=6
http://grafanaIP/dashboard/script/getdash.js?host=hostname&metric=disk&instance=sda1
http://grafanaIP/dashboard/script/getdash.js?host=hostname&metric=disk&instance=sd*
http://grafanaIP/dashboard/script/getdash.js?host=hostname&metric=disk&instance=sda1,sdb1
http://grafanaIP/dashboard/script/getdash.js?host=hostname&metric=disk&instance=sda[1-3]
http://grafanaIP/dashboard/script/getdash.js?host=hostname&refresh=5s
http://grafanaIP/dashboard/script/getdash.js?host=hostname&metric=disk&instance=sda1&refresh=1m
http://grafanaIP/dashboard/script/getdash.js?metric=docker&time=30m&legend=alignAsTable,rightSide

Features

Supported metrics

Supported metric groups

  • system
  • middleware
  • database

Supported time format

For time :

/(\d+)(m|h|d)/

For refresh :

/(\d+)(s|m|h|d)/

Grouping by time is automatically adjusted.

Configuration HOWTO

This HOWTO will guide you through initial script configuration and example of adding additional plugins/metrics.

Initial getdash.js script configuration

Grafana datasource configuration is used for InfluxDB backend requests.

When you are using CollectD metric collector no configuration is required and preconfigured plugins will work out of the box. Otherwise, some additional getdash.js setup is needed and you will have to configure your plugins from scratch. First, for hosts discovery defaultQueries should be set to InfluxDB measurement name shared among all the hosts. If there is no one such measurement, list can be supplied. Second, defaultHostTags should be set to the InsluxDB tag containing hostname value. If it works you should be able to see hosts list on http://grafanaIP/dashboard/script/getdash.js. If this is the case, you can start developing your custom plugins in getdash.conf.js Start with setting-up pluginConfProto.tags to meet your setup. Multi-collector setup is also possible. In that case plugins.<name>.config.tags.<tag> can be set per plugin.

New plugin configuration

Lets assume you have some metric in your InfluxDB and you want it to be displayed. Before starting plugin configuration you will need hostname, series and type. For this demonstration I will use <hostname>, disk_read/disk_write and disk_ops accordingly. If you are not sure about series you can list all host series by querying your InfluxDB:

curl -sG 'http://<influxIP>:8086/query?pretty=true' --data-urlencode "db=collectd" --data-urlencode "q=SHOW SERIES WHERE host = '<hostname>';" | grep "\"name\":"
                    "name": "cpu_value",
                    "name": "df_value",
                    "name": "disk_read",
                    "name": "disk_write",
                    ...

And get other available parameters:

curl -sG 'http://<influxIP>:8086/query?pretty=true' --data-urlencode "db=collectd" --data-urlencode "q=SHOW SERIES FROM /disk_.*/ WHERE host = '<hostname>';" | grep "host="
                            "disk_read,host=<hostname>,instance=sda,type=disk_merged",
                            "disk_read,host=<hostname>,instance=sda,type=disk_octets",
                            "disk_read,host=<hostname>,instance=sda,type=disk_ops",
                            ...

To configure plugin for selected metrics you need to add following configuration to your getdash.conf.js.

// collectd disk plugin configuration
plugins.disk = new Plugin();
plugins.disk.config.multi = true;
plugins.disk.config.regexp = /\d$/;

plugins.disk.diskOps = {
  'graph': {
    'read': {
      'color': '#447EBC',
      'apply': 'derivative',
      'type': 'disk_ops'
    },
    'write': {
      'color': '#508642',
      'math': '* -1',
      'apply': 'derivative',
      'type': 'disk_ops'
    }
  },
  'panel': {
    'title': 'Disk Operations for @metric',
    'grid': { 'max': null, 'min': null, 'leftMin': null }
  }
};

Applying 'derivative' will use derivative(mean(value), 1s) by default. However, more extensive derivative syntax is supported. Examples: derivative(10s), derivative(last), derivative(max, 1s), derivative(min(value), 10s).

OK. So let's go line by line and I'll explain what was done here. Firs you create new Plugin and the name of plugin have to match the beginning of the series for that plugin. In this case it have to be disk.

plugins.disk = new Plugin();

Next you define that this plugin have multiple metrics split in separate graphs. There are probably multiple disks/partitions on your system. In this example I have sda, sda1 and sda2.

plugins.disk.config.multi = true;

For something like memory, where you have just one metric per host you wouldn't need to setup that.

Because we actually want to see only sda1, sda2 on our graphs (sda and sda1 are identical in my case) we apply a regular expression to match the metric. In this case I want to see only metrics with digit at the end.

plugins.disk.config.regexp = /\d$/;

Next we configure "Disk IO" graph itself. We want to see disk_read and disk_write for type=disk_ops.

Now lets describe this in the graph configuration. graph defines that we are configuring a graph :). read and write objects describe the series we want to graph. Those should match begining/ending of the series name or type_instance. Inside those graph configurations we define type to distinguish particular type of disk_read/write series we want to graph. Then we add color we want and InfluxDB function on the stored value with the apply keyword.

plugins.disk.diskOps = {
  'graph': {
    'read': {
      'color': '#447EBC',
      'apply': 'derivative',
      'type': 'disk_ops'
    },
    'write': {
      'color': '#508642',
      'math': '* -1',
      'apply': 'derivative',
      'type': 'disk_ops'
    }
  },

Supported configuration keys are:

  • color - if not defined color will be random
  • alias - used to change metric name on the graph
  • column - used to define requested column
  • math - used to define mathematical expression which will be applied to the column value
  • apply - used to apply InfluxDB SQL value function (e.g. max, min, count, etc.)
  • type - used in case when you have multiple graphs per series

Next we define Panel title and grid.

  'panel': {
    'title': 'Disk Operations for @metric',
    'grid': { 'max': null, 'min': null, 'leftMin': null },
  },
};

@metric is a special keyword which will be substituted with sda1 and sda2 dynamically.

This should be sufficient introduction to start adding your own metrics as needed. It was one of the most feature reach examples. Usually configuration is much more straightforward. Like this config for memcached.

// collectd memcached plugin configuration
plugins.memcache = new Plugin();

plugins.memcache.hits = {
  'graph': {
    'hitratio': { }
  },
  'panel': {
    'title': 'Memcached Hitratio',
    'y_formats': [ 'percent' ]
  }
};

// collectd nfs plugin configuration
plugins.nfs = new Plugin({ 'alias': 'nfs' });

plugins.nfs.nfs = {
  'graph': {
    '/.*/': { 'apply': 'derivative' }
  },
  'panel': {
    'title': 'NFS for @metric',
    'y_formats': [ 'pps' ]
  }
};

You can also describe metric using JS regular expressions syntax as it is done in the nfs plugin example above.

If you understand your data and how it is structured inside database you should be able to describe it as a plugin configuration with current feature set. If you are having any troubles with that feel free to register an Issue and I'll try to help.

Notes

Fetching server side generated graph images

http://grafanaIP/render/dashboard-solo/script/getdash.js?host=hostname&metric=cpu&panelId=1&time=6h

Adding getdash to grafana dashboard list

Issue #54

grafana-influx-dashboard's People

Contributors

alekseyp avatar anryko avatar einsiedlerkrebs avatar l13t avatar mengelmann avatar nordewal avatar oli-g avatar tkuehne-deliveryhero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grafana-influx-dashboard's Issues

[Request] Integrate the opportunity to search a host.

Hello anryko,

Is it possible to integrate in the script getDash, the ability to search a host ?

You tell me that ctrl + f works too;) but the host list when we want to have many hosts become heavier.

Thank you for your reply.

Cordially.

Missing db parameter when using proxy mode on graphite

If the connection to influxdb is using proxymode, I cannot get it to work.
query?q=SHOW TAG VALUES FROM load_midterm WITH KEY = host
I always get
"results": [ { "error": "database name required" } ] }
Back in response.

But If I change the datasource to use direct mode instead, it is working.

Plugins from the same group in the same row

It would be quite nice to have plugins from the same group in the same row - this way, by configuring the span in the configuration file, we could have several panels on the same row. You could still make the panels 12 wide, if needed.

Update method to have getdash show up on grafana main page

Previously there were instructions to modify grafana 2.x's app.js files:

sed -i 's|\({text:\"Dashboards\",icon:\"fa fa-fw fa-th-large\",href:a.getUrl(\"/\")}\)|\1,{text:\"GetDash\",icon:\"fa fa-fw fa-th-large\",href:a.getUrl(\"/dashboard/script/getdash.js\")}|' /usr/share/grafana/public/app/app.*js

This no longer works. Please provide a new method for integrating getdash with the main grafana 3.x page. Thanks!

Add console logging on failure

Hello! I am trying to get this to work, it is not working and I have very little idea how what could be wrong. It could be I've configured grafana to run in /grafana/ instead of the root of a website. It could be that I am running an incompatible version of Influxdb. When I don't pass any argument, it shows an empty list of hosts, although I do have data in influxdb. Some logging to figure out what is wrong would be most helpful!

Anyway thanks for this! It might turn up super useful when it works :)

What will be root dir?

Hi,

I have installed grafana 0.9, what will be my root dir?

i have got all content here -> /usr/share/grafana/public.

-Rohit

Missing query separator

I use your scripted dashboard in the following environment:

  • Debian 8
  • Collectd 5.5.1
  • Grafana 2.6.0
  • InfluxDB 0.12.1

Unfortunately I get several error messages about a missing query separator.
Error

As you can see the selects are just seperated by an space instead of ;.
Query

I use the default plugins of Collectd, but this should not matter. Do you have any idea what went wrong?

Some Grafana graphs has errros

Hello.

I installed your dashboard into Grafana 2.1.3, but some of the graphs are giving me this error:

InfluxDB Error Response: error parsing query: aggregate function required inside the call to derivate

You can see it on the attached screenshot:
grafana

I'm using grafana-2.1.3-1.x86_64, influxdb-0.9.4.1-1.x86_64, collectd-5.5.0-1.el6.x86_64.

I'm not sure if this is a dasboard bug or some problem of my collectd+influxdb configuration.

Thank you

PetrR

influxdb 0.8.8 + grafana 2.6.0

Due to functional constraint i need to keep influxdb 0.8.8 and getdash seems not working with grafana 2.6.0.

Could please fix it ?

regards,

Missing u= & p= parameter when using proxy mode on influxdb

Hello,

When my influxdb datasource is configured in proxy mode, getDash does not work because it fails to recuperate the parameter user and password.

db=collectd&u=undefined&p=undefined&q=SHOW%20TAG%20VALUES%20FROM%20load_midterm%20WITH%20KEY%20%3D%20host%3B

{"error":"user not found"}

If I get the right user and password in place of "undefined" or if I connect the direct datasource that works.

Grafana : 3.0.4
InfluxDB: 0.13
Master branch of grafana-influx-dashboard

Thank you.

Cordially.

Suggested retention/CQ scheme for rollups?

I would really like to take advantage of influxdb's retention policy and continuous queries to create rollups for grafana graphs. Does anyone have a suggested scheme to go along with the grafana-influx-dashboard model?

Links to other posts/issues would be good as well, but my google-fu is either not working well, or rollups are too new a feature to have been explored properly. Thanks.

Interface plugin graphs are incorrect

  • First, they are upside-down :)
  • Second, derivative function rate normalisation parameter is incorrect. According to influxdb docs it should be 1s by default:

DERIVATIVE() can have two arguments. The first is required and is a field name. The second is optional and is a rate normalization parameter. If the second parameter is not provided defaults to 1s.

In reality with v0.9.4.2 i see derivative(mean("value")) and derivative(mean("value"), 1s) show different results and the later one is actually correct.

Does this work with Graphite back end?

Project is written and tested with CollectD->InfluxDB+(input_plugins.collectd) as a system stats collector but with minor configuration changes should be collector independent.

Are you referring to collectd or InfluxDB as the collector? Running Graphite/Grafana and curious if this this work..

Add 'where' graph target configuration parameter

After migrating my infra from graphite metric format to straight collectd I noticed that some plugins put multiple metrics under the same series name. In this case I will need a 'where' sql keyword to get multiple graphs data per series.

CPU graph for more than 3 cpus will not be displayed

Grafana introduced metric rows limitation (grafana/grafana#2087) eq 26 (A-Z). So if you have 3 CPUs x 8 metric = 24 rows, you are fine. If you are unlucky to have more powerful machine your graph will not be displayed. I need to introduce plugin configuration metric grouping option to workaround this limitation.

[Request] Integrate multiple host selection.

Hello,

Is it possible to integrate into the script the ability to choose multiple server? To enable comparison servers. A similar method to the template grafana.

Thank you for your reply.

Cordially.

Change cpu plugin

Default CollectD CPU plugin graphing is complicated. Plugin stores information per thread which is not relevant to my use case and in case when I have 32 threads on the machine it takes quite a while to query 8x32 metrics. I want to have aggregated metrics in 'percent' ready to graph.

/api/datasources endpoint not accessible in 3.0.1 for non-Admin users

Hi anryko! 😃

After upgrading Grafana to 3.0.1 unfortunately the scripted dashboard doesn't load (gives blank page), when logged in without admin privileges.
That seems to be caused by the "/api/datasources" endpoint not being publicly accessible anymore. It returns:

{"message":"Permission denied"}

with such a user.

Are you aware of this? How could this be worked around?
Maybe providing an API key in getdash configuration would be an option?

Cheers,

Tobias.

Custom influx Port

I am missing something.

Where and how can I configure InfluxDB since is not on standard Influx port?

Thx

Two plugins for one measurement

Hi
I just started using this great grafana dashboard generator. I am wondering if there is a possibility to create two getdash plugins for the same collectd plugin, ie:

plugins.disk = new Plugin();
  //plugins.disk.config.multi = true;

  plugins.disk.diskOps = {
    'graph': {
      'read': {
//        'color': '#447EBC',
        'apply': 'derivative',
        'type': 'disk_ops'
      },
      'write': {
//        'color': '#508642',
        'math': '* -1',
        'apply': 'derivative',
        'type': 'disk_ops'
      }
    },
    'panel': {
      'title': 'Disk Operations', // for @metric',
      'grid': { 'max': null, 'min': null, 'leftMin': null },
      'y_formats': [ 'iops' ]
    }
  };

and

plugins.diskdetailed = new Plugin();
  plugins.diskdetailed.config.multi = true;

  plugins.diskdetailed.diskOps = {
    'graph': {
      'read': {
        'color': '#447EBC',
        'apply': 'derivative',
        'type': 'disk_ops'
      },
      'write': {
        'color': '#508642',
        'math': '* -1',
        'apply': 'derivative',
        'type': 'disk_ops'
      }
    },
    'panel': {
      'title': 'Disk Operations for @metric',
      'grid': { 'max': null, 'min': null, 'leftMin': null },
      'y_formats': [ 'iops' ]
    }
  };

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.