# Find resources to save on

List the machines, databases, volumes and addresses that cost money without doing much, with the evidence, the monthly saving and the action, and keep the ones you need.

Findings are computed each time you ask, from the last 14 days of monitoring and the current price
list. The saving is per month, after your discounts and before VAT.

## Prerequisites

- Permission for `billing:GetCostAndUsage`. Without it, **Savings** shows an access-denied notice.
- `billing:DismissCostFinding` to keep a finding or bring it back. Without it, the console offers
  no **Keep**.
- To act on a finding, the action's own permission on the resource (for example
  `ec2:StopInstances`): the action runs with your own credentials and is in the audit log as yours.

## What is found

| Finding                      | When                                                                                                                        | Action                            |
| ---------------------------- | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
| Idle machine                 | Running, with CPU averaged under 2 % and no 5-minute sample above 10 % over the last 7 or more days                         | **Stop**                          |
| Oversized machine            | 7 or more days of CPU samples, and a smaller size of the same family fits its 95th-percentile CPU with 1.5× headroom        | Resize to the size named          |
| Oversized database           | Every node's 95th-percentile CPU under 10 % per vCPU for 7 or more days, and the next smaller class fits with 1.5× headroom | Change the class to the one named |
| Stopped server, still billed | Stopped for 7 or more days while its attached volumes keep billing                                                          | **Terminate**                     |
| Unattached volume            | Attached to nothing for 7 or more days, or never attached and older than 24 hours                                           | **Delete volume**                 |
| Unused elastic IP            | Associated with nothing for 24 hours or more                                                                                | **Release**                       |

A machine that publishes the custom metric `mem_used_percent` with the dimension `InstanceId` is
also judged on its 95th-percentile memory, with 1.3× headroom. Without it, an oversized machine is
marked **check first**. Databases are judged on CPU only, one class smaller at most. While elastic
IPs are metered but not charged, their finding saves nothing on your bill.

## See and act on findings

**Console**
1. Open **Savings**.
2. (Optional) Choose a kind to see only those findings.
3. Choose the finding's action button, then confirm it.

The confirmation names the API operation it runs. **How findings are made** spells out every rule.

**CLI**
```sh
dcloud billing savings list
```

Each finding names its action as an API operation with method, path and body; run that operation
yourself.

**API**
```http
GET /billing/api/cost-findings
```

## Keep a finding

Keeping a finding takes a reason, which everyone sees with your name, and removes it from the list
and the monthly report, for good or until a date.

**Console**
1. Open **Savings**, then choose **Keep** on the finding.
2. For **Reason**, enter why it stays, at least 3 characters.
3. For **For**, choose **Good** or **90 days, then ask again**.
4. Choose **Keep it**.

To undo, open **Kept**, then choose **Bring back**.

**CLI**
```sh
dcloud billing savings dismiss --key idle-machine:ec2_instance/i-0123456789abcdef0 \
  --reason "Disaster recovery standby"
```

**API**
```http
POST /billing/api/cost-findings/dismiss
{ "key": "idle-machine:ec2_instance/i-0123456789abcdef0", "reason": "Disaster recovery standby" }
```

A finding's `key` is in the list. Keeping a key again replaces its reason and date. Bringing back a
key that was not kept answers `404`.

## Related

- [Explore costs](explore-costs.md)
- [Get the monthly cost report](get-the-monthly-cost-report.md)
- `billing.savings.list` · `dcloud billing savings list`
