# Monitoring Compute

Instance metrics and alarms, OS patch state, stock-out events and metrics, and where errors are shown.

## Instance metrics

An instance's **Monitoring** tab shows its metrics and alarms. Reading them needs
`monitoring:GetMetricData` and `monitoring:DescribeAlarms`; see [Monitoring](/docs/monitoring).

## OS patches

An instance launched with **Keep OS patched** shows **OS patches** on its **Overview**; the API is
`GET /ec2/api/instances/{id}/patch-state`. See [Keep the OS patched](keep-the-os-patched.md).

## Errors

Where the Deutsche Cloud Console shows that something went wrong:

- An instance action that fails shows **The action failed.** with the error at the top of the
  instance's page. An instance waiting for a host shows **Waiting for capacity.**
- A snapshot policy whose last run failed shows **Last run:** and the error under the policy.
- A volume snapshot that failed shows its error in the snapshot list; the API returns it as
  `error`.
- A machine image whose snapshot never finished has the state `failed` and cannot launch anything.

## Stock-outs

Every create refused for stock, by the check before buying or by the provider, is reported two
ways:

- an `Insufficient Capacity` event (source `ews.capacity`) on your default event bus, with the
  provider's machine type (`cpx22` for `performance-2`), zone, resource, message, the alternatives
  in stock and what happens next. A
  resource that keeps asking (an auto scaling group, a node group) raises it once, until the type is
  back;
- a count in the metric `EWS/Capacity InsufficientCapacityErrors`, once per refusal, per
  `InstanceType` (the provider's machine type) and `AvailabilityZone`, and once with no dimensions for your organization's
  total. Put an alarm on the total (`> 0`, sum over a minute) to hear about any stock-out.

When a type you were refused is back in that zone, a `Capacity Available` event names the type, the
zone and the resources that were refused it. Match either with an event rule
(`{"source": ["ews.capacity"]}`) to page someone or start a function; see [Events](/docs/events).

## Related

- [Check stock before you launch](check-stock.md)
- [Troubleshooting](troubleshooting.md)
