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

Using Dashboard Parameter in Kusto Query

This document provides a step-by-step guide on using Boolean parameters in Kusto (Azure Data Explorer) dashboards to create dynamic queries. It explains how to create a Boolean parameter, reference it in KQL, handle potential string values, and use it for conditional filters. Key notes emphasize the importance of using the `tobool()` function and combining parameters for enhanced dashboard functionality.

Uploaded by

saiakkina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Using Dashboard Parameter in Kusto Query

This document provides a step-by-step guide on using Boolean parameters in Kusto (Azure Data Explorer) dashboards to create dynamic queries. It explains how to create a Boolean parameter, reference it in KQL, handle potential string values, and use it for conditional filters. Key notes emphasize the importance of using the `tobool()` function and combining parameters for enhanced dashboard functionality.

Uploaded by

saiakkina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

In Kusto (Azure Data Explorer), when working with dashboards (like in Azure Monitor

or Azure Data Explorer dashboards), you can use parameters to make queries dynamic.
For **Boolean parameters**, the process involves defining the parameter in the
dashboard and referencing it in your Kusto Query Language (KQL) query.

### 🚀 **Step-by-Step Guide**

---

### ✅ **1. Create a Boolean Parameter in the Dashboard**

1. Open your **Azure Dashboard** or **Azure Data Explorer Dashboard**.


2. Edit the dashboard and add a **Parameter**:
- Name: `isActive` (for example).
- Type: **Boolean**.
- Set default value: `true` or `false` as needed.

---

### 🔍 **2. Reference the Boolean Parameter in KQL**

You reference the parameter using curly braces `{}` in your query. For a parameter
named `isActive`, you'd write:

```kql
let isActive = {isActive}; // This pulls the parameter value from the dashboard
MyTable
| where Active == isActive
```

- **Explanation:**
- `let isActive = {isActive};` assigns the parameter's value to a KQL variable.
- The `where` clause filters the data based on the Boolean value.

---

### 💡 **3. Handling Boolean Logic in Queries**

Sometimes, the dashboard parameter might pass the value as a string


(`"true"`/`"false"`) depending on the configuration. To handle this, ensure the
type matches:

```kql
let isActive = tobool({isActive});
MyTable
| where Active == isActive
```

- **`tobool()`** converts the parameter to an actual Boolean if needed.

---

### 🎯 **4. Using Boolean Parameter for Conditional Filters**

If you want the filter to be optional (i.e., apply the filter only when `isActive =
true`):

```kql
let isActive = tobool({isActive});
MyTable
| where (isActive == false or Active == true)
```

- **Logic:**
- When `isActive = false`, the filter doesn't restrict anything.
- When `isActive = true`, it filters for `Active == true`.

---

### ⚡ **Example**

#### **Dashboard Parameter: `ShowErrors` (Boolean)**

```kql
let showErrors = tobool({ShowErrors});
Logs
| where (showErrors == false or Severity == "Error")
| project Timestamp, Message, Severity
```

- **When `ShowErrors = true`** → Shows only error logs.


- **When `ShowErrors = false`** → Shows all logs.

---

### 📝 **Key Notes**

- Always use `tobool()` if you're unsure of the data type.


- Use `let` to improve readability and maintainability.
- Combine Boolean parameters with other filters for dynamic dashboards.

---

Let me know if you'd like more examples or if you're facing specific issues! 🚀

You might also like