2022-11-01 23:22:06 +08:00
---
aliases:
2022-12-10 00:36:04 +08:00
- ../../data-sources/graphite/query-editor/
2025-07-01 05:37:49 +08:00
description: Guide for using the Graphite data source query editor.
2022-11-01 23:22:06 +08:00
keywords:
- grafana
- microsoft
- graphite
- monitor
- metrics
- logs
- resources
- queries
Explicitly set all front matter labels in the source files (#71548)
* Set every page to have defaults of 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration pages to have of 'Cloud', 'Enterprise', and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/enterprise-licensing pages to have 'Enterprise' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/organization-management pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/provisioning pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/recorded-queries pages to have labels cloud,enterprise
* Set administration/roles-and-permissions/access-control pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/stats-and-license pages to have labels cloud,enterprise
* Set alerting pages to have labels cloud,enterprise,oss
* Set breaking-changes pages to have labels cloud,enterprise,oss
* Set dashboards pages to have labels cloud,enterprise,oss
* Set datasources pages to have labels cloud,enterprise,oss
* Set explore pages to have labels cloud,enterprise,oss
* Set fundamentals pages to have labels cloud,enterprise,oss
* Set introduction/grafana-cloud pages to have labels cloud
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Fix introduction pages products
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set panels-visualizations pages to have labels cloud,enterprise,oss
* Set release-notes pages to have labels cloud,enterprise,oss
* Set search pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/audit-grafana pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-authentication pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/configure-authentication/enhanced-ldap pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-authentication/saml pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-database-encryption/encrypt-secrets-using-hashicorp-key-vault pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-request-security pages to have labels cloud,enterprise,oss
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-team-sync pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/export-logs pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set troubleshooting pages to have labels cloud,enterprise,oss
* Set whatsnew pages to have labels cloud,enterprise,oss
* Apply updated labels from review
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
---------
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
2023-07-18 16:10:12 +08:00
labels:
products:
- cloud
- enterprise
- oss
2022-11-01 23:22:06 +08:00
menuTitle: Query editor
title: Graphite query editor
weight: 300
2024-05-28 22:17:49 +08:00
refs:
query-transform-data:
- pattern: /docs/grafana/
destination: /docs/grafana/< GRAFANA_VERSION > /panels-visualizations/query-transform-data/
- pattern: /docs/grafana-cloud/
destination: /docs/grafana/< GRAFANA_VERSION > /panels-visualizations/query-transform-data/
annotate-visualizations:
- pattern: /docs/grafana/
destination: /docs/grafana/< GRAFANA_VERSION > /dashboards/build-dashboards/annotate-visualizations/
- pattern: /docs/grafana-cloud/
destination: /docs/grafana/< GRAFANA_VERSION > /dashboards/build-dashboards/annotate-visualizations/
set-up-grafana-monitoring:
- pattern: /docs/grafana/
destination: /docs/grafana/< GRAFANA_VERSION > /setup-grafana/set-up-grafana-monitoring/
- pattern: /docs/grafana-cloud/
destination: /docs/grafana/< GRAFANA_VERSION > /setup-grafana/set-up-grafana-monitoring/
2022-11-01 23:22:06 +08:00
---
# Graphite query editor
Grafana includes a Graphite-specific query editor to help you build queries.
The query editor helps you quickly navigate the metric space, add functions, and change function parameters.
2025-07-01 05:37:49 +08:00
It supports a variety of Graphite queries, including complex nested queries, through the use of query references.
2022-11-01 23:22:06 +08:00
2024-05-28 22:17:49 +08:00
For general documentation on querying data sources in Grafana, see [Query and transform data ](ref:query-transform-data ).
2022-11-01 23:22:06 +08:00
2025-07-01 05:37:49 +08:00
## Query editor elements
2022-11-01 23:22:06 +08:00
2025-07-01 05:37:49 +08:00
The query editor consists of the following elements:
- **Series** - A series in Graphite is a unique time-series dataset, represented by a specific metric name and timestamped values. Click **select metric** to select a metric from the drop-down.
- **Functions** - Graphite uses functions to manipulate data. Click the ** + sign** to view a list of functions in the drop-down. You can create a query with multiple functions.
To view the raw query, click the **Pencil icon** in the upper right. Click the **Pencil icon** again to continue adding series and functions.
2022-11-01 23:22:06 +08:00
## Choose metrics to query
2025-07-01 05:37:49 +08:00
Click **Select metric** to browse the available metrics. You can navigate using your mouse or arrow keys. You can also select a wildcard.
2022-11-01 23:22:06 +08:00
{{< figure src = "/static/img/docs/graphite/graphite-query-editor-still.png" animated-gif = "/static/img/docs/graphite/graphite-query-editor.gif" > }}
## Functions
2025-07-01 05:37:49 +08:00
Click the ** + sign** next to **Function** to add a function from the drop-down. You can also search by typing the first few letters of the function name.
After selecting a function, Grafana adds it to your query and automatically places your cursor in the first parameter field.
To edit a parameter, click it to open an editable text box.
2022-11-01 23:22:06 +08:00
2025-07-01 05:37:49 +08:00
To remove a function simply click on it, then click the **X icon** that appears above it.
2022-11-01 23:22:06 +08:00
{{< figure src = "/static/img/docs/graphite/graphite-functions-still.png" animated-gif = "/static/img/docs/graphite/graphite-functions-demo.gif" > }}
2025-07-01 05:37:49 +08:00
Some functions like `aliasByNode` support an optional second argument. To add this argument, hover your mouse over the argument and a dialog box appears. To remove the second optional parameter, click on it to delete it.
2022-11-01 23:22:06 +08:00
2025-07-01 05:37:49 +08:00
Refer to [Functions ](https://graphite.readthedocs.io/en/latest/functions.html ) in the Graphite documentation for more information.
2022-11-01 23:22:06 +08:00
2025-07-01 05:37:49 +08:00
{{% admonition type="warning" %}}
Some functions accept a second argument, which can itself be another function that returns a series. If you need to add a second argument that is a function, Grafana recommends using a series reference from a second query instead of embedding the function directly.
Currently, the query editor does not support parsing a second function argument when switching between the query builder and the code editor.
{{% /admonition %}}
2024-03-29 01:22:54 +08:00
2022-11-01 23:22:06 +08:00
### Sort labels
2025-07-01 05:37:49 +08:00
If the same labels appear on multiple graphs, they may be sorted differently and assigned different colors.
2022-11-01 23:22:06 +08:00
2025-07-01 05:37:49 +08:00
To ensure consistent sorting and coloring, use the `sortByName()` function to order labels alphabetically.
2022-11-01 23:22:06 +08:00
### Modify the metric name in my tables or charts
Use `alias` functions, such as `aliasByNode()` or `aliasSub()` , to change metric names on Grafana tables or graphs.
### Consolidate data points
Grafana consolidates all Graphite metrics so that Graphite doesn't return more data points than there are pixels in the graph.
By default, Grafana consolidates data points using the `avg` function.
To control how Graphite consolidates metrics, use the Graphite `consolidateBy()` function.
2025-07-01 05:37:49 +08:00
{{% admonition type="note" %}}
Grafana calculates legend summary values like `max` , `min` , and `total` on the client side, after data has been calculated.
Depending on the consolidation function used, only one or two of these values may be accurate at the same time.
{{% /admonition %}}
2022-11-01 23:22:06 +08:00
### Combine time series
To combine time series, click **Combine** in the **Functions** list.
2025-07-01 05:37:49 +08:00
### Select and explore data with tags
2022-11-01 23:22:06 +08:00
2025-07-01 05:37:49 +08:00
In Graphite, everything is a tag.
2022-11-01 23:22:06 +08:00
When exploring data, previously selected tags filter the remaining result set.
To select data, use the `seriesByTag` function, which takes tag expressions (`=`, `!=` , `=~` , `!=~` ) to filter timeseries.
The Grafana query builder does this for you automatically when you select a tag.
2025-07-01 05:37:49 +08:00
{{% admonition type="note" %}}
Regular expression searches can be slow on high-cardinality tags, so try to use other tags to reduce the scope first. To help reduce the results, start by filtering on a particular name or namespace.
{{% /admonition %}}
## Nested queries
2022-11-01 23:22:06 +08:00
2025-07-01 05:37:49 +08:00
Grafana lets you reference one query from another using its query letter, similar to how cell references work in a spreadsheet.
2022-11-01 23:22:06 +08:00
2025-07-01 05:37:49 +08:00
For example, if you add a second query and want to build on the results of query A, you can reference it using #A .
2022-11-01 23:22:06 +08:00
2025-07-01 05:37:49 +08:00
This approach allows you to build compound or nested queries, making your panels more flexible and easier to manage.
2022-11-01 23:22:06 +08:00
## Use wildcards to make fewer queries
2025-07-01 05:37:49 +08:00
To display multiple time series on the same graph, use wildcards in your query to return all matching series at once.
2022-11-01 23:22:06 +08:00
2025-07-01 05:37:49 +08:00
For example, to monitor CPU utilization across a variety of metrics, you can use a single query like `cpu.percent.*.g` to retrieve all matching time series.
This approach is more efficient than writing separate queries for each series, such as `cpu.percent.user.g` , `cpu.percent.system.g` , and others, which would result in multiple queries to the data source.
2022-11-01 23:22:06 +08:00
## Apply annotations
2025-07-01 05:37:49 +08:00
[Annotations ](ref:annotate-visualizations ) overlay rich event information on top of graphs. You can add annotation queries in the dashboard menu's **Annotations** view.
2022-11-01 23:22:06 +08:00
Graphite supports two ways to query annotations:
- A regular metric query, using the `Graphite query` textbox.
- A Graphite events query, using the `Graphite event tags` textbox with a tag, wildcard, or empty value
## Integration with Loki
2025-07-01 05:37:49 +08:00
When you change the data source to Loki in Explore, your Graphite queries are automatically converted to Loki queries. Loki label names and values are extracted based on the mapping information defined in your Graphite data source configuration. Grafana automatically transforms queries that use tags with `seriesByTags()` without requiring additional setup.