Environments define the deployment contexts (e.g., production, staging) where your services run. Each flag metric must specify which environments it applies to.
environments:
- name: "production"
attributes:
region: "eu-west-1"
datacenter: "dc1"
- name: "staging"
- name: "development"| Property | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Unique environment identifier |
attributes |
object | No | Key-value metadata for the environment |
At minimum, define environment names:
environments:
- name: "production"
- name: "staging"
- name: "development"Attributes provide additional metadata that can be passed to the status dashboard:
environments:
- name: "production"
attributes:
region: "eu-west-1"
availability_zone: "eu-west-1a"
tier: "critical"
- name: "staging"
attributes:
region: "eu-west-1"
tier: "non-critical"Regional Deployment:
environments:
- name: "us-east-prod"
attributes:
region: "us-east-1"
type: "production"
- name: "us-west-prod"
attributes:
region: "us-west-2"
type: "production"
- name: "eu-prod"
attributes:
region: "eu-west-1"
type: "production"Environment Tiers:
environments:
- name: "production"
attributes:
tier: "1"
sla: "99.9%"
- name: "staging"
attributes:
tier: "2"
sla: "99%"
- name: "development"
attributes:
tier: "3"
sla: "none"Environment names are available in metric templates via the $environment variable:
metric_templates:
api_latency:
query: "stats.timers.api.$environment.$service.mean"
op: "gt"
threshold: 500
environments:
- name: "production"
- name: "staging"
flag_metrics:
- name: "api_slow"
service: "compute"
template:
name: "api_latency"
environments:
- name: "production" # Query: stats.timers.api.production.compute.mean
- name: "staging" # Query: stats.timers.api.staging.compute.meanDifferent environments can have different thresholds for the same metric:
environments:
- name: "production"
- name: "staging"
- name: "development"
flag_metrics:
- name: "api_slow"
service: "compute"
template:
name: "api_latency" # Default threshold: 500ms
environments:
- name: "production"
# Uses default 500ms - strict for production
- name: "staging"
threshold: 1000 # 1s - more lenient
- name: "development"
threshold: 2000 # 2s - very lenient| Environment | Strategy | Example |
|---|---|---|
| Production | Strict SLA-based | 500ms, 99.9% availability |
| Staging | Moderate | 1000ms, 99% availability |
| Development | Lenient | 2000ms, 90% availability |
For single-region deployments:
environments:
- name: "production"
- name: "staging"
- name: "development"For multi-region deployments:
environments:
- name: "us-production"
- name: "eu-production"
- name: "ap-production"For datacenter-aware deployments:
environments:
- name: "dc1-production"
- name: "dc2-production"
- name: "dc1-staging"environments:
- name: "local"environments:
- name: "production"
attributes:
type: "prod"
alert_channel: "#production-alerts"
- name: "staging"
attributes:
type: "non-prod"
alert_channel: "#staging-alerts"
- name: "development"
attributes:
type: "non-prod"environments:
- name: "us-east-1"
attributes:
region: "us-east-1"
type: "production"
primary: "true"
- name: "us-west-2"
attributes:
region: "us-west-2"
type: "production"
primary: "false"
- name: "eu-west-1"
attributes:
region: "eu-west-1"
type: "production"
primary: "false"
- name: "staging"
attributes:
region: "us-east-1"
type: "staging"environments:
- name: "aws-production"
attributes:
cloud: "aws"
region: "us-east-1"
- name: "gcp-production"
attributes:
cloud: "gcp"
region: "us-central1"
- name: "azure-production"
attributes:
cloud: "azure"
region: "eastus"When status_dashboard is configured, environment attributes are passed along with health updates:
environments:
- name: "production"
attributes:
region: "Region1"
display_name: "Production (Region 1)"
status_dashboard:
url: "https://status.example.com"The status dashboard receives environment information to display health status per environment/region.
Use consistent naming across all environments:
# Good: Consistent pattern
environments:
- name: "prod-us-east"
- name: "prod-us-west"
- name: "prod-eu"
# Avoid: Inconsistent naming
environments:
- name: "production"
- name: "US-West-Prod"
- name: "eu_production"Ensure environment names match your TSDB metric path segments:
# If your metrics are: stats.api.production.service.latency
environments:
- name: "production" # Matches metric path segment
# If your metrics are: stats.api.prod_us_east.service.latency
environments:
- name: "prod_us_east" # Matches metric path segmentAdd comments explaining attribute usage:
environments:
- name: "production"
attributes:
region: "eu-west-1" # AWS region for status dashboard
tier: "1" # Priority tier for alerting
maintenance_window: "sun" # Scheduled maintenance dayIf you have many environments, consider using conf.d to organize:
# conf.d/environments.yaml
environments:
- name: "production"
- name: "staging"
- name: "development"If you see "Environment for service not supported" errors:
- Verify the environment is defined in
environments - Check the environment name matches in
flag_metrics - Ensure consistent spelling and case
If queries return no data for an environment:
- Verify the environment name matches your TSDB metric paths
- Check that metrics exist for this environment in your TSDB
- Test the query directly in your TSDB UI
- Overview - Configuration structure
- Flag Metrics - Using environments in flag metrics
- Metric Templates - Variable substitution
- Examples - Complete configuration samples