Skip to content

How to set up quota consumption alerts

Last updated on

To ensure continuous data ingestion without unexpected drops, it is highly recommended to set up early warning alerts. By configuring alerts to trigger when your resource consumption reaches 90% of your allocated limits, you have enough time to react – either by optimizing your data ingestion or upgrading your plan.

This guide provides a ready-to-use configuration to set up email alerts for the following critical quotas:

  • Logs: Storage bucket size
  • Traces: Storage bucket size
  • Metrics: Write samples per minute

Follow these steps to configure your Alertmanager receiver, routing, and Prometheus alert rules.

  1. Export your variables

    To execute the commands in this guide smoothly, first export the variables from the code box in your terminal. Replace the values with your actual project ID, instance ID, and the email address that should receive the alerts:

    Terminal window
    export PROJECT_ID="your-project-id"
    export INSTANCE_ID="your-instance-id"
    export EMAIL_ADDRESS="your-email@company.com"
  2. Create the Alertmanager receiver

    First, configure an Alertmanager receiver to define where the alert should be sent. We will create an email receiver using your exported email address.

    Terminal window
    stackit curl -X POST "https://argus.api.eu01.stackit.cloud/v1/projects/$PROJECT_ID/instances/$INSTANCE_ID/alertconfigs/receivers" \
    -H "accept: application/json" \
    -H "Content-Type: application/json" \
    --data '{
    "name":"QuotaAlertsReceiver",
    "emailConfigs":[{"to":"'$EMAIL_ADDRESS'"}]
    }'
  3. Create the Alertmanager route

    Next, create an alert config route. This tells the Alertmanager to route alerts to the receiver you just created based on specific grouping and timing settings. We also apply a matcher to ensure only alerts with a warning severity are routed here.

    Terminal window
    stackit curl -X POST "https://argus.api.eu01.stackit.cloud/v1/projects/$PROJECT_ID/instances/$INSTANCE_ID/alertconfigs/routes" \
    -H "accept: application/json" \
    -H "Content-Type: application/json" \
    --data '{
    "receiver":"QuotaAlertsReceiver",
    "groupBy":["alertname"],
    "groupWait":"30s",
    "groupInterval":"5m",
    "repeatInterval":"4h",
    "matchers":["severity=warning"]
    }'
  4. Create the Prometheus Alert Group and Rules

    Finally, define the alert conditions based on the Prometheus Query Language (expr). The following command creates an Alert Group containing three rules that trigger when your Logs, Traces, or Metrics usage hits 90%.

    Terminal window
    stackit curl -X POST "https://argus.api.eu01.stackit.cloud/v1/projects/$PROJECT_ID/instances/$INSTANCE_ID/alertgroups" \
    -H "accept: application/json" \
    -H "Content-Type: application/json" \
    --data '{
    "name": "QuotaConsumptionAlerts",
    "interval": "60s",
    "rules": [
    {
    "alert": "LogQuotaApproaching",
    "expr": "max(instance_logs_storage_size{} * 100 / instance_logs_plan_size{}) >= 90",
    "for": "5m",
    "labels": { "severity": "warning" }
    },
    {
    "alert": "TraceQuotaApproaching",
    "expr": "max(instance_traces_storage_size{} * 100 / instance_trace_plan_size{}) >= 90",
    "for": "5m",
    "labels": { "severity": "warning" }
    },
    {
    "alert": "MetricsQuotaApproaching",
    "expr": "avg by(namespace) (increase(instance_remote_write_samples_received_total[2m])) / on() group_right min(instance_remote_write_samples_max_1m) >= 0.9",
    "for": "5m",
    "labels": { "severity": "warning" }
    }
    ]
    }'