Menu
Grafana documentation Administration Correlations Use Correlations Editor in Explore
Enterprise Open source

Use Correlations Editor in Explore

Before you begin

This example shows how to create a correlation using Correlations Editor in Explore.

Correlations allow you to use results of one query to run a new query in any data source. In this example you will run a query that renders tabular data. The data will be used to run a different query that yields a graph result.

Please make sure you have setup up a test data source.

Create a new correlation

  1. Go to Explore.

  2. Select test data source.

  3. Click on “+ Add” dropdown and select “Add correlation” button.

  4. Explore is now in Correlations Editor mode indicated by a blue border.

  5. Select scenario: CSV File.

  6. Select file: population_by_state.csv.

  7. Note that each cell is a link that you can click on to start creating a new correlation.

    Selecting the source of a correlation
    Selecting the source of a correlation
  8. Create new correlation that attaches a data link in the State column: click on any cell in the State column, e.g. “California”.

  9. Explore opens in split view. Select the same data source you selected in the left pane.

  10. The helper above the query editor contains all available variables you can use the target query. Variables contain all data fields (table columns) from the selected row.

  11. Select Scenario: CSV Metric Values.

  12. In the Query Editor’s String Input field provide variables with population values for each year: ${1980},${2000},${2020}. This will generate a graph using variable values.

  13. In the Query Editor’s Alias field, write ${State}

    Setting up the target of a correlation
    Setting up the target of a correlation
  14. Run a query to see that it produces a graph using sample values from the variables.

  15. Save the correlation using “Save” button in the top.

Test a newly created correlations

  1. Once the correlation is saved Explore will exit Correlations Editor automatically and re-rerun the query in the left pane.

  2. Click on a state name. Note how values from the row are inserted into the query on the right and the graph changes using the values for each row. The query is rerun with updates values every time you click on a state name.

    Result of clicking on a data link
    Result of clicking on a data link

You can apply the same steps to any data source. Correlations allow you to create links in visualizations to run dynamic queries based on selected data. In this example we used data returned by a query to build a new query generating different visualization using the same data source. However, you can create correlations between any data sources to create custom exploration flows.

Correlations in the logs panel

Correlations links in the logs panel show slightly differently than the table panel. When you enter the Correlation Editor mode when looking at logs, you will need to expand a log line to see the button that serves as the correlation link.

Logs panel in the Correlations Editor
Logs panel in the Correlations Editor