# Monitoring apps

The metrics, alarms, logs, activity and events an app produces, and where to read each.

## Metrics

The app's **Metrics** tab charts its own series and those of each machine. Each finished deployment
records metrics of the app (resource type `app`):

| Metric                    | Point                                 |
| ------------------------- | ------------------------------------- |
| `deploy_duration_seconds` | seconds from queued to live or failed |
| `deploys_succeeded`       | 1, when a deployment goes live        |
| `deploys_failed`          | 1, when a deployment fails            |

The machines are compute instances; their metrics are collected under the instance and shown on
the same tab. Reading metrics needs `monitoring:GetMetricData`, and seeing alarms there
`monitoring:DescribeAlarms`.

## Alarms

Any of these series can carry an alarm. An alarm on `deploys_failed` with statistic `max`, threshold
`>= 1`, a 30-minute period and 2 evaluation periods fires when deploys failed in two half-hours in a
row. See [Monitoring](/docs/monitoring).

## Logs

The app's **Logs** tab shows what the containers print: each machine ships its lines every ten
seconds. The newest line is at the bottom and the view follows it; **Pause** stops following, and
**Lines containing…** filters. Reading logs needs `monitoring:FilterLogEvents`. Over the API,
`GET /monitoring/api/logs?resourceId=<app id>` answers newest first. A container's last lines also
appear when you select it on the **Resources** tab.

## Deployment activity and build logs

Each deployment's **Activity** holds every step, written by the machine itself and by the platform,
including release command output line by line; a repository build adds its **Build log**. See
[Deploy an app](deploy-an-app.md#follow-the-build-log). Each row of **Deployment history** has a
phase bar of how long the deployment waited, built, pushed and rolled out.

## Health, sync and drift

The **Resources** tab shows each machine's health and sync. A machine that stays out of sync for
over a minute after a rollout is written to the app's and the machine's events (phase `drift`). See
[Inspect an app](inspect-an-app.md).

## Events

The default event bus receives `Deployment State Change` from `ews.deploy` when a deployment goes
`live` or `failed`, with `detail.appId`, `deploymentId`, `state`, `error`, `gitCommitSha` and
`imageRef`. For an app served through a load balancer, `ews.deploy` also sends
`Certificate Issuance Failed` when the load balancer's certificate could not be issued, and
`Certificate Renewal Failed` when it could not be renewed while the old one is still served. See
[Event bus](/docs/events).

## Email

A failed, timed-out or lost scheduled-job run emails the organization's owners and admins, at most
once a day per job while it keeps failing; the first failure after a success is emailed at once.

## Related

- [What runs on your machines](what-runs-on-your-machines.md)
