﻿---
title: Manage what detection monitors
description: Turn on detection, choose the logs that Elastic nightshift learns from and watches, and manage your sources over time.
url: https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9660/solutions/observability/nightshift/detection/sources
products:
  - Elastic Cloud Serverless
  - Elastic Documentation
  - Elastic Observability
applies_to:
  - Serverless Observability projects: Preview
---

# Manage what detection monitors
Tell Elastic nightshift which logs to learn from and watch for problems. Start with all your logs in one step, or narrow detection down to the services you care about most.
Each set of data that detection watches is a *source*. Detection is optimized for logs. Sources can also select metrics or traces, but in Tech Preview, results are best with logs. You choose sources when you turn detection on, and you can add, change, pause, or remove them at any time.

## Before you begin

- An admin has [enabled Elastic nightshift](/elastic/docs-content/pull/9660/solutions/observability/nightshift/get-started#nightshift-get-started-enable).
- You have the privileges to manage detection sources. Refer to [Grant access](/elastic/docs-content/pull/9660/solutions/observability/nightshift/privileges#nightshift-privileges-admin).
- Your project has recent logs, or can reach them through cross-project search.


## Turn on detection

To turn on detection, follow the detection steps in [Get started](/elastic/docs-content/pull/9660/solutions/observability/nightshift/get-started#nightshift-get-started-detection). To watch only some of your logs from the start, [create a source](#nightshift-detection-sources-create) first, then select it when you enable detection. **All logs** watches all your logs with the query `FROM logs*`.
Elastic nightshift starts to learn from each source right away. Refer to [How long learning takes](/elastic/docs-content/pull/9660/solutions/observability/nightshift/detection/learning#nightshift-detection-learning-warmup).

## What a source is

A source is an ES|QL query that selects rows of data, and nothing else. The query must:
- Start with `FROM` or `TS`.
- Contain only `WHERE` commands after that. Commands that change the rows, such as `STATS`, `EVAL`, or `KEEP`, aren't allowed.
- Select one kind of data. Elastic nightshift derives the kind of data, such as logs or metrics, from the index names. A query that mixes kinds is rejected. For example, `FROM logs-*, my-app-*` is rejected because `my-app-*` isn't recognized as logs. A wildcard for everything, such as `*`, is also rejected.

Sources apply to detection only. Investigations don't need a source. They query all the logs, metrics, and traces that your connectors reach.
For example:
- All your logs: `FROM logs*`
- The services of one application:
  ```esql
  FROM logs-*
  | WHERE service.name IN ("inventory-api", "web", "ticket-issuer")
  ```
- One environment:
  ```esql
  FROM logs-*
  | WHERE deployment.environment == "production"
  ```

Each source is learned separately, and cost grows with the number of sources. Start with **All logs**. Add narrower sources when you want detection to focus on a part of your system.
<note>
  Detection reads data from all projects linked through cross-project search, whatever project scope is configured for this space.
</note>


## Create a source

To create a source from the **Detections** page:
1. At the top of the **Detections** page, select **Sources**, then select **Create source**.
2. Enter a **Title**. Optionally, add a **Description** and **Tags**.
3. In **ES|QL query**, write the query for the logs to watch. To have the query written for you, enter a `//` comment that describes the data, then press <kbd>Cmd</kbd> + <kbd>j</kbd>.
4. Select **Run query**. Check the rows in **Data preview**.
5. Keep **Enabled** on, so that Elastic nightshift starts to learn from the source right away.
6. Select **Create source**.

The source appears in the list, and learning starts. On the **Detections** page before detection is on, the same form ends with **Add source** instead.

## Manage sources

To open the list, select **Sources** at the top of the **Detections** page. Search by title, tag, or query.
The list has the following columns:
- **Title**, **Query**: The name of the source and its ES|QL query.
- **Enabled**: Whether detection learns from and watches this source.
- **Events**: How many results the source's rules produced in the last 24 hours.
- **KI Queries**, **KI Features**: How many query KIs and feature KIs Elastic nightshift extracted from the source. Refer to [How detection learns your system](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9660/solutions/observability/nightshift/detection/learning).
- **Status**: A green check if the source works. A red X if Elastic nightshift hit an error. Hover over the X to read the error.

To work with a source:
- **Change it.** Select its title, change the fields in **Edit source**, and select **Save**. If you change the query, the source's KIs and rules no longer match it, so Elastic nightshift deletes them and learns the source again. Confirm with **Save and reset knowledge**.
- **Learn from it again now.** Select **Onboard source** in its row. To stop a run, select **Stop source onboarding**. For several sources, select them and then **Generate**. To run only one step, open the menu next to **Generate** and select **Generate KI Features** or **Generate KI Queries**.
- **Look for significant events now.** Select **Find significant events** to run discovery without waiting for the next scheduled run. To stop it, open the menu next to the button and select **Cancel**.
- **Pause it.** Turn off **Enabled**.
- **Delete it.** Select the delete icon in its row, then **Delete source**. This deletes the source, its KIs, and its rules. Significant events that detection already found are kept, and the daily stale event cleanup marks them **Inactive**.

Runs that you start yourself don't count toward the daily run limits. If you delete your last source, detection stops and the **Detections** page shows only earlier results.
To pause all detection instead of one source, go to **Settings** → **Detections** and select **Pause detection engine**. Refer to [Settings and limits](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9660/solutions/observability/nightshift/settings).

## Next steps

- [How detection learns your system](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9660/solutions/observability/nightshift/detection/learning): Find out what Elastic nightshift extracts from your sources and how long it takes.
- [Review significant events](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9660/solutions/observability/nightshift/detection/significant-events): Review what detection finds and investigate it.
- [Settings and limits](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/9660/solutions/observability/nightshift/settings): Set run limits and continuous learning, or pause detection.