On This Page

Home / Cribl as Code/ Cribl API/ API Code Examples/ Cribl Search Examples/Get Alerts for Search Results

Get Alerts for Search Results

Use the Cribl API to configure a Notification target and Notification so that you can receive alerts based on the results of a scheduled search.

About Code Examples

Code examples use Bearer token authentication. Read the API authentication documentation to learn how to configure authentication. The API Credential that you use to obtain the Bearer token must have the necessary Permissions for the operations in code examples.

Replace the variables in code examples with the corresponding information for your Cribl deployment.

Cribl Search is available only on Cribl.Cloud, so these code examples do not include on-prem deployments.

Code examples do not include all available body parameters. For a complete list of body parameters for specific endpoints, refer to the documentation in the API Reference.

Create a Notification Target

To receive alerts when a scheduled search generates results that match the triggering conditions that you specify, you need a Notification target to send alerts to.

Once created, Notification targets are available across Cribl products. If you want to use the default System Messages target or an existing target, you can create a Notification without adding a new Notification target.

Amazon SNS Notification Target (Topic ARN)

This example creates an Amazon SNS Notification target for sending Notifications to an Amazon Simple Notification Service (SNS) topic. You can also configure Amazon SNS targets to send text messages (SMS) to a phone number.

The response is a JSON object that includes the Notification target configuration and a status object that lists the target’s health and metrics.

Amazon SNS Example (Topic ARN)Body Parameter InformationResponse Example

Amazon SNS Notification Target (Phone Number)

This example creates an Amazon SNS Notification target for sending text message (SMS) Notifications to a phone number. You can also configure a target that uses the Amazon Simple Notification Service (SNS) topic instead.

The response is a JSON object that includes the Notification target configuration and a status object that lists the target’s health and metrics.

Amazon SNS Example (Phone Number)Body Parameter InformationResponse Example

Email Notification Target

This example creates an email Notification target that uses the SMTP server of your choice. The response is a JSON object that includes the Notification target configuration and a status object that lists the target’s health and metrics.

Email ExampleBody Parameter InformationResponse Example

PagerDuty Notification Target

This example creates a PagerDuty Notification target that uses the Cribl Search native integration with the PagerDuty API. The response is a JSON object that includes the Notification target configuration and a status object that lists the target’s health and metrics.

PagerDuty ExampleBody Parameter InformationResponse Example

Slack Notification Target

This example creates a Slack Notification target that uses Slack’s incoming webhooks. The response is a JSON object that includes the Notification target configuration and a status object that lists the target’s health and metrics.

Slack ExampleBody Parameter InformationResponse Example

Webhook Notification Target

This example creates a webhook Notification target that applies a custom format to Notification events before sending them. The response is a JSON object that includes the Notification target configuration and a status object that lists the target’s health and metrics.

Webhook ExampleBody Parameter InformationResponse Example

Create a Notification to Send Alerts

You can create a Notification to get alerts when a scheduled search generates results that match the triggering conditions that you specify.

When you create a Notification, Cribl also adds the Notification details to the search that you specified for savedQueryId. If you retrieve the saved search, its configuration will include the schedule and Notification details.

You must have a saved and scheduled search and a Notification target to create a Notification.

Cribl does not support creating Notification events for searches that reside within Packs.

The following example demonstrates how to create a Notification for a scheduled search based on a custom condition. The response is a JSON object that includes the Notification configuration.

Custom Condition ExampleBody Parameter InformationResponse Example

The following example demonstrates how to create a Notification for a scheduled search based on search results.

Search Results ExampleBody Parameter InformationResponse Example