Create alerts with OpenSearch® Dashboards
OpenSearch® alerting feature sends notifications when data from one or more indices meets certain conditions that can be customized.
Use case examples include monitoring for HTTP status code 503, CPU load average above a certain percentage, or watching for counts of a specific keyword in logs for a specific interval. Notifications can be configured to be sent via email, Slack, or custom webhooks and other channels.
In the following example, we use Slack as the notification channel and a
sample-host-health index as data source to create a simple alert to
check CPU load. An action will be triggered when the average of
cpu_usage_percentage over 3 minutes is above 75%.
Create using Dashboards UI
To create an alert via OpenSearch Dashboards interface:
- Log in to the Aiven Console and select your OpenSearch service.
- On the service's Overview screen, in the Connection information section, select the OpenSearch Dashboards tab. This opens OpenSearch Dashboards.
- Within OpenSearch Dashboards, access the left side panel and select Alerting under the OpenSearch Plugins section.
To configure each alert, the following needs to be created. We will walk through the configuration of each section:
Notification channelMonitorData sourceQueryTrigger
Create a notification channel
A notification channel is a location for notifications to be delivered when an action is triggered.
-
In OpenSearch Dashboards, select Notifications from the left side panel.
-
Select the Channels tab and click Create channel.
-
Fill in the fields under Channel details.
-
Fill in
slack-testas the Name. -
Provide a description (optional).
-
Select
Slackunder Channel type.note- Channel types can be:
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.
- Channel types can be:
-
Paste your Slack webhook URL
https://your_slack_webhook_URLunder Webhook URL.
-
-
Click Create.
Configure authentication for email channel
This section shows how to authenticate the sender account before sending email messages. To authenticate when sending emails, the credentials need to be added first to the OpenSearch keystore. Perform this step before configuring an email channel that requires authentication.
-
In the Overview screen of your OpenSearch service, scroll to the Advanced configuration section.
-
Select Change and +Add configuration option.
-
Select the following configuration options and provide the corresponding details for each field:
email_sender_nameemail_sender_usernameemail_sender_password
At the end of this step, the email account credentials will be added to the OpenSearch keystore.
-
Select Save advanced configuration.
In OpenSearch Dashboards:
-
Select Notifications from the left side panel.
-
Select the Channels tab and click Create channel.
-
Fill in the fields under Channel details.
- Fill in
email-testas the Name. - Select
Emailunder Channel type. - Under Email settings, click Manage senders if no senders exist yet, then select Create sender.
- Assign a name to the sender. This name should match the property
email_sender_namefrom the keystore configuration. - Fill in the information required by the form and select SSL or TLS in Encryption method.
- Fill in
-
Complete the form with the recipients. You can create email groups in Manage email groups if necessary.
-
Click Create.
Create a monitor
A monitor is a job that runs on a defined schedule and queries OpenSearch indices.
-
Open the Monitors tab and click Create monitor.
-
Fill in the fields under Monitor details:
- Fill in
High CPU Monitoras the Monitor name. - Select
Per query monitoras the Monitor type (selected by default). - Select
Visual editoras the Monitor defining method. - Under Frequency, select
By interval. - Under Run every, select
1Minutes.
noteFrequency can be
By interval,Daily,Weekly,Monthly, orCustom CRON expression. - Fill in
-
Fill in the fields under Select data. Data source is the OpenSearch indices to query.
- Fill in
sample-host-healthas the Index. - Fill in
timestampas the Time field.
- Fill in
-
Configure the Query. Query defines the fields to query from indices and how to evaluate the results.
- Under Metrics, click Add metric.
- Select
average()under Aggregation andcpu_usage_percentageunder Field. - Click Save.
- Fill in
3under Time range for the last and selectminutes.
Create a trigger
A trigger is a defined condition from the query results from the monitor. If conditions are met, alerts are generated.
-
Select Add trigger.
- Fill
high_cpuas the Trigger name. - Select
1 (Highest)for Severity level. - Under Trigger condition, select
IS ABOVEfrom the drop-down menu and fill75into the number field.
noteYou can see a visual graph below the trigger with the index data and the trigger condition you have defined as a red line.
- Fill
-
Fill in the fields under Actions. Actions define the notification channel for alerts when trigger conditions are met.
- Fill in
slackas Action name. - Select
slack-testunder Notification channel. - Fill in
High CPU Test Alertas Message subject.
noteMultiple actions can be defined. In this example, we define one action to send notifications to the channel we created earlier.
- Fill in
Alert message
The Message can be adjusted as needed. Check Message Preview to see a sample and use Send test message to validate notification delivery.
Select Create.
Related pages