# Configure Alerts This section provides instructions for setting up alerts in **Time Series Analytics Microservice**. ## Docker Compose Deployment ### Docker - Publish MQTT Alerts #### Configure MQTT Alerts The following MQTT alerts are configured for both `Wind Turbine Anomaly Detection` and `Weld Defect Detection` sample apps. Refer to the `alerts` section of each app's `config.json`: ::::{tab-set} :::{tab-item} **Wind Turbine Anomaly Detection** :sync: tab1 [wind-turbine-anomaly-detection/time-series-analytics-config/config.json]( https://github.com/open-edge-platform/edge-ai-suites/blob/release-2026.1.0/manufacturing-ai-suite/industrial-edge-insights-time-series/apps/wind-turbine-anomaly-detection/time-series-analytics-config/config.json) ::: :::{tab-item} **Weld Defect Detection** :sync: tab2 [weld-defect-detection/time-series-analytics-config/config.json]( https://github.com/open-edge-platform/edge-ai-suites/blob/release-2026.1.0/manufacturing-ai-suite/industrial-edge-insights-time-series/apps/weld-defect-detection/time-series-analytics-config/config.json) ::: :::: #### Configure MQTT Alert in TICK Script The MQTT `alert()` block is already configured by default in the TICK script for each app. Refer to the `alert()` section of each app's TICK script: ::::{tab-set} :::{tab-item} **Wind Turbine Anomaly Detection** :sync: tab1 [wind-turbine-anomaly-detection/time-series-analytics-config/tick_scripts/windturbine_anomaly_detector.tick]( https://github.com/open-edge-platform/edge-ai-suites/blob/release-2026.1.0/manufacturing-ai-suite/industrial-edge-insights-time-series/apps/wind-turbine-anomaly-detection/time-series-analytics-config/tick_scripts/windturbine_anomaly_detector.tick) ::: :::{tab-item} **Weld Defect Detection** :sync: tab2 [weld-defect-detection/time-series-analytics-config/tick_scripts/weld_defect_detector.tick]( https://github.com/open-edge-platform/edge-ai-suites/blob/release-2026.1.0/manufacturing-ai-suite/industrial-edge-insights-time-series/apps/weld-defect-detection/time-series-analytics-config/tick_scripts/weld_defect_detector.tick) ::: :::: > **Note:** Setting **QoS** to `1` ensures messages are delivered at least once. > Alerts are preserved and re-sent if the MQTT broker reconnects after downtime. ### Docker - Subscribe to MQTT Alerts Follow the steps to subscribe to the published MQTT alerts. - To subscribe to all MQTT topics, execute the following command: ```sh docker exec -ti ia-mqtt-broker mosquitto_sub -h localhost -v -t '#' -p 1883 ``` - To subscribe to a specific MQTT topic, such as `alerts/wind_turbine`, use the following command. Note that the topic information can be found in the TICK Script. ::::{tab-set} :::{tab-item} **Wind Turbine Anomaly Detection** :sync: tab1 [wind-turbine-anomaly-detection/time-series-analytics-config/tick_scripts/windturbine_anomaly_detector.tick]( https://github.com/open-edge-platform/edge-ai-suites/blob/release-2026.1.0/manufacturing-ai-suite/industrial-edge-insights-time-series/apps/wind-turbine-anomaly-detection/time-series-analytics-config/tick_scripts/windturbine_anomaly_detector.tick) ```bash docker exec -ti ia-mqtt-broker mosquitto_sub -h localhost -v -t alerts/wind_turbine -p 1883 ``` ::: :::{tab-item} **Weld Defect Detection** :sync: tab2 [weld-defect-detection/time-series-analytics-config/tick_scripts/weld_defect_detector.tick]( https://github.com/open-edge-platform/edge-ai-suites/blob/release-2026.1.0/manufacturing-ai-suite/industrial-edge-insights-time-series/apps/weld-defect-detection/time-series-analytics-config/tick_scripts/weld_defect_detector.tick) ```bash docker exec -ti ia-mqtt-broker mosquitto_sub -h localhost -v -t alerts/weld_defects -p 1883 ``` ::: :::: ### Docker - Publish OPC-UA Alerts > **Note:** > This section is applicable to `Wind Turbine Anomaly Detection` sample app only. > In other words, OPC UA alerts are not supported for the `Weld Defect Detection` sample app. #### Prerequisite Ensure that `make up_opcua_ingestion` has been executed by following the steps in the [getting started guide](../get-started.md#deploy-with-docker-compose) for the docker compose deployment To enable OPC-UA alerts in `Time Series Analytics Microservice`, use the following steps. #### Configuration #### 1. Configure OPC-UA Alert in TICK Script The following code snippets show how to add the OPC-UA alert, if not already added, replace this in place of MQTT alert section in the TICK script. ::::{tab-set} :::{tab-item} **Wind Turbine Anomaly Detection** :sync: tab1 [wind-turbine-anomaly-detection/time-series-analytics-config/tick_scripts/windturbine_anomaly_detector.tick]( https://github.com/open-edge-platform/edge-ai-suites/blob/release-2026.1.0/manufacturing-ai-suite/industrial-edge-insights-time-series/apps/wind-turbine-anomaly-detection/time-series-analytics-config/tick_scripts/windturbine_anomaly_detector.tick) ```bash data0 |alert() .crit(lambda: "anomaly_status" > 0) .message('Anomaly detected: Wind Speed: {{ index .Fields "wind_speed" }}, Grid Active Power: {{ index .Fields "grid_active_power" }}, Anomaly Status: {{ index .Fields "anomaly_status" }}') .noRecoveries() .post('http://localhost:5000/opcua_alerts') .timeout(30s) ``` > **Note:** > > - The `noRecoveries()` method suppresses recovery alerts, ensuring only critical alerts are sent. #### 2. Upload the new UDF deployment package To copy the TICK script and upload the new UDF deployment package, run the following commands: ```bash cd edge-ai-suites/manufacturing-ai-suite/industrial-edge-insights-time-series/apps/wind-turbine-anomaly-detection # path relative to git clone folder cd time-series-analytics-config export SAMPLE_APP="wind-turbine-anomaly-detection" rm -f ${SAMPLE_APP}.tar tar cf ${SAMPLE_APP}.tar models/ tick_scripts/ udfs/ curl -X POST https://localhost:3000/ts-api/udfs/package -F "file=@${SAMPLE_APP}.tar" -k ``` > **Note:** > If the `curl` command fails with `502`, wait briefly and retry the command. This response can occur while the Time Series Analytics Microservice is still becoming ready. #### 3. Configuring OPC-UA Alert in config.json Make the following REST API call to the Time Series Analytics microservice using [`config-opcua.json`](https://github.com/open-edge-platform/edge-ai-suites/blob/release-2026.1.0/manufacturing-ai-suite/industrial-edge-insights-time-series/apps/wind-turbine-anomaly-detection/time-series-analytics-config/config-opcua.json), which replaces the `mqtt` alerts key from `config.json` with the `opcua` key and its specific details: ::::{tab-set} :::{tab-item} **Wind Turbine Anomaly Detection** :sync: tab1 [wind-turbine-anomaly-detection/time-series-analytics-config/config.json]( https://github.com/open-edge-platform/edge-ai-suites/blob/release-2026.1.0/manufacturing-ai-suite/industrial-edge-insights-time-series/apps/wind-turbine-anomaly-detection/time-series-analytics-config/config.json) ```sh cd edge-ai-suites/manufacturing-ai-suite/industrial-edge-insights-time-series/apps/wind-turbine-anomaly-detection/time-series-analytics-config curl -k -X 'POST' \ 'https://localhost:3000/ts-api/config' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d @config-opcua.json ``` ### Docker - Subscribe to OPC UA Alerts using Sample OPCUA Subscriber 1. Install Python packages `asyncio` and `asyncua` to run the sample OPC UA subscriber ```bash python3 -m venv venv source venv/bin/activate pip install asyncio asyncua ``` 2. Run the following sample OPC UA subscriber by updating the `` to read the alerts published to server on tag `ns=1;i=2004` from Time Series Analytics Microservice. ```python import asyncio from asyncua import Client, Node class SubscriptionHandler: def datachange_notification(self, node: Node, val, data): print(val) async def main(): client = Client(url="opc.tcp://:30003/freeopcua/server/") async with client: handler = SubscriptionHandler() subscription = await client.create_subscription(50, handler) myvarnode = client.get_node("ns=1;i=2004") await subscription.subscribe_data_change(myvarnode) await asyncio.sleep(100) await subscription.delete() await asyncio.sleep(1) if __name__ == "__main__": asyncio.run(main()) ``` ## Helm Deployment ### Helm - Publish MQTT Alerts For detailed instructions on configuring and publishing MQTT alerts, refer to the [Publish MQTT Alerts](#docker---publish-mqtt-alerts) section. ### Helm - Subscribe to MQTT Alerts Follow the steps to subscribe to the published MQTT alerts. To subscribe to MQTT topics in a Helm deployment, execute the following command: - Identify the MQTT broker pod name by running: ```sh kubectl get pods -n ts-sample-app | grep mqtt-broker ``` - Use the pod name from the output of the above command to subscribe to all topics: ```sh kubectl exec -it -n ts-sample-app -- mosquitto_sub -h localhost -v -t '#' -p 1883 ``` - To subscribe to MQTT topic such as `alerts/wind_turbine`, use the following command: ::::{tab-set} :::{tab-item} **Wind Turbine Anomaly Detection** :sync: tab1 ```bash kubectl exec -it -n ts-sample-app -- mosquitto_sub -h localhost -v -t alerts/wind_turbine -p 1883 ``` ::: :::{tab-item} **Weld Defect Detection** :sync: tab2 ```bash kubectl exec -it -n ts-sample-app -- mosquitto_sub -h localhost -v -t alerts/weld_defects -p 1883 ``` ::: :::: ### Helm - Publish OPC-UA Alerts > **Note:** > > Ensure a sample app is deployed by following the [installation step](../get-started/deploy-with-helm.md#step-3-install-helm-charts) for OPC-UA ingestion. To enable OPC-UA alerts in `Time Series Analytics Microservice`, please follow below steps. ### **Configuration** 1. Configuring OPC-UA Alert in TICK Script Configure the TICK script by following [these instructions](#1-configure-opc-ua-alert-in-tick-script). 2. Copying the TICK Script Copy the TICK script using the following commands: ::::{tab-set} :::{tab-item} **Wind Turbine Anomaly Detection** :sync: tab1 ```sh cd edge-ai-suites/manufacturing-ai-suite/industrial-edge-insights-time-series/apps/wind-turbine-anomaly-detection # path relative to git clone folder cd time-series-analytics-config export SAMPLE_APP="wind-turbine-anomaly-detection" rm -f ${SAMPLE_APP}.tar tar cf ${SAMPLE_APP}.tar models/ tick_scripts/ udfs/ curl -X POST https://localhost:30001/ts-api/udfs/package -F "file=@${SAMPLE_APP}.tar" -k ``` > **Note:** > If the `curl` command fails with `502`, wait briefly and retry the command. This response can occur while the Time Series Analytics Microservice is still becoming ready. 3. Configuring OPC-UA Alert in `config.json` Make the following REST API call to the Time Series Analytics microservice using [`config-opcua.json`](https://github.com/open-edge-platform/edge-ai-suites/blob/release-2026.1.0/manufacturing-ai-suite/industrial-edge-insights-time-series/apps/wind-turbine-anomaly-detection/time-series-analytics-config/config-opcua.json), which replaces the `mqtt` alerts key from `config.json` with the `opcua` key and its specific details: ::::{tab-set} :::{tab-item} **Wind Turbine Anomaly Detection** :sync: tab1 [wind-turbine-anomaly-detection/time-series-analytics-config/config.json]( https://github.com/open-edge-platform/edge-ai-suites/blob/release-2026.1.0/manufacturing-ai-suite/industrial-edge-insights-time-series/apps/wind-turbine-anomaly-detection/time-series-analytics-config/config.json) ```sh cd edge-ai-suites/manufacturing-ai-suite/industrial-edge-insights-time-series/apps/wind-turbine-anomaly-detection/time-series-analytics-config curl -k -X 'POST' \ 'https://localhost:30001/ts-api/config' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d @config-opcua.json ``` ### Helm - Subscribe to OPC UA Alerts using Sample OPCUA Subscriber To subscribe to OPC-UA alerts, follow [these steps](#docker---subscribe-to-opc-ua-alerts-using-sample-opcua-subscriber). ## Supporting Resources - [Kapacitor MQTT Alert Documentation](https://docs.influxdata.com/kapacitor/v1/reference/event_handlers/mqtt/).