summaryrefslogtreecommitdiff
path: root/AGENT.md
blob: d5c22e7b2f1921c123602783a88ef9229e463d37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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}]
  }
}
```