Skip to content

Commit de9c2c1

Browse files
committed
exporter/signalfx: calculate extra network I/O metrics
Calculate extra metrics required on the backend: - system.network.io.total: total bytes I/O across all the network interfaces, keeping direction dimension - system.network.packets.total: total number of sent/received packets across all the network interfaces, keeping direction dimension
1 parent d6e93bb commit de9c2c1

File tree

2 files changed

+102
-1
lines changed

2 files changed

+102
-1
lines changed

exporter/signalfxexporter/factory_test.go

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,21 @@ func TestDefaultTranslationRules(t *testing.T) {
246246
require.Equal(t, "host", dps[0].Dimensions[0].Key)
247247
require.Equal(t, "host0", dps[0].Dimensions[0].Value)
248248

249+
// system.network.io.total new metric calculation
250+
dps, ok = metrics["system.network.io.total"]
251+
require.True(t, ok, "system.network.io.total metrics not found")
252+
require.Equal(t, 2, len(dps))
253+
require.Equal(t, 4, len(dps[0].Dimensions))
254+
255+
// system.network.packets.total new metric calculation
256+
dps, ok = metrics["system.network.packets.total"]
257+
require.True(t, ok, "system.network.packets.total metrics not found")
258+
require.Equal(t, 1, len(dps))
259+
require.Equal(t, 4, len(dps[0].Dimensions))
260+
require.Equal(t, int64(350), *dps[0].Value.IntValue)
261+
require.Equal(t, "direction", dps[0].Dimensions[0].Key)
262+
require.Equal(t, "receive", dps[0].Dimensions[0].Value)
263+
249264
// network.total new metric calculation
250265
dps, ok = metrics["network.total"]
251266
require.True(t, ok, "network.total metrics not found")
@@ -639,6 +654,76 @@ func testMetricsData() pdata.ResourceMetrics {
639654
},
640655
},
641656
},
657+
{
658+
MetricDescriptor: &metricspb.MetricDescriptor{
659+
Name: "system.network.packets",
660+
Description: "The number of packets transferred",
661+
Type: metricspb.MetricDescriptor_GAUGE_INT64,
662+
LabelKeys: []*metricspb.LabelKey{
663+
{Key: "direction"},
664+
{Key: "device"},
665+
{Key: "host"},
666+
{Key: "kubernetes_node"},
667+
{Key: "kubernetes_cluster"},
668+
},
669+
},
670+
Timeseries: []*metricspb.TimeSeries{
671+
{
672+
StartTimestamp: &timestamppb.Timestamp{},
673+
LabelValues: []*metricspb.LabelValue{{
674+
Value: "receive",
675+
HasValue: true,
676+
}, {
677+
Value: "eth0",
678+
HasValue: true,
679+
}, {
680+
Value: "host0",
681+
HasValue: true,
682+
}, {
683+
Value: "node0",
684+
HasValue: true,
685+
}, {
686+
Value: "cluster0",
687+
HasValue: true,
688+
}},
689+
Points: []*metricspb.Point{{
690+
Timestamp: &timestamppb.Timestamp{
691+
Seconds: 1596000000,
692+
},
693+
Value: &metricspb.Point_Int64Value{
694+
Int64Value: 200,
695+
},
696+
}},
697+
},
698+
{
699+
StartTimestamp: &timestamppb.Timestamp{},
700+
LabelValues: []*metricspb.LabelValue{{
701+
Value: "receive",
702+
HasValue: true,
703+
}, {
704+
Value: "eth1",
705+
HasValue: true,
706+
}, {
707+
Value: "host0",
708+
HasValue: true,
709+
}, {
710+
Value: "node0",
711+
HasValue: true,
712+
}, {
713+
Value: "cluster0",
714+
HasValue: true,
715+
}},
716+
Points: []*metricspb.Point{{
717+
Timestamp: &timestamppb.Timestamp{
718+
Seconds: 1596000000,
719+
},
720+
Value: &metricspb.Point_Int64Value{
721+
Int64Value: 150,
722+
},
723+
}},
724+
},
725+
},
726+
},
642727
{
643728
MetricDescriptor: &metricspb.MetricDescriptor{
644729
Name: "container.memory.working_set",

exporter/signalfxexporter/translation/constants.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,23 @@ translation_rules:
516516
517517
# Translations to derive Network I/O metrics.
518518
519-
## Calculate network.total.
519+
## Calculate extra network I/O metrics system.network.packets.total and system.network.io.total.
520+
- action: copy_metrics
521+
mapping:
522+
system.network.packets: system.network.packets.total
523+
system.network.io: system.network.io.total
524+
- action: aggregate_metric
525+
metric_name: system.network.packets.total
526+
aggregation_method: sum
527+
without_dimensions:
528+
- device
529+
- action: aggregate_metric
530+
metric_name: system.network.io.total
531+
aggregation_method: sum
532+
without_dimensions:
533+
- device
534+
535+
## Calculate extra network.total metric.
520536
- action: copy_metrics
521537
mapping:
522538
system.network.io: network.total

0 commit comments

Comments
 (0)