From f6b5868cc19afb92b363abf8a7ed6fd956d287ab Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 4 Mar 2021 10:35:30 -0800 Subject: [PATCH] exporter/signalfx: calculate extra disk I/O metrics Calculate some extra disk I/O metrics required on the backend: - system.disk.io.total: total bytes I/O across all the disks, keeping direction dimension - system.disk.operations.total: total number of operations packets across all the disks, keeping direction dimension --- exporter/signalfxexporter/factory_test.go | 119 ++++++++++++++++++ .../signalfxexporter/translation/constants.go | 21 +++- 2 files changed, 139 insertions(+), 1 deletion(-) diff --git a/exporter/signalfxexporter/factory_test.go b/exporter/signalfxexporter/factory_test.go index 251517a9fa48..5f8ad29bc4a7 100644 --- a/exporter/signalfxexporter/factory_test.go +++ b/exporter/signalfxexporter/factory_test.go @@ -236,6 +236,27 @@ func TestDefaultTranslationRules(t *testing.T) { require.Equal(t, "disk", dps[3].Dimensions[2].Key) require.Equal(t, "sda2", dps[3].Dimensions[2].Value) + // system.network.operations.total new metric calculation + dps, ok = metrics["system.disk.operations.total"] + require.True(t, ok, "system.network.operations.total metrics not found") + require.Equal(t, 4, len(dps)) + require.Equal(t, 2, len(dps[0].Dimensions)) + + // system.network.io.total new metric calculation + dps, ok = metrics["system.disk.io.total"] + require.True(t, ok, "system.network.io.total metrics not found") + require.Equal(t, 2, len(dps)) + require.Equal(t, 2, len(dps[0].Dimensions)) + for _, dp := range dps { + require.Equal(t, "direction", dp.Dimensions[1].Key) + switch dp.Dimensions[1].Value { + case "write": + require.Equal(t, int64(11e9), *dp.Value.IntValue) + case "read": + require.Equal(t, int64(3e9), *dp.Value.IntValue) + } + } + // disk_ops.total gauge from system.disk.operations cumulative, where is disk_ops.total // is the cumulative across devices and directions. dps, ok = metrics["disk_ops.total"] @@ -370,6 +391,104 @@ func testMetricsData() pdata.ResourceMetrics { }, }, }, + { + MetricDescriptor: &metricspb.MetricDescriptor{ + Name: "system.disk.io", + Description: "Disk I/O.", + Type: metricspb.MetricDescriptor_CUMULATIVE_INT64, + LabelKeys: []*metricspb.LabelKey{ + {Key: "host"}, + {Key: "direction"}, + {Key: "device"}, + }, + }, + Timeseries: []*metricspb.TimeSeries{ + { + StartTimestamp: ×tamppb.Timestamp{}, + LabelValues: []*metricspb.LabelValue{{ + Value: "host0", + HasValue: true, + }, { + Value: "read", + HasValue: true, + }, { + Value: "sda1", + HasValue: true, + }}, + Points: []*metricspb.Point{{ + Timestamp: ×tamppb.Timestamp{ + Seconds: 1596000000, + }, + Value: &metricspb.Point_Int64Value{ + Int64Value: 1e9, + }, + }}, + }, + { + StartTimestamp: ×tamppb.Timestamp{}, + LabelValues: []*metricspb.LabelValue{{ + Value: "host0", + HasValue: true, + }, { + Value: "read", + HasValue: true, + }, { + Value: "sda2", + HasValue: true, + }}, + Points: []*metricspb.Point{{ + Timestamp: ×tamppb.Timestamp{ + Seconds: 1596000000, + }, + Value: &metricspb.Point_Int64Value{ + Int64Value: 2e9, + }, + }}, + }, + { + StartTimestamp: ×tamppb.Timestamp{}, + LabelValues: []*metricspb.LabelValue{{ + Value: "host0", + HasValue: true, + }, { + Value: "write", + HasValue: true, + }, { + Value: "sda1", + HasValue: true, + }}, + Points: []*metricspb.Point{{ + Timestamp: ×tamppb.Timestamp{ + Seconds: 1596000000, + }, + Value: &metricspb.Point_Int64Value{ + Int64Value: 3e9, + }, + }}, + }, + { + StartTimestamp: ×tamppb.Timestamp{}, + LabelValues: []*metricspb.LabelValue{{ + Value: "host0", + HasValue: true, + }, { + Value: "write", + HasValue: true, + }, { + Value: "sda2", + HasValue: true, + }}, + Points: []*metricspb.Point{{ + Timestamp: ×tamppb.Timestamp{ + Seconds: 1596000000, + }, + Value: &metricspb.Point_Int64Value{ + Int64Value: 8e9, + }, + }}, + }, + }, + }, { MetricDescriptor: &metricspb.MetricDescriptor{ Name: "system.disk.operations", diff --git a/exporter/signalfxexporter/translation/constants.go b/exporter/signalfxexporter/translation/constants.go index 477269fe5dab..34ee92a19475 100644 --- a/exporter/signalfxexporter/translation/constants.go +++ b/exporter/signalfxexporter/translation/constants.go @@ -488,7 +488,25 @@ translation_rules: disk.summary_utilization: 100 -# convert disk I/O metrics +# Translations to derive disk I/O metrics. + +## Calculate extra system.disk.operations.total and system.disk.io.total metrics summing up read/write ops/IO across all devices. +- action: copy_metrics + mapping: + system.disk.operations: system.disk.operations.total + system.disk.io: system.disk.io.total +- action: aggregate_metric + metric_name: system.disk.operations.total + aggregation_method: sum + without_dimensions: + - device +- action: aggregate_metric + metric_name: system.disk.io.total + aggregation_method: sum + without_dimensions: + - device + +## Calculate an extra disk_ops.total metric as number all all read and write operations happened since the last report. - action: copy_metrics mapping: system.disk.operations: disk.ops @@ -501,6 +519,7 @@ translation_rules: - action: delta_metric mapping: disk.ops: disk_ops.total + - action: rename_dimension_keys metric_names: system.disk.merged: true