# Monitoring queues

See how many messages a queue holds now and over time, in the console, through the API and from an SQS client.

Replace _my-queue_ with the name of your queue. Reading counts needs `queue:ListQueues` for the
list and `queue:GetQueueAttributes` for one queue.

## Counts now

| Count             | Meaning                                                                 |
| ----------------- | ----------------------------------------------------------------------- |
| **Available**     | Receivable now                                                          |
| **In flight**     | Received, not yet deleted, visibility timeout running                   |
| **Delayed**       | Sent with a delay still running                                         |
| **Dead-lettered** | Messages this queue moved to its dead-letter queue that are still there |

**Console**
The queue list shows **Available**, **In flight** and **In the DLQ** for every queue. A queue's
**Overview** shows all four counts under **Messages**.

**CLI**
```sh
dcloud queue queues get my-queue
```

**API**
```http
GET /queue/api/queues/my-queue
```

`messages` holds `available`, `inFlight`, `delayed`, `deadLettered`, `total` and `bytes`.

From an SQS client, `GetQueueAttributes` returns `ApproximateNumberOfMessages`,
`ApproximateNumberOfMessagesNotVisible` and `ApproximateNumberOfMessagesDelayed`.

## Counts over time

The available, in-flight and delayed counts are recorded once a minute from when the queue exists.

**Console**
On the queue's **Overview**, **Messages over time** charts them; choose **1 h**, **3 h**, **24 h**
or **7 days**.

**CLI**
```sh
dcloud queue queues metrics my-queue --hours 24
```

**API**
```http
GET /queue/api/queues/my-queue/metrics?hours=24
```

`hours` is 1 to 336 (14 days), 3 by default. The answer has about 180 points per series:
`periodSeconds` (at least 60) and one series each for `messages_available`, `messages_in_flight`
and `messages_delayed`, each point the highest count in its period.

There are no alarms on queue counts.

## Related

- [Message delivery](message-delivery.md)
- [Where your messages are kept](where-messages-are-kept.md)
