# Monitoring Container registry

React to pushes, deletes, scans, pull-through fills, signature checks and refused pushes through your event bus.

The registry puts its events on your organization's [event bus](/docs/events) with `source`
`ews.ecr`, under AWS ECR's EventBridge names and fields, so a rule written for ECR reads the same.

## Events

| `detail-type`                   | When                                                                                                                  | `detail`                                                                                                                  |
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| `ECR Image Action`              | An image is pushed, or deleted (also when a lifecycle rule deletes it with `softDeleteDays` 0 or its image is purged) | `action-type` (`PUSH`, `DELETE`), `result`, `repository-name`, `image-digest`, `image-tag`, `initiated-by`                |
| `ECR Image Scan`                | A scan finished                                                                                                       | `scan-status` (`COMPLETE`, `FAILED`), `repository-name`, `image-digest`, `finding-severity-counts`, `error` (when failed) |
| `ECR Pull Through Cache Action` | A pull brought an image in from an upstream                                                                           | `repository-name`, `upstream-registry-url`, `upstream-repository-name`, `image-reference`, `image-digest`                 |
| `ECR Image Signature Check`     | A deployment checked an image against the signing policy                                                              | `result` (`allowed`, `denied`), `reason`, `appId`, `deploymentId`, `image`                                                |
| `ECR Storage Quota Exceeded`    | A push or a pull-through cache fill was refused by a storage quota                                                    | `repositoryName`, `scope`, `usedBytes`, `limitBytes`, `addingBytes`                                                       |
| `ECR Expired Image Pulled`      | Something pulled an image a lifecycle rule deleted (at most once an hour per image)                                   | `repositoryName`, `reference`, `digest`, `expiredAt`, `purgeAfter`                                                        |

A tag deleted while other tags still point at the image, a tag deleted through the registry
protocol, and a deleted repository emit no `ECR Image Action`.

## Webhooks

A webhook is an event bus rule with an HTTPS target: it is signed (`X-EWS-Signature-256`, an HMAC
of `X-EWS-Timestamp` and the body with the rule's secret), retried, sent to the target's
dead-letter queue when it keeps failing and the target has one, and every delivery is logged. For example, every push of a release tag:

```json
{
  "source": ["ews.ecr"],
  "detail-type": ["ECR Image Action"],
  "detail": { "action-type": ["PUSH"], "image-tag": [{ "prefix": "v" }] }
}
```

A queue or a function target works the same way. See [Events](/docs/events).

## In the console

- A repository's **Images** tab shows each image's scan state; **Scans** lists the latest scan of
  every image.
- **Storage** shows what the registry stores and when layer cleanup last ran.

## Related

- [Scan an image](scan-an-image.md)
- [Storage and cleanup](storage-and-cleanup.md)
