2016-10-21 04:01:34 -05:00
+++
title = "Using Graphite in Grafana"
description = "Guide for using graphite in Grafana"
keywords = ["grafana", "graphite", "guide"]
type = "docs"
2017-02-06 11:04:34 -06:00
aliases = ["/datasources/graphite"]
2016-10-21 04:01:34 -05:00
[menu.docs]
name = "Graphite"
identifier = "graphite"
parent = "datasources"
weight = 1
+++
# Using Graphite in Grafana
2015-03-10 02:55:42 -05:00
2015-07-07 10:14:57 -05:00
Grafana has an advanced Graphite query editor that lets you quickly navigate the metric space, add functions,
2015-06-19 12:03:09 -05:00
change function parameters and much more. The editor can handle all types of graphite queries. It can even handle complex nested
queries through the use of query references.
2015-03-10 02:55:42 -05:00
2015-10-26 07:36:00 -05:00
## Adding the data source
2015-04-13 02:37:07 -05:00
2017-05-03 09:34:51 -05:00
1. Open the side menu by clicking the Grafana icon in the top header.
2015-10-26 07:36:00 -05:00
2. In the side menu under the `Dashboards` link you should find a link named `Data Sources` .
2017-05-03 08:50:38 -05:00
3. Click the `+ Add data source` button in the top header.
4. Select `Graphite` from the *Type* dropdown.
2015-04-13 02:37:07 -05:00
2017-05-03 09:34:51 -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.
2015-04-13 02:37:07 -05:00
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 graphite-web or graphite-api install.
*Access* | Proxy = access via Grafana backend, Direct = access directly from browser.
2015-03-13 03:46:53 -05:00
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 details to the browser.
2015-08-10 16:44:08 -05:00
2015-03-13 03:46:53 -05:00
## Metric editor
### Navigate metric segments
2015-03-10 02:55:42 -05:00
Click the ``Select metric`` link to start navigating the metric space. One you start you can continue using the mouse
or keyboard arrow keys. You can select a wildcard and still continue.
2017-09-14 04:04:01 -05:00
{{< docs-imagebox img = "/img/docs/v45/graphite_query1_still.png"
2017-09-12 02:07:36 -05:00
animated-gif="/img/docs/v45/graphite_query1.gif" >}}
2015-03-10 02:55:42 -05:00
2015-03-13 03:46:53 -05:00
### Functions
2017-05-04 03:19:00 -05:00
2015-03-10 02:55:42 -05:00
Click the plus icon to the right to add a function. You can search for the function or select it from the menu. Once
a function is selected it will be added and your focus will be in the text box of the first parameter. To later change
a parameter just click on it and it will turn into a text box. To delete a function click the function name followed
by the x icon.
2017-09-14 04:04:01 -05:00
{{< docs-imagebox img = "/img/docs/v45/graphite_query2_still.png"
2017-09-12 02:07:36 -05:00
animated-gif="/img/docs/v45/graphite_query2.gif" >}}
2015-03-10 02:55:42 -05:00
### Optional parameters
2017-05-04 03:19:00 -05:00
2015-03-10 02:55:42 -05:00
Some functions like aliasByNode support an optional second argument. To add this parameter specify for example 3,-2 as the first parameter and the function editor will adapt and move the -2 to a second parameter. To remove the second optional parameter just click on it and leave it blank and the editor will remove it.
2017-09-14 04:04:01 -05:00
{{< docs-imagebox img = "/img/docs/v45/graphite_query3_still.png"
2017-09-12 02:07:36 -05:00
animated-gif="/img/docs/v45/graphite_query3.gif" >}}
2015-03-13 03:46:53 -05:00
2017-04-28 05:51:21 -05:00
### Nested Queries
2017-05-03 09:34:51 -05:00
You can reference queries by the row “letter” that they’ re on (similar to Microsoft Excel). If you add a second query to a graph, you can reference the first query simply by typing in #A . This provides an easy and convenient way to build compounded queries.
2017-04-28 05:51:21 -05:00
2017-09-14 04:04:01 -05:00
{{< docs-imagebox img = "/img/docs/v45/graphite_nested_queries_still.png"
2017-09-13 09:29:53 -05:00
animated-gif="/img/docs/v45/graphite_nested_queries.gif" >}}
2015-03-13 03:46:53 -05:00
## Point consolidation
2015-04-13 02:37:07 -05:00
2017-05-03 09:34:51 -05:00
All Graphite metrics are consolidated so that Graphite doesn't return more data points than there are pixels in the graph. By default,
2018-03-25 08:49:06 -05:00
this consolidation is done using `avg` function. You can control how Graphite consolidates metrics by adding the Graphite consolidateBy function.
2015-04-13 02:37:07 -05:00
> *Notice* This means that legend summary values (max, min, total) cannot be all correct at the same time. They are calculated
> client side by Grafana. And depending on your consolidation function only one or two can be correct at the same time.
2015-07-07 07:50:23 -05:00
## Templating
2017-05-03 07:20:59 -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.
Checkout the [Templating ]({{< relref "reference/templating.md" >}} ) documentation for an introduction to the templating feature and the different
types of template variables.
2017-05-03 08:50:38 -05:00
### Query variable
2017-05-03 07:20:59 -05:00
2017-05-03 09:34:51 -05:00
The query you specify in the query field should be a metric find type of query. For example, a query like `prod.servers.*` will fill the
variable with all possible values that exist in the wildcard position.
2015-07-07 07:50:23 -05:00
You can also create nested variables that use other variables in their definition. For example
`apps.$app.servers.*` uses the variable `$app` in its query definition.
2017-05-03 07:20:59 -05:00
### Variable usage
You can use a variable in a metric node path or as a parameter to a function.
2016-11-04 14:29:17 -05:00
![](/img/docs/v2/templated_variable_parameter.png)
2015-07-07 07:50:23 -05:00
2017-05-03 07:20:59 -05:00
There are two syntaxes:
- `$<varname>` Example: apps.frontend.$server.requests.count
- `[[varname]]` Example: apps.frontend.[[server]].requests.count
2017-05-03 09:34:51 -05:00
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. Use
2017-05-03 07:20:59 -05:00
the second syntax in expressions like `my.server[[serverNumber]].count` .
2017-05-04 03:19:00 -05:00
Example:
[Graphite Templated Dashboard ](http://play.grafana.org/dashboard/db/graphite-templated-nested )
2017-04-28 05:51:21 -05:00
## Annotations
2017-04-28 06:43:00 -05:00
[Annotations ]({{< relref "reference/annotations.md" >}} ) allows you to overlay rich event information on top of graphs. You add annotation
2017-04-28 05:51:21 -05:00
queries via the Dashboard menu / Annotations view.
Graphite supports two ways to query annotations. A regular metric query, for this you use the `Graphite query` textbox. A Graphite events query, use the `Graphite event tags` textbox,
2017-05-03 09:34:51 -05:00
specify a tag or wildcard (leave empty should also work)