Follow ~/git/conf/snippets/go/go-projects.md ## Grafana Dashboard Guidelines When creating or updating Grafana dashboards: ### Sorting Requirements **ALWAYS ensure ALL panels are sorted by value (descending):** 1. **Time Series Panels:** - Add to `options.legend`: `"sortBy": "Last", "sortDesc": true` 2. **Bar Gauge Panels:** - Use `sort_desc()` in PromQL queries - Example: `sort_desc(topk(10, sum by (label) (metric)))` 3. **Pie/Donut Chart Panels:** - Add to `options.legend`: `"sortBy": "Value", "sortDesc": true` 4. **Table Panels:** - Add to `options`: `"sortBy": [{"displayName": "ColumnName", "desc": true}]` ### Example Panel Configuration **Time Series:** ```json { "type": "timeseries", "options": { "legend": { "displayMode": "table", "placement": "right", "sortBy": "Last", "sortDesc": true, "calcs": ["lastNotNull", "mean", "max"] } } } ``` **Bar Gauge:** ```json { "type": "bargauge", "targets": [{ "expr": "sort_desc(topk(15, sum by (cust) (metric)))" }], "options": { "orientation": "horizontal", "displayMode": "gradient" } } ``` **Table:** ```json { "type": "table", "options": { "sortBy": [{"displayName": "Count", "desc": true}] } } ```