grafana/docs/sources/features/datasources/elasticsearch.md

138 lines
6.7 KiB
Markdown
Raw Normal View History

Squashed commit of the following: commit 4113ed00782590187d19dd2f8cbae683f164142c Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Fri Oct 21 10:47:35 2016 +0200 docs(): minor fix for docs index page commit 45478d120571519462fac905aadeab5954696690 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Thu Oct 20 14:28:21 2016 +0200 updated commit c9c1c1d5a462f85e8001a45218f24102583d7aee Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Thu Oct 20 14:27:34 2016 +0200 docs(): updated image refs commit 5fa0f27963968d77bbbbb7edd973847ea72135e3 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Wed Oct 19 14:33:04 2016 +0200 docs is almost done commit 6b988c90cb08563e2c27212338c2947e69f6fcc3 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 20:45:28 2016 +0200 almost done commit 17757c21ed813892ddb1f289f2e52613caf7bcef Author: Torkel Ödegaard <torkel@grafana.org> Date: Tue Oct 18 16:45:48 2016 +0200 making progress on docs commit f06c815991dd81b8893912a6da04a17b80b63fda Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 14:30:55 2016 +0200 progress on new docs commit 5197237426252623de2d8b9cc22ddbbdbb240763 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 13:25:26 2016 +0200 making progress commit 33e2b6b617f16f65878141cf11e54b2817a2ea96 Merge: de385e5 ecb4a99 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 12:17:58 2016 +0200 Merge branch 'new-docs' of github.com:grafana/grafana into new-docs commit ecb4a99dd54aa39f17d9bf4d7e132a389812f8fd Author: Torkel Ödegaard <torkel@grafana.org> Date: Tue Oct 18 10:39:59 2016 +0200 keep urls for now commit de385e56d86b071cf2150ccf9f1aa06ec5187277 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 17:56:18 2016 +0200 more progress commit 8469ebc239ab2316cbbc01862e5026737f272f00 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 17:08:06 2016 +0200 progress on new docs commit e755f656b12534cfcb23bad11f1fa696e43f7428 Merge: 4644a35 35cce3b Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 12:21:27 2016 +0200 Merge branch 'new-docs' of github.com:grafana/grafana into new-docs commit 4644a35102555204787e91041b50dcbfe0f7a213 Merge: 25c4bef 977cdd5 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 12:21:11 2016 +0200 Merge branch 'master' of github.com:grafana/grafana into new-docs commit 35cce3bef802fac020a53693b02c112a91a096fc Author: Torkel Ödegaard <torkel@grafana.org> Date: Mon Oct 17 09:31:17 2016 +0200 progress on #6170 commit 25c4bef629de7d77218ba95cc3bd25fb50bb19d6 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Sun Oct 16 15:05:30 2016 +0200 fix for osx commit 6c6b52f975630be87da23dd51beafaecb820cec2 Author: Torkel Ödegaard <torkel@grafana.org> Date: Sun Oct 16 12:56:39 2016 +0200 progress on new docs commit 6a09633981ab26191d5542dbe3a788846ac6b73d Author: Torkel Ödegaard <torkel@grafana.org> Date: Sat Oct 15 11:39:49 2016 +0200 progress on new docs commit 7d533fbc23e41b86fd1ba9c955dd17ae1ad977e5 Author: Torkel Ödegaard <torkel@grafana.org> Date: Mon Oct 10 09:25:12 2016 +0200 making progress on new docs site commit 50392ce98edfa201977716e92e4a86f9d48ae386 Author: Torkel Ödegaard <torkel@grafana.org> Date: Sun Oct 9 20:02:28 2016 +0200 feat(new docs): progress on new docs site commit 81a3d3d0952d3a5d790412e90d01ac5a247e0686 Author: Torkel Ödegaard <torkel@grafana.org> Date: Fri Oct 7 07:52:11 2016 +0200 new docs site experiment commit 704adc98664665b3624087ab38ce29fc9da005f1 Author: Torkel Ödegaard <torkel@grafana.org> Date: Sat Oct 1 20:46:53 2016 +0200 new docs poc
2016-10-21 04:01:34 -05:00
+++
title = "Using Elasticsearch in Grafana"
description = "Guide for using Elasticsearch in Grafana"
keywords = ["grafana", "elasticsearch", "guide"]
type = "docs"
aliases = ["/datasources/elasticsearch"]
Squashed commit of the following: commit 4113ed00782590187d19dd2f8cbae683f164142c Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Fri Oct 21 10:47:35 2016 +0200 docs(): minor fix for docs index page commit 45478d120571519462fac905aadeab5954696690 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Thu Oct 20 14:28:21 2016 +0200 updated commit c9c1c1d5a462f85e8001a45218f24102583d7aee Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Thu Oct 20 14:27:34 2016 +0200 docs(): updated image refs commit 5fa0f27963968d77bbbbb7edd973847ea72135e3 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Wed Oct 19 14:33:04 2016 +0200 docs is almost done commit 6b988c90cb08563e2c27212338c2947e69f6fcc3 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 20:45:28 2016 +0200 almost done commit 17757c21ed813892ddb1f289f2e52613caf7bcef Author: Torkel Ödegaard <torkel@grafana.org> Date: Tue Oct 18 16:45:48 2016 +0200 making progress on docs commit f06c815991dd81b8893912a6da04a17b80b63fda Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 14:30:55 2016 +0200 progress on new docs commit 5197237426252623de2d8b9cc22ddbbdbb240763 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 13:25:26 2016 +0200 making progress commit 33e2b6b617f16f65878141cf11e54b2817a2ea96 Merge: de385e5 ecb4a99 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 12:17:58 2016 +0200 Merge branch 'new-docs' of github.com:grafana/grafana into new-docs commit ecb4a99dd54aa39f17d9bf4d7e132a389812f8fd Author: Torkel Ödegaard <torkel@grafana.org> Date: Tue Oct 18 10:39:59 2016 +0200 keep urls for now commit de385e56d86b071cf2150ccf9f1aa06ec5187277 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 17:56:18 2016 +0200 more progress commit 8469ebc239ab2316cbbc01862e5026737f272f00 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 17:08:06 2016 +0200 progress on new docs commit e755f656b12534cfcb23bad11f1fa696e43f7428 Merge: 4644a35 35cce3b Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 12:21:27 2016 +0200 Merge branch 'new-docs' of github.com:grafana/grafana into new-docs commit 4644a35102555204787e91041b50dcbfe0f7a213 Merge: 25c4bef 977cdd5 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 12:21:11 2016 +0200 Merge branch 'master' of github.com:grafana/grafana into new-docs commit 35cce3bef802fac020a53693b02c112a91a096fc Author: Torkel Ödegaard <torkel@grafana.org> Date: Mon Oct 17 09:31:17 2016 +0200 progress on #6170 commit 25c4bef629de7d77218ba95cc3bd25fb50bb19d6 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Sun Oct 16 15:05:30 2016 +0200 fix for osx commit 6c6b52f975630be87da23dd51beafaecb820cec2 Author: Torkel Ödegaard <torkel@grafana.org> Date: Sun Oct 16 12:56:39 2016 +0200 progress on new docs commit 6a09633981ab26191d5542dbe3a788846ac6b73d Author: Torkel Ödegaard <torkel@grafana.org> Date: Sat Oct 15 11:39:49 2016 +0200 progress on new docs commit 7d533fbc23e41b86fd1ba9c955dd17ae1ad977e5 Author: Torkel Ödegaard <torkel@grafana.org> Date: Mon Oct 10 09:25:12 2016 +0200 making progress on new docs site commit 50392ce98edfa201977716e92e4a86f9d48ae386 Author: Torkel Ödegaard <torkel@grafana.org> Date: Sun Oct 9 20:02:28 2016 +0200 feat(new docs): progress on new docs site commit 81a3d3d0952d3a5d790412e90d01ac5a247e0686 Author: Torkel Ödegaard <torkel@grafana.org> Date: Fri Oct 7 07:52:11 2016 +0200 new docs site experiment commit 704adc98664665b3624087ab38ce29fc9da005f1 Author: Torkel Ödegaard <torkel@grafana.org> Date: Sat Oct 1 20:46:53 2016 +0200 new docs poc
2016-10-21 04:01:34 -05:00
[menu.docs]
name = "Elasticsearch"
parent = "datasources"
weight = 3
+++
# Using Elasticsearch in Grafana
2017-05-04 04:15:48 -05:00
Grafana ships with advanced support for Elasticsearch. You can do many types of simple or complex Elasticsearch queries to
visualize logs or metrics stored in Elasticsearch. You can also annotate your graphs with log events stored in Elasticsearch.
## Adding the data source
Squashed commit of the following: commit 4113ed00782590187d19dd2f8cbae683f164142c Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Fri Oct 21 10:47:35 2016 +0200 docs(): minor fix for docs index page commit 45478d120571519462fac905aadeab5954696690 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Thu Oct 20 14:28:21 2016 +0200 updated commit c9c1c1d5a462f85e8001a45218f24102583d7aee Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Thu Oct 20 14:27:34 2016 +0200 docs(): updated image refs commit 5fa0f27963968d77bbbbb7edd973847ea72135e3 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Wed Oct 19 14:33:04 2016 +0200 docs is almost done commit 6b988c90cb08563e2c27212338c2947e69f6fcc3 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 20:45:28 2016 +0200 almost done commit 17757c21ed813892ddb1f289f2e52613caf7bcef Author: Torkel Ödegaard <torkel@grafana.org> Date: Tue Oct 18 16:45:48 2016 +0200 making progress on docs commit f06c815991dd81b8893912a6da04a17b80b63fda Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 14:30:55 2016 +0200 progress on new docs commit 5197237426252623de2d8b9cc22ddbbdbb240763 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 13:25:26 2016 +0200 making progress commit 33e2b6b617f16f65878141cf11e54b2817a2ea96 Merge: de385e5 ecb4a99 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 12:17:58 2016 +0200 Merge branch 'new-docs' of github.com:grafana/grafana into new-docs commit ecb4a99dd54aa39f17d9bf4d7e132a389812f8fd Author: Torkel Ödegaard <torkel@grafana.org> Date: Tue Oct 18 10:39:59 2016 +0200 keep urls for now commit de385e56d86b071cf2150ccf9f1aa06ec5187277 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 17:56:18 2016 +0200 more progress commit 8469ebc239ab2316cbbc01862e5026737f272f00 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 17:08:06 2016 +0200 progress on new docs commit e755f656b12534cfcb23bad11f1fa696e43f7428 Merge: 4644a35 35cce3b Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 12:21:27 2016 +0200 Merge branch 'new-docs' of github.com:grafana/grafana into new-docs commit 4644a35102555204787e91041b50dcbfe0f7a213 Merge: 25c4bef 977cdd5 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 12:21:11 2016 +0200 Merge branch 'master' of github.com:grafana/grafana into new-docs commit 35cce3bef802fac020a53693b02c112a91a096fc Author: Torkel Ödegaard <torkel@grafana.org> Date: Mon Oct 17 09:31:17 2016 +0200 progress on #6170 commit 25c4bef629de7d77218ba95cc3bd25fb50bb19d6 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Sun Oct 16 15:05:30 2016 +0200 fix for osx commit 6c6b52f975630be87da23dd51beafaecb820cec2 Author: Torkel Ödegaard <torkel@grafana.org> Date: Sun Oct 16 12:56:39 2016 +0200 progress on new docs commit 6a09633981ab26191d5542dbe3a788846ac6b73d Author: Torkel Ödegaard <torkel@grafana.org> Date: Sat Oct 15 11:39:49 2016 +0200 progress on new docs commit 7d533fbc23e41b86fd1ba9c955dd17ae1ad977e5 Author: Torkel Ödegaard <torkel@grafana.org> Date: Mon Oct 10 09:25:12 2016 +0200 making progress on new docs site commit 50392ce98edfa201977716e92e4a86f9d48ae386 Author: Torkel Ödegaard <torkel@grafana.org> Date: Sun Oct 9 20:02:28 2016 +0200 feat(new docs): progress on new docs site commit 81a3d3d0952d3a5d790412e90d01ac5a247e0686 Author: Torkel Ödegaard <torkel@grafana.org> Date: Fri Oct 7 07:52:11 2016 +0200 new docs site experiment commit 704adc98664665b3624087ab38ce29fc9da005f1 Author: Torkel Ödegaard <torkel@grafana.org> Date: Sat Oct 1 20:46:53 2016 +0200 new docs poc
2016-10-21 04:01:34 -05:00
2017-05-04 04:15:48 -05:00
1. Open the side menu by clicking the Grafana icon in the top header.
2. In the side menu under the `Dashboards` link you should find a link named `Data Sources`.
2017-05-04 03:19:00 -05:00
3. Click the `+ Add data source` button in the top header.
4. Select *Elasticsearch* from the *Type* dropdown.
2017-05-04 03:19:00 -05:00
> NOTE: If you're not seeing the `Data Sources` link in your side menu it means that your current user does not have the `Admin` role for the current organization.
Name | Description
------------ | -------------
2017-05-04 04:15:48 -05:00
*Name* | The data source name. This is how you refer to the data source in panels & queries.
*Default* | Default data source means that it will be pre-selected for new panels.
*Url* | The HTTP protocol, IP, and port of your Elasticsearch server.
*Access* | Proxy = access via Grafana backend, Direct = access directly from browser.
2017-05-04 04:15:48 -05:00
Proxy access means that the Grafana backend will proxy all requests from the browser, and send them on to the Data Source. This is useful because it can eliminate CORS (Cross Origin Site Resource) issues, as well as eliminate the need to disseminate authentication to the browser.
### Direct access
2017-05-04 03:19:00 -05:00
If you select direct access you must update your Elasticsearch configuration to allow other domains to access
Elasticsearch from the browser. You do this by specifying these to options in your **elasticsearch.yml** config file.
http.cors.enabled: true
http.cors.allow-origin: "*"
### Index settings
2016-11-04 14:29:17 -05:00
![](/img/docs/elasticsearch/elasticsearch_ds_details.png)
2017-05-04 04:15:48 -05:00
Here you can specify a default for the `time field` and specify the name of your Elasticsearch index. You can use
a time pattern for the index name or a wildcard.
2017-05-04 04:15:48 -05:00
### Elasticsearch version
Be sure to specify your Elasticsearch version in the version selection dropdown. This is very important as there are differences how queries are composed. Currently only 2.x and 5.x
are supported.
## Metric Query editor
2016-11-04 14:29:17 -05:00
![](/img/docs/elasticsearch/query_editor.png)
2017-05-04 04:15:48 -05:00
The Elasticsearch query editor allows you to select multiple metrics and group by multiple terms or filters. Use the plus and minus icons to the right to add/remove
metrics or group by clauses. Some metrics and group by clauses haves options, click the option text to expand the row to view and edit metric or group by options.
2017-05-04 03:19:00 -05:00
## Series naming & alias patterns
You can control the name for time series via the `Alias` input field.
Pattern | Description
------------ | -------------
*{{term fieldname}}* | replaced with value of a term group by
*{{metric}}* | replaced with metric name (ex. Average, Min, Max)
*{{field}}* | replaced with the metric field name
## Pipeline metrics
2017-05-04 04:15:48 -05:00
Some metric aggregations are called Pipeline aggregations, for example, *Moving Average* and *Derivative*. Elasticsearch pipeline metrics require another metric to be based on. Use the eye icon next to the metric to hide metrics from appearing in the graph. This is useful for metrics you only have in the query for use in a pipeline metric.
2016-11-04 14:29:17 -05:00
![](/img/docs/elasticsearch/pipeline_metrics_editor.png)
## Templating
2017-05-04 03:19:00 -05:00
Instead of hard-coding things like server, application and sensor name in you metric queries you can use variables in their place.
Variables are shown as dropdown select boxes at the top of the dashboard. These dropdowns makes it easy to change the data
being displayed in your dashboard.
2017-05-04 03:19:00 -05:00
Checkout the [Templating]({{< relref "reference/templating.md" >}}) documentation for an introduction to the templating feature and the different
types of template variables.
2017-05-04 03:19:00 -05:00
### Query variable
2017-05-04 04:15:48 -05:00
The Elasticsearch data source supports two types of queries you can use in the *Query* field of *Query* variables. The query is written using a custom JSON string.
2017-05-04 03:19:00 -05:00
Query | Description
------------ | -------------
*{"find": "fields", "type": "keyword"} | Returns a list of field names with the index type `keyword`.
*{"find": "terms", "field": "@hostname"}* | Returns a list of values for a field using term aggregation. Query will user current dashboard time range as time range for query.
*{"find": "terms", "field": "@hostname", "query": '<lucene query>'}* | Returns a list of values for a field using term aggregation & and a specified lucene query filter. Query will use current dashboard time range as time range for query.
2017-05-04 04:15:48 -05:00
You can use other variables inside the query. Example query definition for a variable named `$host`.
2017-05-04 03:19:00 -05:00
```
{"find": "terms", "field": "@hostname", "query": "@source:$source"}
```
2017-05-04 04:15:48 -05:00
In the above example, we use another variable named `$source` inside the query definition. Whenever you change, via the dropdown, the current value of the ` $source` variable, it will trigger an update of the `$host` variable so it now only contains hostnames filtered by in this case the
2017-05-04 03:19:00 -05:00
`@source` document property.
### Using variables in queries
There are two syntaxes:
- `$<varname>` Example: @hostname:$hostname
- `[[varname]]` Example: @hostname:[[hostname]]
Why two ways? The first syntax is easier to read and write but does not allow you to use a variable in the middle of a word. When the *Multi-value* or *Include all value*
options are enabled, Grafana converts the labels from plain text to a lucene compatible condition.
![](/img/docs/v43/elastic_templating_query.png)
2017-05-04 04:15:48 -05:00
In the above example, we have a lucene query that filters documents based on the `@hostname` property using a variable named `$hostname`. It is also using
2017-05-04 03:19:00 -05:00
a variable in the *Terms* group by field input box. This allows you to use a variable to quickly change how the data is grouped.
Example dashboard:
[Elasticsearch Templated Dashboard](http://play.grafana.org/dashboard/db/elasticsearch-templated)
## Annotations
[Annotations]({{< relref "reference/annotations.md" >}}) allows you to overlay rich event information on top of graphs. You add annotation
queries via the Dashboard menu / Annotations view. Grafana can query any Elasticsearch index
for annotation events.
Name | Description
------------ | -------------
Query | You can leave the search query blank or specify a lucene query
Time | The name of the time field, needs to be date field.
2017-05-04 04:15:48 -05:00
Title | The name of the field to use for the event title.
Tags | Optional field name to use for event tags (can be an array or a CSV string).
Text | Optional field name to use event text body.