From e50ed0d1a7048bd9e8c0914539b143b412c0f760 Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Sun, 24 Mar 2024 17:32:50 -0700 Subject: [PATCH] use golden files for telegraf --- tests/go.mod | 3 + tests/go.sum | 6 + .../telegraf_procstat_test.go | 80 +- .../testdata/all_expected.yaml | 1325 +++++++++++++++++ .../testdata/all_metrics_config.yaml | 9 + .../testdata/resource_metrics/all.yaml | 507 ------- 6 files changed, 1420 insertions(+), 510 deletions(-) create mode 100644 tests/receivers/smartagent/telegraf-procstat/testdata/all_expected.yaml delete mode 100644 tests/receivers/smartagent/telegraf-procstat/testdata/resource_metrics/all.yaml diff --git a/tests/go.mod b/tests/go.mod index 2b79fb4918..37d110d9ed 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -8,6 +8,8 @@ require ( github.com/go-sql-driver/mysql v1.8.0 github.com/google/uuid v1.6.0 github.com/knadh/koanf v1.5.0 + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.96.0 + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.96.0 github.com/shirou/gopsutil/v3 v3.24.2 github.com/stretchr/testify v1.9.0 github.com/testcontainers/testcontainers-go v0.20.1 @@ -70,6 +72,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/morikuni/aec v1.0.0 // indirect github.com/mostynb/go-grpc-compression v1.2.2 // indirect + github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.96.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc5 // indirect github.com/opencontainers/runc v1.1.12 // indirect diff --git a/tests/go.sum b/tests/go.sum index be2803f362..2fb7902037 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -922,6 +922,12 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/npillmayer/nestext v0.1.3/go.mod h1:h2lrijH8jpicr25dFY+oAJLyzlya6jhnuG+zWp9L0Uk= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.96.0 h1:6xhEYeFRjui33hCCP8tD9B2R2VCGNdNrzi+pivp0osk= +github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.96.0/go.mod h1:7CDMyrWBi/iST+UVvheDNjZX8VWyboTJqkXHz7gpLDI= +github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.96.0 h1:iynLFjnG869r53AIhiavbEVMZoPqCba7Mijm+9MRdOo= +github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.96.0/go.mod h1:FuTdjIZj7Un07dcbJs06IF1DJiYfpQkc4oklhNWE8fg= +github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.96.0 h1:nzAR1IjPcbgLNFmJElLPyRlLOfijAkQcWo4L9CXixu4= +github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.96.0/go.mod h1:Zn0A4V5t3uNr2FYsgnzT4t0OBqdOk8jcPjgHgy3jHG0= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= diff --git a/tests/receivers/smartagent/telegraf-procstat/telegraf_procstat_test.go b/tests/receivers/smartagent/telegraf-procstat/telegraf_procstat_test.go index f30d7a91ca..7fbb6122a5 100644 --- a/tests/receivers/smartagent/telegraf-procstat/telegraf_procstat_test.go +++ b/tests/receivers/smartagent/telegraf-procstat/telegraf_procstat_test.go @@ -17,13 +17,87 @@ package tests import ( + "context" + "fmt" + "path/filepath" + "runtime" "testing" + "time" + + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/pmetrictest" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/component/componenttest" + "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/receiver/otlpreceiver" + "go.opentelemetry.io/collector/receiver/receivertest" + "go.uber.org/zap" "github.com/signalfx/splunk-otel-collector/tests/testutils" ) func TestTelegrafProcstatReceiverProvidesAllMetrics(t *testing.T) { - // collector is monitoring itself so use container for env consistency - testutils.SkipIfNotContainerTest(t) - testutils.AssertAllMetricsReceived(t, "all.yaml", "all_metrics_config.yaml", nil, nil) + checkGoldenFile(t, "all_metrics_config.yaml", "all_expected.yaml", + pmetrictest.IgnoreMetricsOrder(), + pmetrictest.IgnoreResourceMetricsOrder(), + pmetrictest.IgnoreTimestamp(), + pmetrictest.IgnoreStartTimestamp(), + pmetrictest.IgnoreMetricValues( + "procstat.cpu_time_system", + "procstat.involuntary_context_switches", + "procstat.memory_data", + "procstat.memory_rss", + "procstat.memory_usage", + "procstat.memory_vms", + "procstat.num_threads", + "procstat.read_count", + "procstat.voluntary_context_switches", + "procstat.cpu_time_user", + "procstat.num_fds", + "procstat.write_count", + ), + ) +} + +func checkGoldenFile(t *testing.T, configFile string, expectedFilePath string, options ...pmetrictest.CompareMetricsOption) { + f := otlpreceiver.NewFactory() + port := testutils.GetAvailablePort(t) + c := f.CreateDefaultConfig().(*otlpreceiver.Config) + c.GRPC.NetAddr.Endpoint = fmt.Sprintf("localhost:%d", port) + sink := &consumertest.MetricsSink{} + receiver, err := f.CreateMetricsReceiver(context.Background(), receivertest.NewNopCreateSettings(), c, sink) + require.NoError(t, err) + require.NoError(t, receiver.Start(context.Background(), componenttest.NewNopHost())) + t.Cleanup(func() { + require.NoError(t, receiver.Shutdown(context.Background())) + }) + logger, _ := zap.NewDevelopment() + + dockerHost := "0.0.0.0" + if runtime.GOOS == "darwin" { + dockerHost = "host.docker.internal" + } + p, err := testutils.NewCollectorContainer(). + WithConfigPath(filepath.Join("testdata", configFile)). + WithLogger(logger). + WithEnv(map[string]string{"OTLP_ENDPOINT": fmt.Sprintf("%s:%d", dockerHost, port)}). + Build() + require.NoError(t, err) + require.NoError(t, p.Start()) + t.Cleanup(func() { + require.NoError(t, p.Shutdown()) + }) + + expected, err := golden.ReadMetrics(filepath.Join("testdata", expectedFilePath)) + require.NoError(t, err) + + assert.EventuallyWithT(t, func(tt *assert.CollectT) { + if len(sink.AllMetrics()) == 0 { + assert.Fail(tt, "No metrics collected") + return + } + err := pmetrictest.CompareMetrics(expected, sink.AllMetrics()[len(sink.AllMetrics())-1], options...) + assert.NoError(tt, err) + }, 10*time.Second, 1*time.Second) } diff --git a/tests/receivers/smartagent/telegraf-procstat/testdata/all_expected.yaml b/tests/receivers/smartagent/telegraf-procstat/testdata/all_expected.yaml new file mode 100644 index 0000000000..6228750209 --- /dev/null +++ b/tests/receivers/smartagent/telegraf-procstat/testdata/all_expected.yaml @@ -0,0 +1,1325 @@ +resourceMetrics: + - resource: {} + scopeMetrics: + - metrics: + - gauge: + dataPoints: + - asInt: "1" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.involuntary_context_switches + - gauge: + dataPoints: + - asDouble: 0 + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.cpu_time_guest + - gauge: + dataPoints: + - asInt: "83968000" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_memory_locked_soft + - gauge: + dataPoints: + - asInt: "20" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.nice_priority + - gauge: + dataPoints: + - asInt: "16" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.write_count + - gauge: + dataPoints: + - asInt: "2147483647" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_cpu_time_hard + - gauge: + dataPoints: + - asDouble: 0 + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.cpu_time_idle + - gauge: + dataPoints: + - asDouble: 0 + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.cpu_time_irq + - gauge: + dataPoints: + - asInt: "135168" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.memory_stack + - gauge: + dataPoints: + - asInt: "0" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_nice_priority_hard + - gauge: + dataPoints: + - asInt: "910725120" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.memory_vms + - gauge: + dataPoints: + - asDouble: 0 + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.cpu_time_nice + - gauge: + dataPoints: + - asInt: "0" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_realtime_priority_hard + - gauge: + dataPoints: + - asInt: "86151168" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.memory_data + - gauge: + dataPoints: + - asInt: "8388608" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_memory_stack_soft + - gauge: + dataPoints: + - asInt: "1" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.pid + - gauge: + dataPoints: + - asInt: "2147483647" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_file_locks_hard + - gauge: + dataPoints: + - asInt: "0" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.memory_locked + - gauge: + dataPoints: + - asInt: "2147483647" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_memory_stack_hard + - gauge: + dataPoints: + - asInt: "2147483647" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_file_locks_soft + - gauge: + dataPoints: + - asDouble: 0.9599148035049438 + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.memory_usage + - gauge: + dataPoints: + - asInt: "13" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.num_threads + - gauge: + dataPoints: + - asInt: "0" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.memory_swap + - gauge: + dataPoints: + - asInt: "2147483647" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_cpu_time_soft + - gauge: + dataPoints: + - asInt: "2147483647" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_memory_vms_soft + - gauge: + dataPoints: + - asInt: "120311808" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.memory_rss + - gauge: + dataPoints: + - asInt: "2147483647" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_memory_data_hard + - gauge: + dataPoints: + - asInt: "0" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.read_bytes + - gauge: + dataPoints: + - asInt: "1048576" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_num_fds_soft + - gauge: + dataPoints: + - asInt: "0" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.signals_pending + - gauge: + dataPoints: + - asInt: "0" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.cpu_time + - gauge: + dataPoints: + - asInt: "10" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.num_fds + - gauge: + dataPoints: + - asDouble: 0 + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.cpu_time_iowait + - gauge: + dataPoints: + - asInt: "0" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.realtime_priority + - gauge: + dataPoints: + - asDouble: 0 + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.cpu_time_guest_nice + - gauge: + dataPoints: + - asInt: "2147483647" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_memory_rss_hard + - gauge: + dataPoints: + - asInt: "0" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_realtime_priority_soft + - gauge: + dataPoints: + - asInt: "2147483647" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_memory_data_soft + - gauge: + dataPoints: + - asDouble: 0 + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.cpu_time_soft_irq + - gauge: + dataPoints: + - asInt: "0" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.write_bytes + - gauge: + dataPoints: + - asInt: "83968000" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_memory_locked_hard + - gauge: + dataPoints: + - asDouble: 0.08 + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.cpu_time_user + - gauge: + dataPoints: + - asInt: "47790" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_signals_pending_soft + - gauge: + dataPoints: + - asInt: "114" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.read_count + - gauge: + dataPoints: + - asInt: "0" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_nice_priority_soft + - gauge: + dataPoints: + - asInt: "127" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.voluntary_context_switches + - gauge: + dataPoints: + - asInt: "47790" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_signals_pending_hard + - gauge: + dataPoints: + - asInt: "2147483647" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_memory_rss_soft + - gauge: + dataPoints: + - asInt: "1048576" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_num_fds_hard + - gauge: + dataPoints: + - asDouble: 0 + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.cpu_time_steal + - gauge: + dataPoints: + - asInt: "2147483647" + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.rlimit_memory_vms_hard + - gauge: + dataPoints: + - asDouble: 0.02 + attributes: + - key: exe + value: + stringValue: otelcol + - key: plugin + value: + stringValue: telegraf-procstat + - key: process_name + value: + stringValue: otelcol + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + - key: user + value: + stringValue: splunk-otel-collector + timeUnixNano: "1000000" + name: procstat.cpu_time_system + - gauge: + dataPoints: + - asInt: "1" + attributes: + - key: exe + value: + stringValue: otelcol + - key: pid_finder + value: + stringValue: native + - key: plugin + value: + stringValue: telegraf-procstat + - key: result + value: + stringValue: success + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + timeUnixNano: "1000000" + name: procstat_lookup.running + - gauge: + dataPoints: + - asInt: "0" + attributes: + - key: exe + value: + stringValue: otelcol + - key: pid_finder + value: + stringValue: native + - key: plugin + value: + stringValue: telegraf-procstat + - key: result + value: + stringValue: success + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + timeUnixNano: "1000000" + name: procstat_lookup.result_code + - gauge: + dataPoints: + - asInt: "1" + attributes: + - key: exe + value: + stringValue: otelcol + - key: pid_finder + value: + stringValue: native + - key: plugin + value: + stringValue: telegraf-procstat + - key: result + value: + stringValue: success + - key: system.type + value: + stringValue: procstat + - key: telegraf_type + value: + stringValue: untyped + timeUnixNano: "1000000" + name: procstat_lookup.pid_count + scope: {} diff --git a/tests/receivers/smartagent/telegraf-procstat/testdata/all_metrics_config.yaml b/tests/receivers/smartagent/telegraf-procstat/testdata/all_metrics_config.yaml index 5aa2013bb0..21f90e7734 100644 --- a/tests/receivers/smartagent/telegraf-procstat/testdata/all_metrics_config.yaml +++ b/tests/receivers/smartagent/telegraf-procstat/testdata/all_metrics_config.yaml @@ -9,9 +9,18 @@ exporters: tls: insecure: true +processors: + batch: # batch a set of telegraf outputs + timeout: 1s + groupbyattrs: # merge all resources into one. + keys: + - host.name + + service: pipelines: metrics: receivers: - smartagent/telegraf_procstat + processors: [batch, groupbyattrs] exporters: [otlp] diff --git a/tests/receivers/smartagent/telegraf-procstat/testdata/resource_metrics/all.yaml b/tests/receivers/smartagent/telegraf-procstat/testdata/resource_metrics/all.yaml deleted file mode 100644 index 5d3541e26c..0000000000 --- a/tests/receivers/smartagent/telegraf-procstat/testdata/resource_metrics/all.yaml +++ /dev/null @@ -1,507 +0,0 @@ -resource_metrics: - - scope_metrics: - - metrics: - - name: procstat.cpu_time - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.cpu_time_guest - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: DoubleGauge - - name: procstat.cpu_time_guest_nice - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: DoubleGauge - - name: procstat.cpu_time_idle - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: DoubleGauge - - name: procstat.cpu_time_iowait - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: DoubleGauge - - name: procstat.cpu_time_irq - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: DoubleGauge - - name: procstat.cpu_time_nice - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: DoubleGauge - - name: procstat.cpu_time_steal - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: DoubleGauge - - name: procstat.cpu_time_system - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: DoubleGauge - - name: procstat.cpu_time_user - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: DoubleGauge - - name: procstat.cpu_usage - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: DoubleGauge - - name: procstat.involuntary_context_switches - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.memory_data - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.memory_locked - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.memory_rss - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.memory_stack - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.memory_swap - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.memory_usage - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: DoubleGauge - - name: procstat.memory_vms - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.nice_priority - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.num_fds - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.num_threads - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.pid - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat_lookup.pid_count - attributes: - exe: otelcol - pid_finder: native - plugin: telegraf-procstat - result: success - system.type: procstat - telegraf_type: untyped - type: IntGauge - - name: procstat.cpu_time_soft_irq - type: DoubleGauge - attributes: - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - system.type: procstat - telegraf_type: untyped - user: splunk-otel-collector - - name: procstat_lookup.running - type: IntGauge - attributes: - exe: otelcol - pid_finder: native - plugin: telegraf-procstat - result: success - system.type: procstat - telegraf_type: untyped - - name: procstat_lookup.result_code - type: IntGauge - attributes: - exe: otelcol - pid_finder: native - plugin: telegraf-procstat - result: success - system.type: procstat - telegraf_type: untyped - - name: procstat.read_bytes - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.read_count - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.realtime_priority - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_cpu_time_hard - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_cpu_time_soft - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_file_locks_hard - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_file_locks_soft - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_memory_data_hard - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_memory_data_soft - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_memory_locked_hard - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_memory_locked_soft - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_memory_rss_hard - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_memory_rss_soft - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_memory_stack_hard - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_memory_stack_soft - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_memory_vms_hard - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_memory_vms_soft - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_nice_priority_hard - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_nice_priority_soft - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_num_fds_hard - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_num_fds_soft - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_realtime_priority_hard - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_realtime_priority_soft - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_signals_pending_hard - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.rlimit_signals_pending_soft - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.signals_pending - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.voluntary_context_switches - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.write_bytes - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge - - name: procstat.write_count - attributes: - system.type: procstat - exe: otelcol - plugin: telegraf-procstat - process_name: otelcol - telegraf_type: untyped - user: splunk-otel-collector - type: IntGauge