﻿---
title: Automatically investigate your alerts
description: Create an Elastic nightshift automation that investigates each matching alert when it fires and posts the findings to a Slack channel.
url: https://www.elastic.co/elastic/docs-builder/docs/4922/solutions/observability/nightshift/use-cases/auto-investigate-alerts
products:
  - Elastic Cloud Serverless
  - Elastic Documentation
  - Elastic Observability
applies_to:
  - Serverless Observability projects: Preview
---

# Automatically investigate your alerts
Elastic nightshift can automatically investigate your alerts using automations. An automation starts an investigation when an alert matches the conditions you set up, and posts the findings to Slack, giving the on-call engineer a head start on fixing the problem.

## Before you begin

- An admin has [enabled Elastic nightshift](/elastic/docs-builder/docs/4922/solutions/observability/nightshift/get-started#nightshift-get-started-enable).
- You have the privileges to create automations. Without them, you can only view automations. Refer to [Grant access](/elastic/docs-builder/docs/4922/solutions/observability/nightshift/privileges#nightshift-privileges-admin).
- The alert rules that you want to investigate are in the same project as Elastic nightshift. For alerts from other tools, refer to [Investigate alerts from your other tools](https://www.elastic.co/elastic/docs-builder/docs/4922/solutions/observability/nightshift/use-cases/external-alerts).
- An admin has connected the Slack channel you want to send investigation results to. Refer to [Set up Slack](/elastic/docs-builder/docs/4922/solutions/observability/nightshift/investigation/set-up#nightshift-set-up-slack).

Before setting up automations, run some investigations to familiarize yourself with the process and the results. Refer to [Investigate your alerts](https://www.elastic.co/elastic/docs-builder/docs/4922/solutions/observability/nightshift/use-cases/investigate-alerts).

## Example: Critical checkout alerts

Your checkout alert rules have the tag `checkout`. You want every **Critical** alert from them investigated, with the findings posted to `#checkout-oncall`.
The process looks something like this:
1. A rule tagged `checkout` fires an alert with severity **Critical**.
2. The automation checks that the alert matches and that no daily limit is reached.
3. Elastic nightshift starts an investigation and posts a message in `#checkout-oncall`.
4. When the investigation finishes, Elastic nightshift updates that message with the impact, the conclusion, and the hypotheses.


## Create the automation

For this process to work, you need to first create the automation that fires under this scenario:
1. On the Elastic nightshift home page, select **Automations** → **Create automation**.
2. Enter a **Name**, for example `Investigate critical checkout alerts`. Optionally, add a **Description** and **Tags**.
3. Under **Trigger**, select **Add trigger** → **Alert triggered**. The trigger reads as a sentence: **When an alert** from **Any rule** from **any source** changes to **Active** with severity **Any severity**.
4. Select **Any rule**, select one of the following:
   - Select a tag, such as `checkout`. Every rule with that tag is selected, including rules that you add later.
   - Select individual rules by name.
5. Optionally, select **any source** to limit where alerts come from: **Classic** rules, **Universal rules**, **Significant events**, or **External sources**.
6. Select **Any severity** and select the alert severity that you want to trigger an investigation. Only the severities that the selected rules support are available. Elastic nightshift checks the severity once, when the alert becomes active; later changes don't start an investigation.
7. Set the **Daily trigger limit**. Refer to [Daily trigger limit](/elastic/docs-builder/docs/4922/solutions/observability/nightshift/investigation/automations#nightshift-automations-daily-limit).
8. Optionally, in **Additional Instructions**, tell Elastic nightshift about these services. Refer to [Point Elastic nightshift to your runbooks and code](#nightshift-uc-auto-instructions).
9. Under **Notifications**, select **Add notification** → **Post in Slack**. Search for and select the Slack channel you want to send investigation results to. If no channels are listed, select **Connect channels in Settings**.
10. Select **Save and enable**. To save an automation, but leave it turned off, select **Save**.

The automation now appears on the **Automations** page with **Enabled** on. To pause it, turn off **Enabled**.

## Check the deployment-wide limits

Deployment-wide limits apply on top of the automation's own limit, and the lowest limit wins. Refer to [How a start is checked](/elastic/docs-builder/docs/4922/solutions/observability/nightshift/investigation/limits#nightshift-limits-check).

## Point Elastic nightshift to your runbooks and code

Each investigation that the automation starts reads its **Additional Instructions**, up to 5,000 characters. Include information like:
- **Where things live**: the GitHub repositories for the services and their deployment configuration.
- **Runbooks**: links to the runbooks for these alerts, and the checks your team does first.
- **Ownership**: who owns each service and its dependencies.
- **What's normal**: known noisy periods, planned jobs, or dependencies that often cause trouble.

For the checkout alerts in the example scenario, you might add something like:
```text
Checkout runs on the web service and calls inventory-api, which uses the
Postgres encore database. Code: github.com/example/web and
github.com/example/inventory-api. Helm charts are in deploy/helm.
Runbook: https://wiki.example.com/runbooks/checkout.
The payments team owns web; the inventory team owns inventory-api.
A reconcile-batch job runs every hour on the hour and can hold row locks.
```


## Check what the automation did

On the **Automations** page, select the automation, then **Run history**. A skipped run shows why. Refer to [Check what an automation did](/elastic/docs-builder/docs/4922/solutions/observability/nightshift/investigation/automations#nightshift-automations-run-history).

## Other triggers

To start from a schedule or a Slack message instead, refer to [Triggers](/elastic/docs-builder/docs/4922/solutions/observability/nightshift/investigation/automations#nightshift-automations-triggers). For alerts that another tool posts in Slack, refer to [Investigate alerts from your other tools](https://www.elastic.co/elastic/docs-builder/docs/4922/solutions/observability/nightshift/use-cases/external-alerts).

## Best practices

- **Start narrow.** Begin with a few rules that fire a few times a day and matter to someone. Widen it when the results are useful.
- **Read the first results.** Check the hypothesis tree of the first investigations, and improve the instructions where Elastic nightshift looked in the wrong place.
- **Expect one investigation per alert.** A new alert from the same rule starts its own investigation, and automations can't group repeat firings into one. Refer to [Each problem has one investigation](/elastic/docs-builder/docs/4922/solutions/observability/nightshift/investigation#nightshift-investigations-dedup).
- **Edit the automation, not its workflow.** Changes apply from the next trigger. Refer to [The workflow behind an automation](/elastic/docs-builder/docs/4922/solutions/observability/nightshift/investigation/automations#nightshift-automations-workflow).


## Next steps

- [Investigate in Slack](https://www.elastic.co/elastic/docs-builder/docs/4922/solutions/observability/nightshift/use-cases/investigate-in-slack): Ask follow-up questions in the results thread.
- [Detect problems your alerts miss](https://www.elastic.co/elastic/docs-builder/docs/4922/solutions/observability/nightshift/use-cases/detect-problems): Find problems that no alert catches, and investigate them with an automation too.
- [Automations](https://www.elastic.co/elastic/docs-builder/docs/4922/solutions/observability/nightshift/investigation/automations): Manage, clone, and delete automations, and read every setting.
- [Investigation limits](https://www.elastic.co/elastic/docs-builder/docs/4922/solutions/observability/nightshift/investigation/limits): Set the daily limits for your deployment.