0% found this document useful (0 votes)
10 views

Using Base Queries in Kusto dashboard

Uploaded by

saiakkina
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Using Base Queries in Kusto dashboard

Uploaded by

saiakkina
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

In Kusto Explorer, you can use base queries to create reusable components for your

dashboards. Base queries allow you to define a common dataset that can be
referenced by multiple tiles in the dashboard, ensuring consistency and simplifying
maintenance. Here’s a step-by-step guide on how to use base queries in a Kusto
Explorer dashboard:

### Step-by-Step Guide

#### 1. **Define the Base Query**


A base query is a query that defines a common dataset or a foundational query that
other queries can build upon.

**Example Base Query:**

```kql
let BaseData = MyTable
| where Timestamp >= datetime(2023-01-01) and Timestamp <= datetime(2023-01-31)
| project Timestamp, Value;
BaseData
```

#### 2. **Save the Base Query**


Save this base query with a name so that it can be reused in other queries.

**Instructions:**
1. Write your base query in Kusto Explorer.
2. Highlight the query and right-click to bring up the context menu.
3. Select "Save As Base Query" or similar option.
4. Give your base query a meaningful name, such as `BaseData`.

#### 3. **Create a Dashboard**


Navigate to the Dashboard section in Kusto Explorer.

**Instructions:**
1. Click `New Dashboard` to create a new dashboard or select an existing one to
edit.

#### 4. **Add Tiles and Use the Base Query**


Add tiles to your dashboard and use the saved base query as a starting point for
these tiles.

**Example Usage of Base Query in a Tile:**

```kql
let BaseData = cluster('mycluster').database('mydatabase').BaseData;
BaseData
| summarize TotalValue = sum(Value) by bin(Timestamp, 1d)
| project Timestamp, TotalValue
```

**Instructions:**
1. In the dashboard editor, add a new tile.
2. Select the type of visualization you want (e.g., table, chart).
3. Insert a query that references your base query.
4. Use the base query by referencing its name as shown in the example.

#### 5. **Add Input Controls (Optional)**


If your base query involves parameters (e.g., startDate and endDate), add input
controls to the dashboard for these parameters.
**Instructions:**
1. In the dashboard editor, add a new control.
2. Choose the appropriate control type (e.g., Date Picker).
3. Bind this control to the parameter used in your base query.

#### 6. **Bind Parameters to Base Query**


Ensure that the parameters in your base query are correctly bound to the input
controls in the dashboard.

**Example Parameterized Base Query:**

```kql
let BaseData = MyTable
| where Timestamp >= datetime({startDate}) and Timestamp <= datetime({endDate})
| project Timestamp, Value;
BaseData
```

**Instructions:**
1. Define `startDate` and `endDate` parameters in the Parameters tab.
2. Bind these parameters to Date Picker controls in the dashboard.

#### 7. **Run and Test the Dashboard**


Save the dashboard and test it to ensure that the base query and the tiles
referencing it work correctly.

**Instructions:**
1. Save the dashboard.
2. Use the input controls to select different parameter values (e.g., date ranges).
3. Verify that the query results in the tiles update accordingly based on the
selected parameters.

### Summary

1. **Define the base query** with a common dataset.


2. **Save the base query** with a meaningful name.
3. **Create a dashboard** and add tiles.
4. **Use the base query** in the tiles by referencing its name.
5. **Add input controls** if parameters are involved.
6. **Bind parameters** to the base query and input controls.
7. **Run and test** the dashboard to ensure it updates correctly with the selected
parameters.

This approach allows you to maintain consistency across multiple tiles and
simplifies the management of your dashboard by using a common base query.

You might also like