This page covers creating and silencing Billing alerts and alert rules.
Before you begin
Before continuing, ensure you have the following required role:
- Monitoring Rule Creator: create and manage
MonitoringRulecustom resources. Ask your IAM Org Admin to grant you themonitoringrule-pa-creatorrole.
Create alert rules
You can create alert rules based on invoice metrics and your spend thresholds
using the MonitoringRule
resource in the Observability API. See Create alert rules for more information about defining MonitoringRule custom resources.
To create an alert rule, work through the following steps:
Create a YAML file, and add in the
MonitoringRuleresource and the following contents:apiVersion: monitoring.gdc.goog/v1 kind: MonitoringRule metadata: name: MONITORING_RULE_NAME namespace: platform-obs spec: interval: INTERVAL limit: LIMIT alertRules: - alert: ALERT expr: EXPRESSION labels: severity: SEVERITY code: BILLING_CODE resource: BILLING annotations: message: MESSAGEReplace the following variables:
Variable Description MONITORING_RULE_NAME The name of the monitoring rule.
For example:invoice-total-cost.INTERVAL The length of time the alert re-runs in a given period.
For example:60sdefines that the alert runs every sixty seconds.LIMIT The amount of times an alert can run.
For example:0for no limit.ALERT The alert name.
For example:invoice_total_cost_approaching_limit.EXPRESSION The PromQL expression to describe the alert rule. To retrieve a PromQL expression, see View and filter open alerts.
For example, to set an alert rule with a spend threshold at 80% of your $500,000 budgeted amount, use the following expression:
sum(billing_total_cost{account_id="platform/BILLING_ACCOUNT_NAME"}) / 500000 > 0.8
Replace BILLING_ACCOUNT_NAME with your billing account name.SEVERITY The severity of the alert rule. Severity values include error,critical,warning, andinfo.BILLING_CODE The billing code you define for the alert rule.
For example:"BILLING-100".MESSAGE A description of the alert that appears when the alert rule runs.
For example:"Spending exceeded limit".Apply the contents of the YAML file and set the alert rule:
kubectl apply -f FILENAME.yaml --kubeconfig=MANAGEMENT_API_SERVER -n platform-obsReplace the following:
- FILENAME: the name of the YAML file that defines the
MonitoringRuleresource. - MANAGEMENT_API_SERVER: the path to the management API server kubeconfig file.
- FILENAME: the name of the YAML file that defines the
Verify that the alert rule exists:
kubectl get monitoringrule -n platform-obs --kubeconfig=MANAGEMENT_API_SERVERThe output is similar to the following:
NAME AGE invoice-total-cost 10s
Create spend threshold alerts
Your Infrastructure Operator (IO) creates spend threshold alert policies in the GDC console. Spend threshold alerts are custom billing alerts that indicate when the billing costs exceed the threshold you set. For example, your IO creates billing total cost alerts and configures the alerts based on a fixed dollar amount, or as a percentage of the initial budgeted amount.
To create spend threshold alerts and other organization-level billing alerts, submit a request to your IO. Include the following parameters in your request:
- Billing account ID.
- The total budget amount for the specified billing account.
- The budget threshold.
Silence alerts
You can silence and unsilence alert rules through the GDC console. Follow the instructions in Silence an alert.
Configure billing notifications
To configure billing notifications, follow the instructions in Configure notification channels.