Reference
Google Cloud
Reads only Google Cloud answers: which data has arrived, resources by type, region and project, idle resources, label coverage, utilization, budgets, and what LevelFour's service account can read.
These methods read what LevelFour knows about your Google Cloud estate beyond the bill: resources, utilization, budgets and access. Cost, recommendations and savings for Google Cloud use the same methods as every other provider, with gcp as the provider ID; Costs covers the credits basis they take. Any key can call these reads. The examples show the Go SDK and plain HTTP.
Methods
| Method | Returns |
|---|---|
| Get data availability | Which Google Cloud datasets hold data for your organization |
| Get inventory breakdown | Resource counts by type, region or project |
| Get waste signals | Resources that bill while doing nothing |
| Get label hygiene | How many resources carry the labels you care about |
| Get utilization | Utilization bands for VMs, Cloud SQL and GKE, one resource's daily series, and which projects answered |
| Get budgets | Your Cloud Billing budgets, with spend from the billing export |
| Get access | What LevelFour's service account can read |
Get data availability
Returns, for each Google Cloud dataset LevelFour reads, whether it holds data for your organization. The dashboard's Google Cloud board shows a card only when the dataset behind it holds data, so this is the same answer the board uses.
availability, err := client.GoogleCloud.GetDataAvailability(ctx)Get inventory breakdown
Counts your Google Cloud resources, grouped by type (default), region or project.
byRegion, err := client.GoogleCloud.GetInventoryBreakdown(ctx,
&levelfour.GetInventoryBreakdownAPIV1ProvidersGcpInventoryBreakdownGetRequest{
By: levelfour.GetInventoryBreakdownAPIV1ProvidersGcpInventoryBreakdownGetRequestBy("region").Ptr(),
},
)Get waste signals
Returns resources that bill while doing nothing: stopped VMs whose disks still bill, unattached disks, reserved addresses nothing uses, and snapshots older than 90 days.
waste, err := client.GoogleCloud.GetWasteSignals(ctx)Get label hygiene
Returns how many resources carry each label key, and how many carry none. Pass keys to measure the keys your allocation depends on. System labels, the ones starting goog-, never count as labeled.
hygiene, err := client.GoogleCloud.GetLabelHygiene(ctx,
&levelfour.GetLabelHygieneAPIV1ProvidersGcpInventoryLabelHygieneGetRequest{
Keys: []string{"team", "env"},
},
)Get utilization
Three reads cover utilization from Cloud Monitoring. The summary puts VMs, Cloud SQL instances and GKE workloads into utilization bands over the last 30 days. The series is one resource's daily values. Coverage says which projects and metrics Cloud Monitoring answered for, so a missing band reads as missing data rather than as idle.
summary, err := client.GoogleCloud.GetUtilizationSummary(ctx)
series, err := client.GoogleCloud.GetUtilizationSeries(ctx,
&levelfour.GetUtilizationSeriesAPIV1ProvidersGcpUtilizationSeriesGetRequest{
ResourceID: "projects/acme-prod/zones/us-central1-a/instances/web-1",
Metric: levelfour.String("memory_utilization"),
Days: levelfour.Int(90),
},
)
coverage, err := client.GoogleCloud.GetUtilizationCoverage(ctx)| Series parameter | Type | Description |
|---|---|---|
resource_id | string | Required. The resource the summary names |
metric | string | cpu_utilization (default), memory_utilization for VMs running the Ops Agent, or memory_request_utilization for GKE |
days | int | 1 to 400 (defaults to 30) |
Get budgets
Returns your Cloud Billing budgets, each with the spend LevelFour reads from the billing export against it. A budget whose scope the export cannot reproduce exactly is marked approximate. Reading budgets needs the optional roles/billing.viewer grant from the billing connect command.
budgets, err := client.GoogleCloud.GetBudgets(ctx)Get access
Returns what LevelFour's service account can read in Google Cloud, checked against Google's own permission test, beside what the connect command reported it applied. Use it when a read comes back empty to see whether a grant is missing.
access, err := client.GoogleCloud.GetAccess(ctx)Next
- Connect Google Cloud is the connection these reads depend on
- Costs has Google Cloud spend, the credits basis, cost by labels and invoice months
- API reference is every parameter and response field
Accounts
Read the cloud accounts connected to LevelFour, what each one can do, the modules your organization has, and the work tools it is connected to, and disconnect a work tool.
Webhooks
What LevelFour posts to your endpoint when a recommendation or an optimization changes state, and how to verify the signature before you act on it.