# Security events

> Every alert from your realm's devices, searchable and filterable over any time range in the last 30 days, with an overview of devices by status and alerts by level.

Security events are the alerts the realm raises from what your devices' sensors send: a burst of failed sign-ins, a
changed system binary, a failed hardening check. You search them over any time range, narrow them by device, field or
text, and see each one with its rule, its level, its description, and what it means in ATT&CK and compliance terms.

## Before you begin

- **Who:** an administrator of the realm, in a group holding `RealmOwner` or `RealmViewer` on the realm or a realm
  above it (see [Delegated administration](../../../platform/realms/delegated-administration/)). Reading needs no
  more than `RealmViewer`.
- **Where:** the API.
- **First:** at least one enrolled device; alerts start arriving as soon as it does.

## How it works

Each alert carries the device it came from, the rule that raised it, a level from 0 to 15, the rule's groups, and
the ATT&CK techniques and compliance controls it touches. Some alerts come from a pattern rather than one event:
repeated failed sign-ins on one device, for example, raise an alert of their own at a higher level. Patterns are
found within one device's events; nothing correlates events across devices.

### Alert levels

The higher the level, the more it matters. The overview and the summary group levels into three bands.

| Level | Band | What it usually means |
|---|---|---|
| 0 to 3 | Low | Routine: a service started, a successful sign-in, a scan finished |
| 4 to 6 | Low | Worth knowing: an error, a single failed sign-in, a request refused |
| 7 to 11 | Medium | Worth a look: a monitored file changed, a hardening check failed, repeated failures |
| 12 to 15 | High | Act now: a pattern that points to an attack, or signs of tampering |

### Slices

Some views are a slice of the same alerts, named by a `preset`: `fim` (file changes), `sca` (configuration
assessment), `vulnerabilities`, and `mitre` (every alert naming an ATT&CK technique). Each slice adds its own fields
to filter on.

## Set it up

Nothing to turn on. Through the API ([Call the API](../../../develop/api/)), read the overview (devices by status, and
alerts over the range by level), then a page of one device's alerts:

```sh
curl "https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/overview?from=<RFC 3339 time>&to=<RFC 3339 time>" \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"

curl "https://foobar.cvyuh.com/api/v0/endpoint/dar/v1/events?agent=<sensor id>&from=<RFC 3339 time>&to=<RFC 3339 time>" \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
  -H "Content-Type: application/json" \
  -d '{"page": 1, "pageSize": 20}'
```

In the query: `from` and `to` (RFC 3339; left out, the last day), `agent` (the device's sensor id) and `preset`. A
page answers `data`, `totalPages` and `totalCount`; each alert's fields are in the [API reference](../../api/#security-log).

### Filter, search and sort

The body takes paging, a sort, free text and a filter. This asks for medium and high alerts from one address, those
whose text mentions `sshd`, highest level first:

```json
{
  "page": 1,
  "pageSize": 50,
  "sort": { "column": "level", "order": "desc" },
  "qbe": {
    "text": "sshd",
    "filter": {
      "type": "and",
      "rules": [
        { "field": "level", "op": ">=", "value": 7 },
        { "field": "sourceIp", "op": "=", "value": "203.0.113.24" }
      ]
    }
  }
}
```

- **`filter`** is a rule (`field`, `op`, `value`) or a group (`type` of `and`, `or` or `not`, and its `rules`, which
  may be groups again; `not` takes exactly one).
- **Fields:** `time`, `agentId`, `agentName`, `agentIp`, `rule`, `level`, `description`, `groups`, `mitre`, `tactic`,
  `location`, `decoder`, `sourceIp`, `sourceUser`, `user`, `log`. A preset adds its own: `GET .../events/fields`
  (with `preset=`) lists them all, with their kinds.
- **Operators:** on text, `=`, `!=`, `in`, `not in`, `like` and `not like` (`%` for any run of characters, `_` for
  one), `contains`; on numbers, `=`, `!=`, `in`, `not in`, `>`, `>=`, `<`, `<=`, `between` (`[low, high]`, either may
  be `null`); on times, `>`, `>=`, `<`, `<=`, `between`; on any field, `is null` and `is not null`.
- **`text`** matches, ignoring case, anywhere in the device name, rule, description, location, addresses, users and
  the log line.
- **`sort`** takes a field and `asc` or `desc`; the default is `time`, newest first.

`POST .../events/summary` takes the same body and counts the range: by band over time, by rule group, by rule, and
failed and successful sign-ins.

## Limits and defaults

| Limit | Value |
|---|---|
| Retention | 30 days from when an alert is written, then deleted |
| Default range | The last day |
| Page size | 20 by default, up to 100 |
| Deepest page | The first 10,000 alerts of a search; narrow the range or the filter to reach further |
| Top lists in the overview and summary | 10 |

## What happens when it fails

| Answer | Why | What to do |
|---|---|---|
| `400` "is not RFC 3339" | A `from` or `to` that isn't a full RFC 3339 time | Write it as `2026-12-01T00:00:00Z` |
| `400` "from must be before its to" | The range is empty or backward | Swap or widen it |
| `400` naming a field | A field the slice doesn't have, or an operator its kind doesn't take | Check `GET .../events/fields` |
| `400` "only the first 10000 documents page" | The page starts past the deepest page | Narrow the range or the filter |
| `403` | Your session doesn't administer the realm | Ask for `RealmOwner` or `RealmViewer` on it |

## Good to know

- **Alerts are what's kept.** A log line or event that matches no rule raises no alert and isn't kept; keeping every
  event is [planned](../whats-next/#every-event-kept).
- **Keep alerts past 30 days by exporting them.** Page through `POST .../events` over each day's range and store the
  answers where you keep records. Setting your own retention is [planned](../whats-next/#retention-set-per-realm).
- **Your realm only.** Every search sees your realm's events and no other's; see [One log per realm](../realm-isolation/).
- **The shipped ruleset.** Alerts come from the ruleset the realm ships; your own rules are
  [planned](../../detection/whats-next/#custom-detection-rules).

## Troubleshooting

| Symptom | Cause | Fix |
|---|---|---|
| A device shows no alerts | It's quiet, offline, or outside the range | Widen the range; check its status in the [device view](../device-view/) |
| An event you expected isn't there | It matched no rule, so no alert was raised | Check the device's logs are read ([Log collection](../../detection/log-collection/)) |
| Alerts older than 30 days are gone | Retention | Export what you need to keep before then |

See [Detection & Response troubleshooting](../../troubleshooting/) for more.

## Audit record

Searching the log writes no audit record.

## Related

- [Device view](../device-view/): one device, from every side.
- [Handle an alert on a device](../../guides/handle-an-alert/): act on an alert.
- [Threat mapping](../../detection/threat-mapping/): alerts over the ATT&CK matrix.
