-
Notifications
You must be signed in to change notification settings - Fork 0
API Reference
Garot Conklin edited this page Feb 6, 2025
·
1 revision
Complete reference for the DataDog Dashboard Deployer Python API.
Main class for handling dashboard deployment operations.
from datadog_dashboard_deployer import DashboardDeployer
deployer = DashboardDeployer(
api_key="your-api-key",
app_key="your-app-key",
site="datadoghq.com"
)Deploy dashboards from configuration file.
result = deployer.deploy("config/dashboard.yaml", dry_run=False)Returns:
{
"status": "success",
"results": [
{
"status": "success",
"dashboard_id": "abc-123",
"name": "My Dashboard",
"action": "create" # or "update"
}
]
}Parser for dashboard configuration files.
from datadog_dashboard_deployer import ConfigParser
parser = ConfigParser("config/dashboard.yaml")
config = parser.parse()Parse and validate configuration file.
config = parser.parse()Configure logging for the package.
from datadog_dashboard_deployer import setup_logging
setup_logging("DEBUG")Validate required environment variables.
from datadog_dashboard_deployer.utils import validate_environment
validate_environment()DASHBOARD_SCHEMA = {
"type": "object",
"required": ["version", "dashboards"],
"properties": {
"version": {"type": "string"},
"defaults": {
"type": "object",
"properties": {
"layout_type": {"type": "string", "enum": ["ordered", "free"]},
"refresh_interval": {"type": "integer", "minimum": 0},
"tags": {"type": "array", "items": {"type": "string"}},
},
},
"dashboards": {
"type": "array",
"items": {
"type": "object",
"required": ["name", "widgets"],
"properties": {
"name": {"type": "string"},
"description": {"type": "string"},
"layout_type": {"type": "string"},
"widgets": {"type": "array"}
}
}
}
}
}from datadog_dashboard_deployer.exceptions import (
ConfigurationError,
ValidationError,
DeploymentError
)
try:
deployer.deploy("config.yaml")
except ConfigurationError as e:
print(f"Configuration error: {e}")
except ValidationError as e:
print(f"Validation error: {e}")
except DeploymentError as e:
print(f"Deployment error: {e}")from datadog_dashboard_deployer import DashboardDeployer
# Initialize deployer
deployer = DashboardDeployer(
api_key="your-api-key",
app_key="your-app-key"
)
# Deploy dashboards
result = deployer.deploy("config/dashboard.yaml")
# Check results
if result["status"] == "success":
print("Deployment successful!")
for dashboard in result["results"]:
print(f"- {dashboard['action']}: {dashboard['name']}")import logging
from datadog_dashboard_deployer import DashboardDeployer, setup_logging
# Configure logging
setup_logging("DEBUG")
# Initialize deployer
deployer = DashboardDeployer(
api_key="your-api-key",
app_key="your-app-key",
site="datadoghq.eu"
)
# Validate configuration
result = deployer.deploy("config/dashboard.yaml", dry_run=True)
# Deploy if valid
if result["status"] == "validated":
result = deployer.deploy("config/dashboard.yaml")