Skip to content

Commit ac1b1b0

Browse files
committed
Add support for per cpu metrics
Signed-off-by: Dani Louca <[email protected]>
1 parent f89d7a1 commit ac1b1b0

File tree

4 files changed

+53
-4
lines changed

4 files changed

+53
-4
lines changed

exporter/signalfxexporter/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,18 @@ exporters:
131131
state: [interrupt, user, system]
132132
```
133133
134+
The following `include_metrics` example would instruct the exporter to send only `cpu.interrupt` metrics with a `cpu` dimension value ("per core" datapoints), and both "per core" and aggregate `cpu.idle` metrics:
135+
136+
```
137+
exporters:
138+
signalfx:
139+
include_metrics:
140+
- metric_name: "cpu.idle"
141+
- metric_name: "cpu.interrupt"
142+
dimensions:
143+
cpu: ["*"]
144+
```
145+
134146
## Translation Rules and Metric Transformations
135147
136148
The `translation_rules` metrics configuration field accepts a list of metric-transforming actions to
@@ -181,6 +193,17 @@ The translation rules defined in [`translation/constants.go`](./internal/transla
181193
* vmpage_io.swap.in
182194
* vmpage_io.swap.out
183195
196+
In addition to the aggregated metrics, the default translation rules make available the following "per core" custom hostmetrics.
197+
The CPU number is assigned to the dimension `cpu`
198+
199+
* cpu.interrupt
200+
* cpu.nice
201+
* cpu.softirq
202+
* cpu.steal
203+
* cpu.system
204+
* cpu.user
205+
* cpu.wait
206+
184207
These metrics are intended to be reported directly to Splunk IM by the SignalFx exporter. Any desired changes to their attributes or values should be made via additional translation rules or from their constituent host metrics.
185208
186209
## Example Config

exporter/signalfxexporter/factory_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ func TestCreateMetricsExporterWithDefaultExcludeMetrics(t *testing.T) {
272272
require.NotNil(t, te)
273273

274274
// Validate that default excludes are always loaded.
275-
assert.Equal(t, 11, len(config.ExcludeMetrics))
275+
assert.Equal(t, 12, len(config.ExcludeMetrics))
276276
}
277277

278278
func TestCreateMetricsExporterWithExcludeMetrics(t *testing.T) {
@@ -292,7 +292,7 @@ func TestCreateMetricsExporterWithExcludeMetrics(t *testing.T) {
292292
require.NotNil(t, te)
293293

294294
// Validate that default excludes are always loaded.
295-
assert.Equal(t, 12, len(config.ExcludeMetrics))
295+
assert.Equal(t, 13, len(config.ExcludeMetrics))
296296
}
297297

298298
func TestCreateMetricsExporterWithEmptyExcludeMetrics(t *testing.T) {
@@ -630,11 +630,14 @@ func TestDefaultCPUTranslations(t *testing.T) {
630630
cpuUtilPerCore := m["cpu.utilization_per_core"]
631631
require.Equal(t, 8, len(cpuUtilPerCore))
632632

633-
cpuStateMetrics := []string{"cpu.idle", "cpu.interrupt", "cpu.num_processors", "cpu.system", "cpu.user"}
633+
cpuNumProcessors := m["cpu.num_processors"]
634+
require.Equal(t, 1, len(cpuNumProcessors))
635+
636+
cpuStateMetrics := []string{"cpu.idle", "cpu.interrupt", "cpu.system", "cpu.user"}
634637
for _, metric := range cpuStateMetrics {
635638
dps, ok := m[metric]
636639
require.True(t, ok, fmt.Sprintf("%s metrics not found", metric))
637-
require.Len(t, dps, 1)
640+
require.Len(t, dps, 9)
638641
}
639642
}
640643

exporter/signalfxexporter/internal/translation/constants.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,17 @@ translation_rules:
130130
without_dimensions:
131131
- cpu
132132
133+
- action: copy_metrics
134+
mapping:
135+
sf_temp.cpu.idle: sf_temp.cpu.idle_per_core
136+
sf_temp.cpu.interrupt: sf_temp.cpu.interrupt_per_core
137+
sf_temp.cpu.system: sf_temp.cpu.system_per_core
138+
sf_temp.cpu.user: sf_temp.cpu.user_per_core
139+
sf_temp.cpu.wait: sf_temp.cpu.wait_per_core
140+
sf_temp.cpu.steal: sf_temp.cpu.steal_per_core
141+
sf_temp.cpu.softirq: sf_temp.cpu.softirq_per_core
142+
sf_temp.cpu.nice: sf_temp.cpu.nice_per_core
143+
133144
- action: aggregate_metric
134145
metric_name: sf_temp.cpu.idle
135146
aggregation_method: sum
@@ -399,15 +410,23 @@ translation_rules:
399410
mapping:
400411
sf_temp.container_cpu_utilization: container_cpu_utilization
401412
sf_temp.cpu.idle: cpu.idle
413+
sf_temp.cpu.idle_per_core: cpu.idle
402414
sf_temp.cpu.interrupt: cpu.interrupt
415+
sf_temp.cpu.interrupt_per_core: cpu.interrupt
403416
sf_temp.cpu.nice: cpu.nice
417+
sf_temp.cpu.nice_per_core: cpu.nice
404418
sf_temp.cpu.num_processors: cpu.num_processors
405419
sf_temp.cpu.softirq: cpu.softirq
420+
sf_temp.cpu.softirq_per_core: cpu.softirq
406421
sf_temp.cpu.steal: cpu.steal
422+
sf_temp.cpu.steal_per_core: cpu.steal
407423
sf_temp.cpu.system: cpu.system
424+
sf_temp.cpu.system_per_core: cpu.system
408425
sf_temp.cpu.user: cpu.user
426+
sf_temp.cpu.user_per_core: cpu.user
409427
sf_temp.cpu.utilization: cpu.utilization
410428
sf_temp.cpu.wait: cpu.wait
429+
sf_temp.cpu.wait_per_core: cpu.wait
411430
sf_temp.disk.summary_utilization: disk.summary_utilization
412431
sf_temp.disk.utilization: disk.utilization
413432
sf_temp.memory.total: memory.total

exporter/signalfxexporter/internal/translation/default_metrics.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ exclude_metrics:
5151
dimensions:
5252
state: [interrupt, nice, softirq, steal, system, user, wait]
5353
54+
- metric_name: cpu.idle
55+
dimensions:
56+
cpu: ["*"]
57+
5458
# Memory metrics.
5559
- metric_name: system.memory.usage
5660
dimensions:

0 commit comments

Comments
 (0)