Create alerts with OpenSearch® Dashboards
Set up alerts in OpenSearch® Dashboards to send notifications when your data meets specific conditions.
The OpenSearch alerting feature monitors data from one or more indexes and sends notifications when conditions are met. You can use alerts to monitor HTTP status codes, CPU load averages, or keyword counts in logs over specific intervals. Configure notifications to be sent through email, Slack, custom webhooks, or other channels.
To configure an alert, you need the following:
-
Notification channel: a location for notifications to be delivered when an action is triggered
- Available channel types are:
Amazon Chime,Amazon SNS,Slack,Custom webhook,Email, orMicrosoft Teams. - To use
Email:- Ensure you have an SMTP server configured for a valid domain to deliver email notifications.
- Configure authentication for an email channel before configuring the email channel itself.
- Available channel types are:
-
Monitor: a job that runs on a defined schedule and queries OpenSearch indexes
Available frequency options are:
By interval,Daily,Weekly,Monthly, orCustom CRON expression. -
Data source: OpenSearch indexes to query
-
Query: the fields to query from indexes and the method for evaluating results
-
Trigger: a defined condition from the query results from the monitor. If a condition is met, the alert is generated.
-
Action: a notification configured to be sent through a specified channel when trigger conditions are met. You can define multiple actions.
This guide shows how to create an alert that:
- Checks
CPU load - Uses the
sample-host-healthindex as the data source - Uses
Slackas the notification channel - Triggers when the average
cpu_usage_percentageover3 minutesexceeds75%
Create a notification channel
Configure your selected type of the notification channel, for example, Slack or Email.
Configure a Slack channel
-
In OpenSearch Dashboards, go to Notifications > Channels.
-
Click Create channel.
-
Enter the following:
- Name:
slack-test - Channel type:
Slack - Slack webhook URL: Paste your Slack webhook URL.
- Name:
-
Click Create.
Configure authentication for an email channel
To authenticate the sender account for sending email messages, add their credentials to the OpenSearch keystore:
-
Go to the Aiven Console.
-
On the Service settings page of your Aiven for OpenSearch® service, go to Advanced configuration.
-
Click Configure > Add configuration options.
-
Add all three of the following configuration options and provide the corresponding details for each field:
email_sender_nameemail_sender_usernameemail_sender_password
noteConfigure all three parameters together. You cannot set them individually or save the configuration with only some of them set.
-
Click Save configuration.
-
-
Go to OpenSearch Dashboards.
-
Go to Notifications > Channels.
-
Click Create channel.
-
Enter the following:
- Name:
email-test - Channel type:
Email
- Name:
-
Configure a sender:
- Sender type: Select
SMTP sender. - Select an SMTP sender. If no SMTP sender exists, create one:
- Enter a sender name matching the
email_sender_nameproperty from the keystore configuration. - Click Create SMTP sender.
- Enter the sender details, select Encryption method
SSL/TLS, and click Create.
- Enter a sender name matching the
- Sender type: Select
-
Configure default recipients:
Select default recipients. If no default recipients exist, create a recipient group:
- Click Create recipient group.
- Enter the recipient group details, and click Create.
-
Click Create to save the new channel configuration.
-
Access Alerting in OpenSearch Dashboards
- Log in to the Aiven Console and go to your Aiven for OpenSearch service.
- On the service's Overview page, in the Connection information section, go to the OpenSearch Dashboards tab.
- Open OpenSearch Dashboards by clicking Service URI and logging in.
- In OpenSearch Dashboards, go to Alerting.
Create a monitor
In OpenSearch Dashboards, go to Alerting > Monitors > Create monitor.
Configure monitor details
In the Monitor details section:
- Monitor name: Enter
High CPU Monitor. - Monitor type: Select
Per query monitor(selected by default). - Monitor defining method: Select
Visual editor. - Frequency: Select
By interval. - Run every: Select
1 Minute(s).
Configure a data source
In the Select data section, configure a data source:
- Enter
sample-host-healthas Indexes. - Enter
timestampas Time field.
Configure a query
In the Query section, configure a query:
- Click Add metric.
- Aggregation: Select
average(). - Field: Select
cpu_usage_percentage. - Click Save.
- Time range for the last: Enter
3 minute(s).
Create a trigger
In the Triggers section, create a trigger:
- Click Add trigger.
- Trigger name: Enter
high_cpu. - Severity level: Select
1 (Highest). - Trigger condition: Select
IS ABOVEand enter75.
You can see a visual graph for the trigger with the index data and the defined trigger condition as a red line.
Create an action
In the Triggers section, configure Actions for your trigger.
-
To use an existing notification channel for your action:
- Action name: Enter
slack. - Select your notification channel.
- Message subject: Enter
High CPU Test Alert. - Enter the message body.
- Action name: Enter
-
To use a new notification channel for your action:
- Click either Manage channels or Create channels, depending on whether you already have notification channels.
- Create a channel.
- Return to configuring your action: Go to Alerting > Monitors > Create monitor > Triggers > Actions.
- Action name: Enter
slack. - Select your new notification channel.
- Message subject: Enter
High CPU Test Alert. - Enter the message body.
Verify your action configuration by using Preview message and Send test message.
Click Create to finalize your monitor setup.
Related pages