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 are such as monitoring for HTTP status code 503, CPU load average above certain percentage or watch for counts of a specific keyword in logs for a specific amount of interval, notification to be configured to be sent via email, slack or custom webhooks and other destination.
In the following example we are using Slack as the destination and a sample-host-health index as datasource to create a simple alert to check cpu load. An action will be triggered when average of cpu_usage_percentage over 3 minutes is above 75%.
Create using Dashboards UI#
In order to create an alert via OpenSearch Dashboards interface, follow these steps:
Log in to the Aiven Console and select your OpenSearch service.
On the service’s Overview screen, in the Connection information section and select the OpenSearch Dashboards tab.
This opens the OpenSearch Dashboard
Within the OpenSearch Dashboard, 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 configuration of each section.
DestinationMonitorData sourceQueryTrigger
Create a destination#
Destination is a location for notifications to be delivered when an action is triggered.
Open the Destination tab and click on Add destination
Fill in the fields under Destination
Fill
slack-testas the NameSelect
Slackunder TypePaste your slack webhook here
https://your_slack_webhook_URLunder Webhook URL
Note
Destination Type can be: Amazon Chime, Slack, Custom webhook or Email
Important
When using email you need to have a SMTP server configured for a valid domain to deliver email notifications
Configure authentication for email destination#
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 destination that requires authentication.
In 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. That is, the steps-by-step procedure that follows need to be completed in OpenSearch Dashboards.
Select Save advanced configuration.
Open the Destination tab in the OpenSearch Dashboard and select Add destination.
Fill in the fields under Destination
Fill
email-testas the NameSelect
Emailunder TypeIn this step we assume that no senders exist yet. So, click first on Manage Senders, then click on New sender link.
Assign a name to the sender. Please note that this name should match the property
email_sender_namefrom step 1.Fill in the information required by the form and select SSL or TLS in Encryption method.
Lastly you need to complete the form with the recipients, by creating email groups in Manage email groups if necessary.
Create a monitor#
Monitor is a job that runs on a defined schedule and queries OpenSearch indices.
Open the Monitors tab and click on Create monitor
Fill in the fields under Monitor details
Fill
High CPU Monitorinto Monitor nameSelect
Per query monitoras the Monitor typeSelect
Visual editoras the Monitor defining methodSelect
By intervalunder Schedule FrequencyUnder Run every select
1Minutes
Note
Schedule Frequency can be By internal, Daily Weekly Monthly, Custom CRON expression.
Fill in the fields under Data source
Data source is the OpenSearch indices to query.
Fill
sample-host-healthinto indexFill
timestampinto Time fieldQuery
Query defines the fields to query from indices and how to evaluate the results.
Under Metrics click on Add metric
Select
average()under Aggregation andcpu_usage_percentageunder Field, click on SaveFill
3under Time range for the last and selectminutes
Create a trigger#
Triggers is a defined conditions from the queries results from monitor. If conditions are met, alerts are generated.
Select Add trigger
Fill
high_cpuas the Trigger nameSelect
1 (Highest)for Severity levelUnder Trigger condition select
IS ABOVEfrom the drop-down menu and fill75into the number field
Note
You can see a visual graph below trigger with the index data and the trigger condition you have defined as a red line
Fill in the fields under Actions
Actions defines the destination for notification alerts when trigger conditions are met.
Fill in
slackas Action nameSelect
slack-testunder DestinationFill in
High CPU Test Alertas Message subject
Note
Multiple Actions can be defined, in this example we will define one action to send notification to destination we have defined in step 4
Alert message#
Message can be adjusted as needed, check Message Preview to see the sample and use Send test message to validate notification delivery
Select Create and your monitor is ready!
For further details on alerting monitors configuration