Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Data Source and Actions to BIG #890

Merged
merged 13 commits into from
Feb 12, 2025
4 changes: 2 additions & 2 deletions big/alerting/analyze-alert-rules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ To make the interaction between the Business Engine and Grafana more transparent
To review the Grafana data frame in the Business Studio:

1. Open the alert rule of interest.
2. Optionally, on the **Alert settings** tab confirm the alert rule is assigned to the dashboard(2.1) and panel(2.2) of interest.
2. Optionally, on the **Alert settings** page confirm the alert rule is assigned to the dashboard(2.1) and panel(2.2) of interest.
3. Open the **Data preview** tab.
4. Optionally, verify the dashboard variable (data frame filter) is set up to the necessary value.
5. Review the Grafana data frame in the Business Studio.
Expand All @@ -66,7 +66,7 @@ To review the Grafana data frame in the Business Studio:

<Image
title="Data preview tab to review Grafana data frames in the Business Studio."
src="/img/blog/2025-02-05-big-2.4.0/data-preview.png"
src="/img/big/business-alerting/data-preview.png"
/>

A Grafana data frame can be reviewed as a code by clicking on the **View as code** button.
12 changes: 12 additions & 0 deletions big/alerting/datasources/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
tags:
- Business Alerting
---

# Data Sources

This section provides examples of some supported data sources. Please note that the Business Intelligence platform supports most backend data sources available in Grafana. On this page, we started to collect examples of the most popular ones.

| Data Source Example | Description |
| --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| [PostgreSQL](../datasources/postgresql) | Postgres, is a free and open-source relational database management system emphasizing extensibility and SQL compliance |
8 changes: 8 additions & 0 deletions big/alerting/datasources/loki.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
tags:
- Business Alerting
---

import Image from "@theme/Image";

# Loki
130 changes: 130 additions & 0 deletions big/alerting/datasources/postgresql.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
---
tags:
- Business Alerting
---

import Image from "@theme/Image";

# PostgreSQL

The following example demonstrates configuring a Grafana, Business Studio, and PostgreSQL cluster to work with alerts.

## Grafana

Follow provided instruction to configure Time Series panel with dashboard variable.

### Time Series panel

<Image
title="Grafana Time Series visualization panel configuration."
src="/img/big/business-alerting/postgres-grafana-timeseries.png"
/>

1. Create a panel in a Grafana instance and select the pre-configured PostgreSQL datasource. In this example, it is called **Timescale**.
2. Specify an SQL query. In this example, we fetch two column data frame with **time** and **value** fields. The alerts configured via Business Studio supports Grafana dashboard variables. So, in addition to the time range parameter(**\_\_timeFilter**), we added another one. It is a dashboard variable named **metric** (see the image below for more details about the **metric** configuration).

```sql
SELECT time, value
FROM metrics
WHERE name=${metric:sqlstring} and $__timeFilter(time)
ORDER BY 1
```

The Grafana data frame looks as follows (those are not exact values that represented on the picture above).

| time | value |
| ------------------- | ----- |
| 2025-02-10 11:30:19 | 97.3 |
| 2025-02-10 11:30:29 | 97.3 |
| 2025-02-10 11:30:39 | 97.6 |
| 2025-02-10 11:30:49 | 98.0 |
| 2025-02-10 11:30:59 | 98.5 |
| 2025-02-10 11:31:09 | 99.1 |
| 2025-02-10 11:31:59 | 20.5 |
| 2025-02-10 11:32:09 | 20.7 |
| 2025-02-10 11:32:19 | 20.8 |

3. Specify one possible value. In this example, it is a device name - **Tampa South 124**.
4. Select the **Time series** visualization panel.
5. The **Thresholds** section has many tiers: - below 30 (green area on the panel), - from 30 to 60 (blue area on the panel), - from 60 to 70 (yellow area on the panel), - from 70 to 80 (orange area on the panel), - above 80 (red area on the panel).
6. The look of the created time series visualization.
- Horizontal color areas are the threshold sections.
- Vertical blue lines are the annotations created by Grafana as was instructed by the Business Studio.

### Dashboard variable

<Image
title="Grafana dashboard variable configuration."
src="/img/big/business-alerting/postgres-grafana-dash-var.png"
/>

1. **Metric** is a dashboard variable name.
2. **Query** is the dashboard variable type.
3. The dashboard variable takes data from the connected PostgreSQL data source.
4. The query that populated the dashboard variable requests the listing of all unique device names.

```sql
select distinct name from metrics
```

5. In the **Preview of values**, all fetched values are shown. Further in the example, we use one value **Tampa South 124**.

## Business Studio

Open Business Studio and add an alert rule. To follow up on the triggered event check alert history and data preview.

### Alert rule configuration

To add an alert rule, you can follow the [general instructions](/big/alerting/manage-alert-rules/#add-a-new-rule) or review the suggested example below.

After an alert rule is added, you can open the **Alert settings** page to review its configuration.

<Image
title="Business Studio alert rule configuration, part1."
src="/img/big/business-alerting/bs-alert-conf-part1.png"
/>

- **Details**
- **Title** is set to **Metric Threshold with Tampa 124 Override**.
- **Schedule** is kept by default which is every minute.
- **Target**
- **Dashboard** is set to **Metrics** Grafana dashboard.
- **Panel** is set to **One Time Series**.
- **Time Range**
- **Source** is set to take the Grafana **Dashboard** time range.
- **Execution**->**Variable** is set to use the dashboard variable **metric**. This means that query will be run for every variable value separately.
- **Variable values** is set to **All**. Here, you can specify a subset of a dashboard variable values if you do not need all of them.

<Image
title="Business Studio alert rule configuration, part2."
src="/img/big/business-alerting/bs-alert-conf-part2.png"
/>

- **Evaluation**
- **Type** is set to **Thresholds** to instruct the Business Studio to get configured thresholds from the specified Grafana dashboard.
- **Allowed range** is set to from below 30 up to 70. The top boundary is not specified; it comes from the lower boundary of the next range.
- **Apply to**. Applying to one (the last value) is enough for this example.
- **Overrides**. When the **Execution** -> **Variable** is populated with a dashboard variable name, the **Overrides** section appears. In this example, the **Tampa Sount 124** device has a specific allowed range below 30. Anything above 30 triggers the alert rule.
- **Action**
- **Actions**. In the case of a triggered alert rule, two actions are triggered - writing into the Business Engine container logs and creating a file on a designated server/location with the details of the triggered event.
- **Add Annotation**. With every triggered alert event, an annotation is created and displayed on the Grafana dashboard (a light blue vertical line on the time series visualization).

### Alert history

On the **Alert history** page, the Business Studio displays the alert rule status changes.

<Image
title="The Alert history page."
src="/img/big/business-alerting/history.png"
/>

### Data preview

On the **data preview** page you have a Grafana data frame. Specify a dashboard variable in the provided drop-down if needed.

<Image
title="The data preview page to review the Grafana data frame."
src="/img/big/business-alerting/preview.png"
/>

You can also review the payload submitted into the alert action "as-is".
8 changes: 8 additions & 0 deletions big/alerting/datasources/prometheus.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
tags:
- Business Alerting
---

import Image from "@theme/Image";

# Prometheus
65 changes: 50 additions & 15 deletions big/alerting/manage-alert-rules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ Use the **Alert rules** tab to manage alert rules. Here you can:

## Alert rules states

To temporate pause alert execution click on **Pause** icon for the specific alert rule. Alert can be started anytime to resume execution.
To temporate pause alert execution, click on the **Pause** icon for the specific alert rule. Alert can be started anytime to resume execution.

## Alert rules statuses

Right after an alert is created it becomes **Active** and **Scheduled**. After modification, the alert status changes to **Scheduled** if it requires reexecution with a new set of parameters.

- **Scheduled**. The alert is scheduled, but never run yet with a current set of parameters. This status is assigned right after the alert is created or modified by the user and API.
- **OK**. The alert has been run and the thresholds are NOT breached and the Regex pattern is NOT found.
- **Alerting**. The alert has been run and the thresholds are being breached or the Regex pattern is found.
- **Error**. Something is wrong which could be the query, annotation or action.
- **Scheduled**. The alert is scheduled but has never run with a current set of parameters. This status is assigned right after the user and API create or modify the alert.
- **OK**. The alert has been run, the thresholds are NOT breached, and the Regex pattern is NOT found.
- **Alerting**. The alert has been run, the thresholds are breached, or the Regex pattern is found.
- **Error**. Something is wrong, such as the query, annotation, or action.

### Flow schema

Expand All @@ -52,11 +52,16 @@ The **Add a new rule** window looks as follows:
src="/img/big/business-alerting/new-rule.png"
/>

<Image
title="Sections Execution and Variable values appear when the selected dashboard has Grafana's dashboard variables."
src="/img/big/business-alerting/exec.png"
/>

The new alert rule/edit window has the following configuration elements to specify:

- **Details**
- **Title** is an alert name.
- **Schedule** is a frequency of how often the rule should run. Here you can select from the ready-to-use templates and adjust if needed. Alternatively, use a CRON expression to make your schedule as complex as needed.
- **Schedule** is a frequency of how often the rule should run. Here, you can select from the ready-to-use templates and adjust if needed. Alternatively, use a Cron expression to make your schedule as complex as needed.
- **Target**
- **Dashboard** is a drop-down populated from the connected Grafana dashboard listing.
- **Panel** is a drop-down populated from the selected dashboard.
Expand All @@ -66,26 +71,56 @@ The new alert rule/edit window has the following configuration elements to speci
- **Evaluation**. It could be set to:
- **Thresholds**. The alert examines the data against thresholds set in the panel options.
- **Regex Pattern**. The alert examines the specified fields (optional) and searches the specified pattern.
- **Event**
- **Result sample size**. This parameter lets you specify how many rows in an alert result should be randomly picked up for saving and your analysis. The choice is between:
- **All Values** and **Percentage**.
- The **Results sample size** parameter is not applicable for the **Last value**.
- **Execution**. This section appears if the selected dashboard has configured Grafana dashboard variables. You can specify a variable name to be taken into account with each query.
- **Variable values**. This section appears at the same time as the **Execution**. Here, you can specify the exact dashboard variable values for the query. This parameter is useful when you do not want to use all variable values.
- **Event**. This section appears when the **Evaluation**->**Apply to** is set to **All values** or **Maximum Allowed**.
- **Result sample size**. It lets you specify how many rows in an alert result should be randomly picked up for saving and your analysis.
- **Action**
- **Actions**. Select from the drop-down list of the existing, pre-configured action APIs.
- **Add Annotation**:
- **Panel** to create and attach an annotation to a panel.
- **Dashboard** to create and attach an annotation to a dashboard (i.e., all panels of this dashboard),
- **Disabled** to disable the creation of any annotation following the alert rule breach.
- **Dashboard** to create and attach an annotation to a dashboard (i.e., all panels of this dashboard).
- **Disabled** to disable the creation of any annotation following the triggered alert rule.

### Schedule

Select from the templates and adjust if needed or specify a CRON expression to make your schedule as complex as needed.
Select from the templates and adjust if needed, or specify a CRON expression to make your schedule as complex as required.

<Image
title="Custom made Schedule editor with suggestions."
title="Custom-made Schedule editor with suggestions."
src="/img/big/business-alerting/scheduler.png"
width="70%"
/>

### Grafana dashboard variables

The Business Studio alert rules can incorporate Grafana dashboard variables and be specific for certain conditions.

For instance, you can create the same alert rule for all your devices but make it distinctive for the actual threshold values.

Below is the general description of such a configuration. You can find the detailed data sources examples in dedicated parts of this documentation.

When in the **Target**->**Dashboard** parameter, you specify a dashboard containing dashboard variables, two more sections appear:

- **Execution**. Here, you can specify a dashboard variable to use in each alert rule query.
- **Variable values**. Here, you can specify the subset of dashboard variable values that should be used in the alert rule execution.

<Image
title="The Execution and Variable values sections appear if the specified Target->Dashboard contains dashboard variables."
src="/img/big/business-alerting/execution-var-values.png"
/>

When a dashboard variable is specified in the **Execution**->**Variable** parameter, the **Overrides** section appears. Here, you can identify specific thresholds for each dashboard variable value individually.

<Image
title="The Overrides section appears if a dashboard variable is selected in the Execution-Variable section."
src="/img/big/business-alerting/overrides.png"
/>

In the described example, the alert rules should be triggered when the observable data is above 70. (values in the ranges from below 30, above 30, above 60, and below 70 are allowed).

For only one device with the name **Tampa South 124**, the allowed range is below 30. Any value above 30 triggers the alert rule.

## Multi-frames

The Business Engine supports multi-frame data sets. That means that the alert rule assigned to a dashboard and panel will be applied to all data frames fetched from the connected data source.
Expand All @@ -102,4 +137,4 @@ The Business Engine supports multi-frame data sets. That means that the alert ru
Support of Grafana transformation is in beta state. This is due to the number of existing transformations.
:::

Grafana transformations are supported. However, please, note, that Grafana offers a large number of transformations, hence, there is a chance that some of them will not work correctly.
Grafana transformations are supported. However, please note that Grafana offers many transformations; hence, there is a chance that some of them will not work correctly.
10 changes: 9 additions & 1 deletion big/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,17 @@ Such architecture allows users:

There is a possibility of facilitating all Grafana instances version control, new Grafana dashboard propagation (for instance, from the DEV to QA to production), etc.

## Users

The Business Studio interface accommodates two types of users - **Business** and **Technical**. You can always switch between them in profile settings (the feature is coming soon).

- Business users have sleeker interfaces; those can be internal company users as well as customers. They can focus on creating alert rules and actions, provide a quick analysis and signal about critical errors if necessary.
- Technical users have more functionality available for deeper troubleshooting, such as payloads, Grafana data frame views, etc. Those users are not shy about working with clusters and docker containers.

## Some features at a glance

- [Monaco Code editor to create sophisticated alert messages](/big/studio/manage-alert-actions/#add-a-new-action)
- [Use Grafana dashboard variables and overrides in the alert rule configuration](/big/alerting/manage-alert-rules/#grafana-dashboard-variables)
- [Monaco Code editor to create sophisticated alert messages](/big/studio/actions/#add-a-new-action)
- [Simplified schedule configuration](/big/alerting/manage-alert-rules/#add-a-new-rule)
- [Simplified connection configuration](/big/studio/manage-business-engines/#environment)
- [Review Grafana data frames in the Business Studio](/big/alerting/analyze-alert-rules/#review-grafana-data-frames-in-the-business-studio)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Image from "@theme/Image";

# Actions

Use the [**Actions**](/big/studio/manage-business-engines/#actions) tab to manage actions. Here you can:
Use the Actions tab to manage actions for the selected Business Engine. Here you can:

1. Add a new action.
2. Delete an existing action.
Expand Down
8 changes: 8 additions & 0 deletions big/studio/actions/json.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
tags:
- Business Studio
---

import Image from "@theme/Image";

# JSON Server
8 changes: 8 additions & 0 deletions big/studio/actions/logs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
tags:
- Business Studio
---

import Image from "@theme/Image";

# Logs
8 changes: 8 additions & 0 deletions big/studio/actions/node-red.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
tags:
- Business Studio
---

import Image from "@theme/Image";

# Node-RED
2 changes: 1 addition & 1 deletion big/studio/manage-business-engines.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ To learn more about alert rules, please refer to this documentation's [**Alert r

The **Actions** tab helps to configure actions, which are the set of steps that are triggered by an expected event. The most common scenario is when an action is triggered after an alert rule is broken, but it is just one of the possible scenarios.

To learn more about actions, please refer to this documentation's [**Actions**](/big/studio/manage-alert-actions/) section.
To learn more about actions, please refer to this documentation's [**Actions**](/big/studio/actions/) section.

## Environment

Expand Down
2 changes: 1 addition & 1 deletion blog/big/2024-12-31-big-2.2.0/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ The new alert rule/edit window has the following configuration elements to speci
- **Add Annotation** option.
- specify **Panel** to create and attach an annotation to a panel,
- specify **Dashboard** to create and attach an annotation to a dashboard (i.e. all panels of this dashboard),
- specify **Disabled** to disable the creation of any annotation following the alert rule breach.
- specify **Disabled** to disable the creation of any annotation following the triggered alert rule.

### Manage alert actions

Expand Down
Loading