-
Notifications
You must be signed in to change notification settings - Fork 0
Best Practices
Garot Conklin edited this page Feb 6, 2025
·
1 revision
Comprehensive guide to best practices when using the DataDog Dashboard Deployer.
- Store configurations in version control
- Use meaningful commit messages
- Follow branching strategy
- Review changes before deployment
dashboards/
├── production/
│ ├── system-monitoring.yaml
│ └── application-metrics.yaml
├── staging/
│ ├── system-monitoring.yaml
│ └── application-metrics.yaml
└── templates/
├── widgets.yaml
└── defaults.yaml# Clear, descriptive names
dashboards:
- name: "Production-WebAPI-Metrics"
description: "Web API performance metrics for production"
# Consistent widget naming
widgets:
- title: "[PROD] API Response Time"
type: "timeseries"- Group related metrics
- Use consistent ordering
- Consider visual hierarchy
- Maintain readability
# Choose appropriate widget types
widgets:
# Use timeseries for trends
- title: "CPU Trend"
type: "timeseries"
# Use query_value for current status
- title: "Current Load"
type: "query_value"
# Use toplist for rankings
- title: "Top Consumers"
type: "toplist"# Efficient queries
queries:
# Use appropriate aggregation
good: "avg:system.cpu.user{*}.rollup(avg, 300)"
bad: "avg:system.cpu.user{*}"
# Limit cardinality
good: "sum:requests{service:$service} by {endpoint}"
bad: "sum:requests{*} by {host,endpoint,method,status}"- Use environment variables
- Rotate credentials regularly
- Implement least privilege
- Audit access regularly
# Use appropriate tagging
defaults:
tags:
- "team:infrastructure"
- "env:production"
- "security-level:restricted"# .github/workflows/deploy.yml
name: Deploy Dashboards
on:
push:
branches: [main]
paths:
- "dashboards/**"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Deploy
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DATADOG_APP_KEY: ${{ secrets.DATADOG_APP_KEY }}
run: |
datadog-dashboard-deploy dashboards/production/*.yaml# Validate before deployment
datadog-dashboard-deploy --dry-run config.yaml
# Run tests
pytest tests/
# Check formatting
black . && isort .- Use appropriate time aggregation
- Limit high-cardinality tags
- Implement efficient filtering
# Limit widgets per dashboard
dashboards:
- name: "System Overview"
widgets:
# Keep widget count reasonable (8-12 max)
- title: "CPU Usage"
type: "timeseries"
# ...- Audit dashboard usage
- Update outdated metrics
- Remove unused dashboards
- Validate configurations
dashboards:
- name: "Service Monitoring"
description: |
Comprehensive service monitoring dashboard.
Owner: Infrastructure Team
Last Updated: 2024-02-06
Contact: #infrastructure-supportdef test_dashboard_config():
"""Test dashboard configuration validation."""
config = load_config("dashboards/production/system.yaml")
assert "version" in config
assert len(config["dashboards"]) > 0def test_dashboard_deployment():
"""Test dashboard deployment."""
result = deployer.deploy("config.yaml", dry_run=True)
assert result["status"] == "validated"