Επεξεργασία

Κοινή χρήση μέσω


Visualize data from Azure Data Explorer in Grafana

Grafana is an analytics platform where you can query and visualize data, and then create and share dashboards based on your visualizations. Grafana provides an Azure Data Explorer plug-in, which enables you to connect to and visualize data from Azure Data Explorer. The plug-in works with both Azure Managed Grafana and self-hosted Grafana.

In this article, you learn how to configure your cluster as a data source for Grafana and visualize data in Grafana for Azure Managed Grafana and self-hosted Grafana. To follow along with the examples in this article, ingest the StormEvents sample data. The StormEvents sample dataset contains weather-related data from the National Centers for Environmental Information.

Prerequisites

Configure the data source

To configure Azure Data Explorer as a data source, follow the steps for your Grafana environment.

Add the managed identity to the Viewer role

Managed Grafana creates a system-assigned managed identity for each new workspace, by default. You can use it to access your Azure Data Explorer cluster.

  1. In the Azure portal, go to your Azure Data Explorer cluster.

  2. In the Overview section, select the database that has the StormEvents sample data.

    Screenshot of the Azure Data Explorer overview page and the selection of a sample database.

  3. Select Permissions > Add > Viewer.

    Screenshot of the permissions page with the Add button highlighted.

  4. In the search box, enter your Managed Grafana workspace name.

  5. In the search results, select the result that matches your workspace name, and then choose Select.

    Screenshot of the pane for new principals and a selected workspace name.

Set up Azure Data Explorer as a Grafana data source

Managed Grafana workspaces come with the Azure Data Explorer plug-in preinstalled.

  1. In the Azure portal, go to your Managed Grafana workspace.

  2. Under Overview, select the Endpoint link to open the Grafana UI.

  3. In Grafana, on the left menu, select the gear icon. Then select Data Sources.

    Screenshot of the Grafana settings menu and the option for data sources.

  4. Select Azure Data Explorer Datasource.

    Screenshot of the data sources page with the Azure Data Explorer source highlighted.

  5. In Connection Details, enter your Azure Data Explorer cluster URL.

    Screenshot of the pane for connection details with the box for cluster URL highlighted.

  6. Select Save & Test.

Visualize data

You finished configuring Azure Data Explorer as a data source for Grafana. Now it's time to visualize data.

The following basic example uses both the query builder mode and the raw mode of the query editor. We recommend that you view write queries for Azure Data Explorer for examples of other queries to run against the dataset.

  1. In Grafana, on the left menu, select the plus icon. Then select Dashboard.

    Screenshot of the Grafana settings menu with the dashboard option highlighted.

  2. Under the Add tab, select Graph.

    Screenshot of the page for adding a panel, with the graph option highlighted.

  3. On the graph pane, select Panel Title > Edit.

    Screenshot of the Grafana panel menu, with the edit option highlighted.

  4. At the bottom of the pane, select Data Source, and then select the data source that you configured.

    Screenshot of the menu for selecting a data source.

Query builder mode

Use query builder mode to define your query.

  1. Below the data source, select Database and choose your database from the dropdown list.

  2. Select From and choose your table from the dropdown list.

    Screenshot of the query builder that shows choosing a table from a list of samples.

  3. Now that the table is defined, filter the data:

    1. Select + to the right of Where (filter) to select one or more columns in your table.
    2. For each filter, define the values by using the applicable operator. This selection is similar to using the where operator in Kusto Query Language.
  4. Select the values to present in the table:

    1. Select + to the right of Value columns to select the value columns that will appear on the pane.

    2. For each value column, set the aggregation type.

      You can set one or more value columns. This selection is equivalent to using the summarize operator.

  5. Select + to the right of Group by (summarize) to select one or more columns that will be used to arrange the values into groups. This selection is equivalent to the group expression in the summarize operator.

  6. Select Run Query.

    Screenshot of the query builder with all values completed.

    Tip

    While you're finalizing the settings in the query builder, a Kusto Query Language query is created. This query shows the logic that you constructed by using the graphical query editor.

  7. Select Edit KQL to move to raw mode. Edit your query by using the flexibility and power of the Kusto Query Language.

Screenshot of a raw query in the query builder.

Raw mode

Use raw mode to edit your query.

  1. On the query pane, paste the following query, and then select Run. The query buckets the count of events by day for the sample dataset.

    StormEvents
    | summarize event_count=count() by bin(StartTime, 1d)
    

    Screenshot of the query window, with the button for running a query highlighted.

  2. The graph doesn't show any results because it's scoped (by default) to data from the last six hours. On the top menu, select Last 6 hours.

    Screenshot of the default time filter of last six hours.

  3. Specify a custom range that covers 2007, the year included in the StormEvents sample dataset. Then select Apply.

    Screenshot of the custom range control, with a custom date range selected.

    Now the graph shows the data from 2007, bucketed by day.

    Screenshot of a finished graph on the graph panel.

  4. On the top menu, select the save icon: .

To switch to the query builder mode, select Switch to builder. Grafana will convert the query to the available logic in the query builder. The query builder logic is limited, so you might lose manual changes that you made to the query.

Screenshot of the query window, with the button for switching to the builder highlighted.

Create alerts

  1. In Home Dashboard, select Alerting > Notification channels to create a new notification channel.

    Screenshot of the dashboard, with the option for creating a notification channel highlighted.

  2. Enter a name and type under New Notification Channel, and then select Save.

    Screenshot of the window for creating a new notification channel.

  3. On the dashboard, select Edit from the dropdown list.

    Screenshot of the dashboard panel, with the Edit menu command highlighted.

  4. Select the alert bell icon to open the Alert pane. Select Create Alert, and then complete the properties for the alert.

    Screenshot of the pane for selecting alert properties.

  5. Select the Save dashboard icon to save your changes.