Commit 59326a9
Add host-level memory pressure metrics to system memory check (#44808)
### What does this PR do?
Adds memory pressure metrics from `/proc/vmstat` to the Linux system memory check.
**New metrics:**
| Metric | Type | Tags | Description |
|--------|------|------|-------------|
| `system.mem.allocstall` | MonotonicCount | `zone` | Direct reclaim stalls per memory zone |
| `system.mem.pgscan_direct` | MonotonicCount | - | Pages scanned during direct (synchronous) reclaim |
| `system.mem.pgsteal_direct` | MonotonicCount | - | Pages reclaimed during direct reclaim |
| `system.mem.pgscan_kswapd` | MonotonicCount | - | Pages scanned by kswapd background daemon |
| `system.mem.pgsteal_kswapd` | MonotonicCount | - | Pages reclaimed by kswapd |
Similar to #1605 (commit_limit/committed_as) and #6708 (context_switches).
### Motivation
These counters expose kernel memory reclaim activity:
- **allocstall**: Increments when a process enters direct reclaim, blocking until memory is freed. Indicates memory pressure where kswapd cannot keep up with demand. Per-zone counters (`dma`, `dma32`, `normal`, `movable`) help distinguish zone-specific pressure from system-wide pressure. ([kernel docs](https://www.kernel.org/doc/html/latest/admin-guide/mm/concepts.html), [Red Hat on memory zones](https://www.redhat.com/en/blog/memory-zones-and-linux-driver-issue))
- **pgscan/pgsteal**: Track pages scanned vs reclaimed during memory reclaim. The ratio `pgsteal/pgscan` indicates reclaim efficiency—values below 30% suggest the kernel is scanning many pages to find few reclaimable ones. `_direct` variants measure synchronous reclaim in the allocation path; `_kswapd` variants measure background reclaim. ([kernel memory management docs](https://www.kernel.org/doc/gorman/html/understand/understand013.html))
### Describe how you validated your changes
- `go test -tags test ./pkg/collector/corechecks/system/memory/...` — all tests pass
- `TestMemoryCheckLinux` updated to verify new metrics with correct values and zone tags
- `TestSwapMemoryError` updated to handle vmstat unavailability path
### Additional Notes
- Linux-only (relies on `/proc/vmstat`)
- Respects `procfs_path` config for containerized environments
- Per-zone `allocstall_*` counters available since kernel 4.8; older kernels have a single global counter (not collected)
- No configuration required—metrics collected automatically with existing memory check
- This PR was created with the help of [Claude Code](https://github.com/anthropics/claude-code)
Co-authored-by: fabbing <fabbing@free.fr>
Co-authored-by: fabrice.buoro <fabrice.buoro@datadoghq.com>1 parent 2b6687a commit 59326a9
File tree
4 files changed
+172
-5
lines changed- cmd/agent/dist/conf.d/memory.d
- pkg/collector/corechecks/system/memory
- releasenotes/notes
4 files changed
+172
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
1 | 7 | | |
2 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
| 13 | + | |
12 | 14 | | |
| 15 | + | |
| 16 | + | |
13 | 17 | | |
14 | 18 | | |
| 19 | + | |
15 | 20 | | |
16 | | - | |
17 | | - | |
| 21 | + | |
| 22 | + | |
18 | 23 | | |
| 24 | + | |
| 25 | + | |
19 | 26 | | |
20 | 27 | | |
21 | 28 | | |
22 | 29 | | |
23 | 30 | | |
24 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
25 | 39 | | |
26 | | - | |
| 40 | + | |
27 | 41 | | |
28 | 42 | | |
| 43 | + | |
29 | 44 | | |
30 | 45 | | |
31 | 46 | | |
| |||
96 | 111 | | |
97 | 112 | | |
98 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
99 | 119 | | |
100 | 120 | | |
101 | 121 | | |
| |||
108 | 128 | | |
109 | 129 | | |
110 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
63 | 88 | | |
64 | 89 | | |
65 | 90 | | |
| |||
85 | 110 | | |
86 | 111 | | |
87 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
88 | 124 | | |
89 | 125 | | |
90 | 126 | | |
91 | 127 | | |
92 | 128 | | |
93 | 129 | | |
94 | 130 | | |
95 | | - | |
| 131 | + | |
| 132 | + | |
96 | 133 | | |
97 | 134 | | |
98 | 135 | | |
| |||
186 | 223 | | |
187 | 224 | | |
188 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
189 | 231 | | |
190 | 232 | | |
191 | 233 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
0 commit comments