Volume I · Part II · Chapter 6

Built-In Tools

Timothy O’Brien 11 min read Free online

A machine-sizing report recommends a smaller instance. A budget alert says the project is spending too much. The autoscaler wants to create more instances. Before we schedule a meeting to determine which tool has failed, it would help to know what each one was asked.

The sizing report looks back at how a machine was used. The budget alert compares charges with a threshold. The autoscaler reacts to a recent measurement and asks for more resources. All three could be doing their jobs correctly, while none can tell us on its own whether the application will be able to serve the customers it expects next month.

The cloud provider keeps several records about the same machine. One says it exists, one says what it did, and one says what we were charged. A capacity team needs to connect those records when a decision turns on the work the machine was doing.

I’ve changed what I look for in a tool since agents became useful for this sort of investigation. A dashboard can answer the questions its designers anticipated. When the business asks a new one, I want an engineer or an agent to be able to query the data and show the work behind the answer.

How to read this chapter

If you’re trying these tools on a service of your own, take a real discrepancy with you. Reading the bill correctly is a good place to start if the totals don’t reconcile. Recommendations and experiments takes up the harder case, when the report is correct and you still have to decide what to do.

Data we can ask questions of

Google Cloud provides an example of what I want from a provider. You can configure Cloud Billing to export cost and usage data into a BigQuery dataset. BigQuery is a service for storing and querying data, so the cost team can ask questions of the billing records without waiting for someone to build a new report for each question. Google offers a detailed export with resource-level information for supported services; export has to be enabled, and storing and querying the data can incur charges.1

A cost export is the beginning. Suppose you want to know which applications cost more per completed request this month, even though their response times stayed about the same. You would need the billing records, measurements of completed work and response time, and a way to connect those records to the right applications over the period you are comparing. You might then want to know whether the change came from a different workload, a deployment, or a commercial commitment. That takes you into other data again. No single chart can anticipate all the questions that follow from the first answer.

Consider a different kind of investigation: “Show me the systems running in this data center that haven’t been touched in three months, are owned by this project, and are connected to projects where vulnerabilities have been increasing.” Answering that takes more than a cost report. We need to connect the inventory and its location to change history, project ownership and relationships, and vulnerability findings over time. We also need to agree on what “touched” means: a system with no recorded configuration change may still be doing useful work.

An agent can help connect those sources, but it still needs records it can read and compare. In this case, the finding history needs to show what was checked over the same period. A rise in findings could simply reflect a change in what the scanner looked at.

I’d ask for the query and the sources along with the answer. If an agent matches the wrong application or counts a charge twice, fluent prose makes it harder to spot the mistake. Ask the owners about changes the billing records can name but can’t explain.

Azure Resource Graph offers a different query interface, this time for finding resources. The following read-only query asks for virtual machines in the subscriptions visible under a management group, along with their location, size, tags, and reported power state:2

az graph query \
  --management-groups YOUR_MANAGEMENT_GROUP_ID \
  --first 1000 --output json \
  --graph-query "
    Resources
    | where type =~ 'microsoft.compute/virtualmachines'
    | extend p = properties
    | project id, subscriptionId, location, zones, tags,
        vmSize = tostring(p.hardwareProfile.vmSize),
        powerState = tostring(p.extended.instanceView.powerState.code)
    | order by id asc" > vm-inventory.json

For the launch in Chapter 4, I’d use the inventory to see where the sixteen new workers showed up and whether Azure reports them running. Operations still has to show that the new group can carry its share of traffic and stay available when one of the others fails.

I can run the inventory query from a script. Claude Code also documents a programmatic mode that a scheduled job can call.3

Keep three questions distinct: what resources exist, what they did, and what was charged for them. Inventory, monitoring, and billing answer different parts of that story. A machine that disappeared yesterday may still appear on this month’s bill, while a resource that appears unused may be there for recovery.

This result could miss a machine because the caller lacks access, the inventory hasn’t caught up, or the answer needs another page. Microsoft documents all three limits.4 If we’re about to make a decision from the result, I want to know which subscriptions the query covered and when the information was current.

This query asks about virtual machines. Use a different query for managed services and keep the distinction when you add up the results. Tags are helpful when they lead to the person who can explain a surprise on the bill.

Measurements and the work behind them

The provider can tell us a great deal about a machine without knowing much about the application running on it. Azure Monitor, for example, distinguishes measurements from the host from those collected inside the operating system. Azure provides host metrics for CPU and available memory; collecting information from inside the guest requires additional configuration.5

That difference matters when someone asks an agent to find machines with too much memory. Linux can count reclaimable page cache as available memory, even when that cache helps keep a database’s reads away from storage.6 We looked at that problem in Chapter 5. If the agent sees only the provider’s available-memory number, it can find candidates for investigation, but it does not yet know what will happen to the database if memory is removed.

A quiet week can make a machine look unnecessary just before its most important job runs at month-end. Azure’s platform metrics have a finite retention period, so the peak may be gone from the record unless someone kept it.7 Before taking a week’s measurements into a budget discussion, check when the work you care about actually ran.

An efficiency report might tell a team to raise utilization from 33 or 43 percent. A database using its memory to make reads fast and a batch worker that works for a few hours at night may both do their jobs perfectly well at those levels. I’d ask the database owner about response time and the batch owner about the deadline before asking either to change anything.

Start with the measures the specialists already trust. An agent can bring cost records into that investigation and help compare periods, if it can see what the specialists see. A confident score from partial data still leaves the main question open.

If I were shopping for tooling, I’d give each product a real case from the team’s backlog. See how far it can get into the question the business asked, and what the team would need to find out for itself.

Reading the bill correctly

A question about cost sounds simple until we discover that the same purchase can be described in different ways. Chapter 1 distinguishes what arrives on an invoice from the cost assigned to the period that uses a commitment. Azure can export both views, including in a format based on the FinOps Open Cost and Usage Specification, known as FOCUS.8

Take a constructed example. A team pays $36,000 in March for a one-year virtual-machine reservation. If we spread that purchase evenly, the effective cost is $3,000 a month: $36,000 divided by 12. The March invoice shows the purchase, while the monthly view spreads the cost across the year.9 Both are useful. Finance may need to know when the money was billed; a team comparing monthly workload costs may need the second view. Adding them together would count the same purchase twice.

Suppose a machine costs $1,000 and our ownership list has three rows that match it. Join the lists and sum all three rows and you have a $3,000 machine on paper. If three teams share the cost, agree on shares that add to $1,000. If the owner is unclear, leave the charge open for the team that can resolve it.

Azure exports can repeat the month to date in each snapshot.10 If Monday’s export already includes Sunday, adding the files together charges Sunday twice. Keep the dates, credits and corrections visible so another person can trace the result back to the bill.

Recommendations and experiments

Cloud providers can suggest resources to resize or shut down. Azure Advisor, for example, bases its recommendations on a period of resource measurements and makes assumptions about how the machine is used. Its estimated savings also use retail rates rather than the organization’s particular reservations or savings plans.11

Taking a list of supposedly oversized systems to the teams responsible for them often got a fair response: you don’t know what this system does. A quiet database might be keeping reads in memory or waiting for a rebuild it has to finish before customers return. Those are questions for the application team even when the provider’s numbers look convincing.

For a stable service, we may be able to try a smaller configuration on part of the workload, compare its performance with the existing one, and return to the old configuration if the test fails. A database may need a longer test that includes maintenance or recovery, not just ordinary traffic. If the smaller system serves requests but cannot complete a required rebuild, it provides a different service. The business may choose that trade, but it should know what it is choosing.

If an agent reviews recommendations each morning, teach it to carry the answer forward. Suppose the database owner shows why the cache is needed. Keep that explanation and the measurements together and check them again when the workload changes, so the owner doesn’t have to defend the same machine every morning.

Once the team has seen a class of change work reliably, it can authorize the system to make it and check the result. A decision that depends on a customer promise still needs the person who made it.

Alerts, controls, and automation

An alert tells someone that a condition has been met. A control changes what the system can do. The two are easy to confuse when both are called a budget.

An Azure budget can notify people when actual or forecast costs cross a threshold, but Microsoft says the budget itself does not stop consumption. The notification can be connected to automation, which must be designed to decide what action to take.12

A billing alert may arrive too late to stop work at a limit, and it can react to a reservation purchase when day-to-day usage hasn’t changed.13 If a job must stop admitting requests at a threshold, put the control where it admits requests.

Some provider controls really can stop resources, though their scope differs. Azure’s spending limit applies to certain subscriptions with credits, not every paid subscription. AWS budget actions and Google Cloud spend caps have their own eligible actions and limits.1415 Before depending on one, establish what it can stop and what continues to incur charges.

If the operations team knows how to stop an idle development machine safely, it can authorize that action and make the result visible. On a shared production service, the same team might let the system pause optional work and ask for a decision about the rest.

Agree in advance what the tool can change and what to do if the data is stale or it can’t tell whether the action worked. The people on duty need enough of its record to understand and correct what happened. As the team learns which actions it can rely on, it can widen that authority.

Autoscaling asks for capacity

When the autoscaler asks for more instances, the number it wants is the start of the investigation.16 What matters to the service is how many instances arrived in time and began doing useful work.

A cloud account may have a quota that permits a certain amount of a resource. That permission does not mean the provider has the requested machines available in the desired location at the moment we need them. Azure checks quota and capacity separately, and it reports different errors when a request exceeds quota or when it cannot allocate the requested resource.1718 An automated response needs to know which problem it is facing: asking for a quota increase will not create machines in a location that lacks supply.

Even after a machine is allocated, it may need preparation before it can do useful work. Our constructed portfolio gives borrowed workers two days for preparation and testing; the new workers need longer. Raising an autoscaler’s maximum does not make either group ready sooner. At scale, several teams may also plan to use the same available pool. If each assumes it can draw on the whole pool at once, individually sensible plans can make a promise the shared supply cannot keep.

A capacity reservation can hold Azure supply when it is available, and it incurs a charge from the time it is created.19 Volume II, Chapter 18 discusses its use for recovery, and Volume II, Chapter 20 distinguishes a capacity reservation from a pricing commitment. Here I want the system that watches scaling to keep track of what was requested, what was allocated, and what became usable. If those diverge, we need to know before the application discovers the shortfall on its own.

From an answer to an action

I’d try these tools on the web service’s launch. Can we see whether the new workers are ready, how much we’ve begun paying for them, and what happens to the queue once they take traffic? That’s a better conversation with the operators than sending another report that says the machine count went up.

The companion’s examples/capacity_portfolio/run.py generates a synthetic review without cloud credentials. It shows how evidence and decisions can be connected; it does not implement a cloud agent or make changes to a live system. A real organization will need its own data, permissions, controls, and specialists.

Notes and sources

  1. Google Cloud, “Export Cloud Billing data to BigQuery”, checked November 14, 2026. Billing exports are enabled by type; detailed export includes resource-level data for supported services. BigQuery storage and analysis can incur charges. Data availability and history depend on export configuration.↩︎

  2. Microsoft Learn, “Overview of Azure Resource Graph”, “Work with large data sets”, “Understand the query language”, and “az graph”, checked October 4, 2026. Results are limited by permissions, can lag changes, and require pagination beyond the per-request limit. The power-state property follows Microsoft’s VM sample queries. This query was checked against documentation, not run against a live account; az graph requires the Resource Graph CLI extension.↩︎

  3. Anthropic, “Run Claude Code programmatically”, checked November 14, 2026. The documented non-interactive mode can be called from a script; access to cloud data and authority to make changes depend on the tools and permissions configured for the run.↩︎

  4. Microsoft Learn, “Overview of Azure Resource Graph”, “Work with large data sets”, “Understand the query language”, and “az graph”, checked October 4, 2026. Results are limited by permissions, can lag changes, and require pagination beyond the per-request limit. The power-state property follows Microsoft’s VM sample queries. This query was checked against documentation, not run against a live account; az graph requires the Resource Graph CLI extension.↩︎

  5. Microsoft Learn, “Monitor virtual machines with Azure Monitor” and “Supported metrics - Microsoft.Compute/virtualMachines”, checked October 4, 2026. Host metrics and guest collection have different sources and configuration requirements.↩︎

  6. Linux kernel documentation, “The /proc Filesystem”, checked October 4, 2026. MemAvailable is estimated from free memory and reclaimable resources including file caches; check a provider metric’s own definition before treating it as equivalent.↩︎

  7. Microsoft Learn, “Metrics in Azure Monitor”, checked October 4, 2026. Platform metrics have a 93-day retention period; moving or renaming a resource may affect its history.↩︎

  8. Microsoft Learn, “Tutorial - Create and manage Cost Management exports” and “Cost Management dataset schema index”, checked October 4, 2026. Actual, amortized and FOCUS datasets, per-run files, and the option to retain daily month-to-date export runs instead of overwriting them.↩︎

  9. FinOps Foundation, FOCUS Specification and the version 1.2 EffectiveCost definition, checked October 4, 2026. A purchase covering future charges carries zero effective cost; the reservation example and even monthly allocation are constructed for illustration.↩︎

  10. Microsoft Learn, “Tutorial - Create and manage Cost Management exports” and “Cost Management dataset schema index”, checked October 4, 2026. Actual, amortized and FOCUS datasets, per-run files, and the option to retain daily month-to-date export runs instead of overwriting them.↩︎

  11. Microsoft Learn, “Optimize virtual machine (VM) or virtual machine scale set (VMSS) spend by resizing or shutting down underutilized instances”, checked October 4, 2026. The documented lookback, assumptions, exceptions, and retail-rate estimates should be checked against the version in use.↩︎

  12. Microsoft Learn, “Tutorial - Create and manage budgets”, checked October 4, 2026. Budgets notify rather than directly stop consumption; data and evaluation are delayed, purchases are included in actual cost, and action groups can connect notifications to automation at supported scopes.↩︎

  13. Microsoft Learn, “Tutorial - Create and manage budgets”, checked October 4, 2026. Budgets notify rather than directly stop consumption; data and evaluation are delayed, purchases are included in actual cost, and action groups can connect notifications to automation at supported scopes.↩︎

  14. Microsoft Learn, “Azure spending limit”, checked October 4, 2026. Eligible subscription types and the effect of reaching the limit.↩︎

  15. AWS, “Configuring budget actions”, and Google Cloud, “Manage spend cap budgets” (Preview; updated September 30, 2026), checked October 4, 2026. The providers’ controls have different scopes, actions, and timing.↩︎

  16. Microsoft Learn, “Understand autoscale settings in Azure Monitor”, checked October 4, 2026. Metric rules, capacity limits, and cooldown.↩︎

  17. Microsoft Learn, “Check vCPU quotas” and “Resource quota errors”, checked October 4, 2026. Quota and available capacity are separate checks.↩︎

  18. Microsoft Learn, “Troubleshoot allocation failures when you create or resize VMs in Azure”, checked October 4, 2026. Allocation failures and possible remedies.↩︎

  19. Microsoft Learn, “On-demand capacity reservation in Azure”, checked October 4, 2026. Creation requires quota and capacity; reserved capacity is billed whether or not it is used.↩︎