|
| 1 | += Hawkular Datasource for Grafana |
| 2 | +:source-language: javascript |
| 3 | + |
| 4 | +This project is the Hawkular Datasource plugin for Grafana 3. It works with: |
| 5 | + |
| 6 | +* Metrics standalone servers as well |
| 7 | +* Hawkular servers, starting from version Alpha13 |
| 8 | +
|
| 9 | +== Installing |
| 10 | + |
| 11 | +=== From source |
| 12 | + |
| 13 | +Download the source code and copy the content of `dist` to `hawkular` inside Grafana's plugin directory. |
| 14 | + |
| 15 | +[source,bash] |
| 16 | +---- |
| 17 | +# This is the default for Linux Grafana installs. Change it to match yours, if needed. |
| 18 | +GRAFANA_PLUGINS=/var/lib/grafana/plugins |
| 19 | +wget https://github.com/hawkular/hawkular-grafana-datasource/archive/master.zip -O hawkular-grafana-datasource-master.zip |
| 20 | +unzip hawkular-grafana-datasource-master.zip |
| 21 | +mkdir ${GRAFANA_PLUGINS}/hawkular |
| 22 | +cp -R hawkular-grafana-datasource-master/dist/* ${GRAFANA_PLUGINS}/hawkular |
| 23 | +---- |
| 24 | + |
| 25 | +=== From the Grafana plugin directory |
| 26 | + |
| 27 | +COMING SOON |
| 28 | + |
| 29 | +== Configuration |
| 30 | + |
| 31 | +The datasource URL must point to the Hawkular Metrics service, e.g. `http://myhost:8080/hawkular/metrics` |
| 32 | + |
| 33 | +`direct` access mode only works with standalone Metrics servers currently. If you active it, make sure to allow |
| 34 | +the Grafana server origin in Metrics' configuration. |
| 35 | + |
| 36 | +Authentication must be set when working with a Hawkular server. Check the 'Basic Auth' box and fill the user and password fields. |
| 37 | + |
| 38 | +Select the tenant. On Hawkular servers, use `hawkular`. |
| 39 | + |
| 40 | +Openshift-Metrics users must provide an authentication token. |
| 41 | + |
| 42 | +== Using Grafana Templating (variables) |
| 43 | + |
| 44 | +Grafana allows you to create dashboard templates through the definition of variables. This is link:http://docs.grafana.org/reference/templating/[documented on Grafana's site]. |
| 45 | +With the Hawkular Datasource Plugin, the variables of type _'Query'_ are mapped to the http://www.hawkular.org/docs/rest/rest-metrics.html#GET__metrics[_@get (url)/metrics_] |
| 46 | +Hawkular Metrics endpoint and can be used to retrieve tenant's metric names. Use the _Query Options_ text field to pass query parameters. |
| 47 | +[TIP] |
| 48 | +For instance, if you have metrics tagged _"type:memory"_ and others tagged _"type:cpu"_, you can write _"?tags=type:memory"_ to get only the _"memory"_ ones, or _"?tags=type:cpu|memory"_ to get them both. The leading question mark is not mandatory. |
| 49 | + |
| 50 | +There is an exception to that rule: if the query string is prefixed with _'tags/'_, the variable will contain the matching tag names rather than the metric names. In this case, the Hawkular Metrics endpoint link:++http://www.hawkular.org/docs/rest/rest-metrics.html#GET__metrics_tags__tags_++[_@get (url)/metrics/tags/{tags}_] will be used. |
| 51 | +[TIP] |
| 52 | +For instance, type _"tags/type:*"_ to get all of the available tag values for _"type"_. |
| 53 | + |
| 54 | +Once you have set some variables, you can use them in graph queries: either for row or graph duplication, or to display multiple series in a single graph from a single query. This is especially useful when metric names contain some dynamic parts and thus cannot be known in advance. |
| 55 | + |
| 56 | +== Building |
| 57 | + |
| 58 | +You need `npm` and `grunt` to build the project. Clone this repository, then from that directory run: |
| 59 | + |
| 60 | +[source,bash] |
| 61 | +---- |
| 62 | +npm install |
| 63 | +grunt |
| 64 | +---- |
| 65 | + |
| 66 | +Files are generated under the `dist` directory. |
| 67 | + |
| 68 | +To test it, copy these files to `${GRAFANA_PLUGINS}/hawkular` and restart grafana-server. |
| 69 | + |
| 70 | +== Building and running a Docker image |
| 71 | + |
| 72 | +[source,bash] |
| 73 | +---- |
| 74 | +# This will build the image |
| 75 | +docker build -t hawkular/hawkular-grafana-datasource . |
| 76 | +# This will run the image on http://localhost:3000/ |
| 77 | +docker run -i -p 3000:3000 --name hawkular-grafana-datasource --rm hawkular/hawkular-grafana-datasource |
| 78 | +---- |
0 commit comments