# Add components to a status page

List what your status page reports on, each following an uptime check or showing a state you set.

A component follows an uptime check or has a state you set by hand, not both. Components with the
same group are shown together. Replace _page-id_ with the status page's id, and the check id in the
examples (`0f8b3c2a-5d1e-4c7b-9a60-2e4f1b7d9c31`) with one of your uptime checks' ids.

| The check is          | The component shows  |
| --------------------- | -------------------- |
| `up`                  | Operational          |
| `regional`            | Degraded performance |
| `down`                | Major outage         |
| `pending` or `paused` | No data              |

A state set by hand is `operational`, `degraded`, `partial_outage` or `major_outage`. An open
incident makes the components it affects at least as bad as its impact (see
[Post an incident](post-an-incident.md)). Under each component that follows a check, the page shows
90 bars of daily uptime and the 90-day percentage, from the check's outage log. The banner at the
top is the worst state on the page.

## Prerequisites

- Permission for `monitoring:UpdateStatusPage` on the page,
  `rn:ews::<organization id>:monitoring:status-page/<page id>`. Without it, the console says "Needs
  monitoring:UpdateStatusPage."
- In the console, also `monitoring:DescribeStatusPages` on the page to open it (without it the page
  is not found), and `monitoring:DescribeChecks` on `rn:ews::<organization id>:monitoring:*` to
  choose a check: without it, only the states set by hand are offered.

## Set the components

The list you save replaces the page's components, in order. A component you leave out is removed.

**Console**
1. Open **Monitoring**, then **Status pages**, and choose the page.
2. Under **Components**, choose **Add component** for each new component.
3. In each row, enter the name and, optionally, a group, and choose what it follows: one of your
   uptime checks, or a state set by hand. The trash button removes a row.
4. Choose **Save components**.

**CLI**
```sh
dcloud monitoring status-pages put-components page-id \
  --components '{"name":"API","checkId":"0f8b3c2a-5d1e-4c7b-9a60-2e4f1b7d9c31"}' \
  --components '{"name":"Support desk","manualState":"operational","groupName":"Back office"}'
```

**API**
```http
PUT /monitoring/api/status-pages/page-id/components
{
  "components": [
    { "name": "API", "checkId": "0f8b3c2a-5d1e-4c7b-9a60-2e4f1b7d9c31" },
    { "name": "Support desk", "manualState": "operational", "groupName": "Back office" }
  ]
}
```

To keep an existing component, send its `id` with it; a component without an `id` is new.

**Terraform**
```hcl
resource "dcloud_status_page" "acme" {
  slug  = "acme"
  title = "Acme status"
  components = jsonencode([
    { name = "API", checkId = dcloud_uptime_check.api.id },
    { name = "Support desk", manualState = "operational", groupName = "Back office" },
  ])
}
```

## Result

The answer lists the saved components in order. A page holds at most 50. A component without a
check and without a state shows Operational; that is also what a component shows after the check it
followed is deleted.

## When the components are refused

- `404` "Check 0f8b3c2a-5d1e-4c7b-9a60-2e4f1b7d9c31 not found" when a `checkId` is not one of your
  organization's checks.
- `400` "components.0: A component follows a check or has a state set by hand, not both", with the
  component's position.

## Related

- [Create an uptime check](create-an-uptime-check.md)
- [Post an incident](post-an-incident.md)
- `monitoring.status-pages.put-components` · `dcloud_status_page`
