mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Graphite: Expand metric names for variables (#33694)
* Allow expanding metrics names in variable queries * Simplify docs * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/datasources/graphite.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Clean up docs Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
This commit is contained in:
@@ -138,9 +138,34 @@ For more details, see the [Graphite docs on the autocomplete API for tags](http:
|
||||
|
||||
### Query variable
|
||||
|
||||
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
|
||||
The query you specify in the query field should be a metric find type of query. For example, a query like `prod.servers.*` fills the
|
||||
variable with all possible values that exist in the wildcard position.
|
||||
|
||||
The results contain all possible values occurring only at the last level of the query. To get full metric names matching the query
|
||||
use expand function (`expand(*.servers.*)`).
|
||||
|
||||
#### Comparison between expanded and non-expanded metric search results
|
||||
|
||||
The expanded query returns the full names of matching metrics. In combination with regex, it can extract any part of the metric name. By contrast, a non-expanded query only returns the last part of the metric name. It does not allow you to extract other parts of metric names.
|
||||
|
||||
Here are some example metrics:
|
||||
- `prod.servers.001.cpu`
|
||||
- `prod.servers.002.cpu`
|
||||
- `test.servers.001.cpu`
|
||||
|
||||
The following examples show how expanded and non-expanded queries can be used to fetch specific parts of the metrics name.
|
||||
|
||||
| non-expanded query | results | expanded query | expanded results |
|
||||
|--------------|---------|----------------|------------------|
|
||||
| `*` | prod, test | `expand(*)` | prod, test
|
||||
| `*.servers` | servers | `expand(*.servers)` | prod.servers, test.servers |
|
||||
| `test.servers` | servers | `expand(test.servers)` | test.servers |
|
||||
| `*.servers.*` | 001,002 | `expand(*.servers.*)` | prod.servers.001, prod.servers.002, test.servers.001 |
|
||||
| `test.servers.*` | 001 | `expand(test.servers.*)` | test.servers.001 |
|
||||
| `*.servers.*.cpu` | cpu | `expand(*.servers.*.cpu)` | prod.servers.001.cpu, prod.servers.002.cpu, test.servers.001.cpu |
|
||||
|
||||
As you can see from the results, the non-expanded query is the same as an expanded query with a regex matching the last part of the name.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user