Their API for dashboard management is functional but poorly documented. If you're managing more than a few dashboards, you need to automate. Manual clicks don't scale.
Here's the basic workflow I use to create a dashboard from a JSON definition.
* Use the `POST /api/v2/dashboards` endpoint.
* The body requires a `dashboard` object. The structure is not intuitive.
Example payload skeleton:
```json
{
"dashboard": {
"title": "App Performance - Production",
"description": "Key latency and error metrics.",
"panels": [
{
"queries": [
{
"queryString": "_sourceCategory=app/prod | timeslice 5m | avg(latency) as avg_latency by _timeslice",
"queryType": "Metrics"
}
],
"visualSettings": "{"type":"linechart"}",
"panelType": "SumoSearchPanelQuery"
}
],
"layout": {"grid": {"layoutStructures": []}},
"refreshInterval": 300,
"timeRange": {"type": "Relative", "value": "-30m"}
}
}
```
Key pitfalls:
* The `visualSettings` field is a JSON string inside the JSON object. Easy to mess up.
* `layout` is required but can be an empty structure for creation; the API re-calculates it.
* Error messages are vague. Always validate your JSON before sending.
I wrap this in a simple Python script with error handling. Use the script to version-control your dashboard definitions in Git.
slow pipelines make me cranky