diff --git a/tests/installation/discovery_test.go b/tests/installation/discovery_test.go new file mode 100644 index 0000000000..86f3b6f3a4 --- /dev/null +++ b/tests/installation/discovery_test.go @@ -0,0 +1,312 @@ +// Copyright Splunk, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build installation + +package tests + +import ( + "fmt" + "io" + "os" + "path/filepath" + "sort" + "strings" + "syscall" + "testing" + "time" + + dockerContainer "github.com/docker/docker/api/types/container" + dockerMount "github.com/docker/docker/api/types/mount" + "github.com/stretchr/testify/require" + "github.com/testcontainers/testcontainers-go/wait" + + "github.com/signalfx/splunk-otel-collector/tests/testutils" +) + +func getPackagePath(t testing.TB, suffix string) string { + var paths []string + require.NoError( + t, filepath.Walk( + filepath.Join("..", "..", "dist"), + func(path string, info os.FileInfo, err error) error { + file := filepath.Base(path) + if strings.HasPrefix(file, "splunk-otel-collector") && strings.HasSuffix(file, fmt.Sprintf(".%s", suffix)) { + abs, e := filepath.Abs(path) + require.NoError(t, e) + paths = append(paths, abs) + } + return nil + }), + ) + if len(paths) == 0 { + t.Fatalf("no %s installer available: run `make %s-package` for this test.", suffix, suffix) + } + + sort.Strings(paths) + return paths[len(paths)-1] +} + +func TestDefaultConfigDDiscoversPostgres(t *testing.T) { + tc := testutils.NewTestcase(t, testutils.OTLPReceiverSinkBindToBridgeGateway) + defer tc.PrintLogsOnFailure() + defer tc.ShutdownOTLPReceiverSink() + + finfo, err := os.Stat("/var/run/docker.sock") + require.NoError(t, err) + fsys := finfo.Sys() + stat, ok := fsys.(*syscall.Stat_t) + require.True(t, ok) + dockerGID := fmt.Sprintf("%d", stat.Gid) + + treeBytes, err := os.ReadFile(filepath.Join(".", "testdata", "tree")) + require.NoError(t, err) + expectedTree := string(treeBytes) + + server := testutils.NewContainer().WithContext(filepath.Join("..", "receivers", "smartagent", "postgresql", "testdata", "server")).WithEnv( + map[string]string{"POSTGRES_DB": "test_db", "POSTGRES_USER": "postgres", "POSTGRES_PASSWORD": "postgres"}, + ).WithExposedPorts("5432:5432").WithName("postgres-server").WithNetworks( + "postgres", + ).WillWaitForPorts("5432").WillWaitForLogs("database system is ready to accept connections") + + client := testutils.NewContainer().WithContext(filepath.Join("..", "receivers", "smartagent", "postgresql", "testdata", "client")).WithEnv( + map[string]string{"POSTGRES_SERVER": "postgres-server"}, + ).WithName("postgres-client").WithNetworks("postgres").WillWaitForLogs("Beginning psql requests") + + _, stop := tc.Containers(server, client) + defer stop() + + waitForSystemd := wait.NewExecStrategy([]string{"systemctl", "status", "1"}) + waitForSystemd.PollInterval = time.Second + waitForSystemd.WithResponseMatcher( + func(body io.Reader) bool { + b, err := io.ReadAll(body) + require.NoError(t, err) + return strings.Contains(string(b), "Active: active (running)") + }) + + for _, packageType := range []string{"deb", "rpm"} { + t.Run(packageType, func(t *testing.T) { + defer tc.OTLPReceiverSink.Reset() + packagePath := getPackagePath(t, packageType) + cc, shutdown := tc.SplunkOtelCollectorContainer( + "", func(c testutils.Collector) testutils.Collector { + cc := c.(*testutils.CollectorContainer) + cc.Container.Privileged = true + cc.Container = cc.Container.WithContext( + filepath.Join(".", "testdata", "systemd"), + ).WithDockerfile( + fmt.Sprintf("Dockerfile.%s", packageType), + ).WithHostConfigModifier(func(config *dockerContainer.HostConfig) { + config.CgroupnsMode = dockerContainer.CgroupnsModeHost + config.CapAdd = append(config.CapAdd, "NET_RAW") + config.GroupAdd = []string{dockerGID} + config.Mounts = []dockerMount.Mount{ + {Source: "/sys/fs/cgroup", Target: "/sys/fs/cgroup", Type: dockerMount.TypeBind}, + {Source: packagePath, Target: fmt.Sprintf("/opt/otel/splunk-otel-collector.%s", packageType), Type: dockerMount.TypeBind}, + {Source: "/var/run/docker.sock", Target: "/opt/docker/docker.sock", ReadOnly: true, Type: dockerMount.TypeBind}, + } + }).WithBuildArgs(map[string]*string{"DOCKER_GID": &dockerGID}).WithNetworks("postgres") + cc.Container.WillWaitForLogs() + cc.Container.WaitingFor = append(cc.Container.WaitingFor, waitForSystemd) + return cc.WithArgs("") + }, + ) + + var installCmd []string + switch packageType { + case "deb": + installCmd = []string{"apt-get", "install", "-f", "/opt/otel/splunk-otel-collector.deb", "-y"} + case "rpm": + installCmd = []string{"dnf", "install", "/opt/otel/splunk-otel-collector.rpm", "-y"} + } + + defer shutdown() + + for _, exec := range []struct { + wait time.Duration + cmd []string + }{ + {wait: 5 * time.Minute, cmd: installCmd}, + {wait: 10 * time.Second, cmd: []string{"usermod", "-aG", "docker", "splunk-otel-collector"}}, + {wait: 20 * time.Second, cmd: []string{"systemctl", "import-environment", "OTLP_ENDPOINT"}}, + {wait: 20 * time.Second, cmd: []string{"systemctl", "daemon-reload"}}, + {wait: 10 * time.Second, cmd: []string{"systemctl", "start", "splunk-otel-collector"}}, + } { + rc, stdout, stderr := cc.Container.AssertExec(t, exec.wait, exec.cmd...) + require.Zero(t, rc, fmt.Sprintf("%s failed. stdout: %q, stderr: %q", strings.Join(exec.cmd, " "), stdout, stderr)) + } + + // --discovery default time + time.Sleep(10 * time.Second) + + expectedResourceMetrics := tc.ResourceMetrics("postgres-and-internal.yaml") + require.NoError(t, tc.OTLPReceiverSink.AssertAllMetricsReceived(t, *expectedResourceMetrics, 30*time.Second)) + + expectedInitial := map[string]any{ + "file": map[string]any{}, + "splunk.configd": map[string]any{ + "exporters": map[string]any{ + "otlp": map[string]any{ + "endpoint": "${env:OTLP_ENDPOINT}", + "tls": map[string]any{ + "insecure": true, + }, + }, + }, + "extensions": map[string]any{}, + "processors": map[string]any{}, + "receivers": map[string]any{ + "prometheus/internal": map[string]any{ + "config": map[string]any{ + "scrape_configs": []any{ + map[string]any{ + "job_name": "otel-collector", + "metric_relabel_configs": []any{ + map[string]any{ + "action": "drop", + "regex": ".*grpc_io.*", + "source_labels": []any{"__name__"}, + }, + }, + "scrape_interval": "10s", + "static_configs": []any{ + map[string]any{ + "targets": []any{"0.0.0.0:8888"}, + }, + }, + }, + }, + }, + }, + }, + "service": map[string]any{ + "pipelines": map[string]any{ + "metrics": map[string]any{ + "exporters": []any{"otlp"}, + "receivers": []any{"prometheus/internal"}, + }, + }, + }, + }, + "splunk.discovery": map[string]any{ + "extensions": map[string]any{ + "docker_observer": map[string]any{ + "endpoint": "unix:///opt/docker/docker.sock", + }, + }, + "receivers": map[string]any{ + "receiver_creator/discovery": map[string]any{ + "receivers": map[string]any{ + "smartagent/postgresql": map[string]any{ + "config": map[string]any{ + "connectionString": "sslmode=disable user={{.username}} password={{.password}}", + "masterDBName": "test_db", + "params": map[string]any{ + "password": "test_password", + "username": "test_user", + }, + "type": "postgresql", + }, + "resource_attributes": map[string]any{}, + "rule": "type == \"container\" and port == 5432", + }, + }, + "watch_observers": []any{"docker_observer"}}}, + "service": map[string]any{ + "extensions/splunk.discovery": []any{"docker_observer"}, + "receivers/splunk.discovery": []any{"receiver_creator/discovery"}, + }, + }, + } + require.Equal(t, expectedInitial, cc.InitialConfig(t, 55554)) + + expectedEffective := map[string]any{ + "exporters": map[string]any{ + "otlp": map[string]any{ + "endpoint": tc.OTLPEndpoint, + "tls": map[string]any{ + "insecure": true, + }, + }, + }, + "extensions": map[string]any{ + "docker_observer": map[string]any{ + "endpoint": "unix:///opt/docker/docker.sock", + }, + }, + "processors": map[string]any{}, + "receivers": map[string]any{ + "prometheus/internal": map[string]any{ + "config": map[string]any{ + "scrape_configs": []any{ + map[string]any{ + "job_name": "otel-collector", + "metric_relabel_configs": []any{ + map[string]any{ + "action": "drop", + "regex": ".*grpc_io.*", + "source_labels": []any{"__name__"}, + }, + }, + "scrape_interval": "10s", + "static_configs": []any{ + map[string]any{ + "targets": []any{"0.0.0.0:8888"}, + }, + }, + }, + }, + }, + }, + "receiver_creator/discovery": map[string]any{ + "receivers": map[string]any{ + "smartagent/postgresql": map[string]any{ + "config": map[string]any{ + "connectionString": "sslmode=disable user={{.username}} password={{.password}}", + "masterDBName": "test_db", + "params": map[string]any{ + "password": "", + "username": "", + }, + "type": "postgresql", + }, + "resource_attributes": map[string]any{}, + "rule": "type == \"container\" and port == 5432", + }, + }, + "watch_observers": []any{"docker_observer"}, + }, + }, + "service": map[string]any{ + "extensions": []any{"docker_observer"}, + "pipelines": map[string]any{ + "metrics": map[string]any{ + "exporters": []any{"otlp"}, + "receivers": []any{ + "prometheus/internal", + "receiver_creator/discovery", + }, + }, + }, + }, + } + require.Equal(t, expectedEffective, cc.EffectiveConfig(t, 55554)) + + rc, stdout, stderr := cc.Container.AssertExec(t, 5*time.Second, "tree", "/etc/otel/collector/config.d") + require.Zero(t, rc, fmt.Sprintf("tree failed. stdout: %q, stderr: %q", stdout, stderr)) + require.Equal(t, expectedTree, stdout) + }) + } +} diff --git a/tests/installation/testdata/resource_metrics/postgres-and-internal.yaml b/tests/installation/testdata/resource_metrics/postgres-and-internal.yaml new file mode 100644 index 0000000000..e7a73b2984 --- /dev/null +++ b/tests/installation/testdata/resource_metrics/postgres-and-internal.yaml @@ -0,0 +1,418 @@ +resource_metrics: + - attributes: + container.image.name: + container.name: postgres-server + scope_metrics: + - metrics: + - name: postgres_query_count + attributes: + system.type: postgresql + database: postgres + postgres_port: "5432" + user: postgres + type: DoubleMonotonicCumulativeSum + - name: postgres_query_count + attributes: + system.type: postgresql + database: postgres + postgres_port: "5432" + user: test_user + type: DoubleMonotonicCumulativeSum + - name: postgres_query_count + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + user: postgres + type: DoubleMonotonicCumulativeSum + - name: postgres_query_count + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + user: test_user + type: DoubleMonotonicCumulativeSum + - name: postgres_query_time + attributes: + system.type: postgresql + database: postgres + postgres_port: "5432" + user: postgres + type: DoubleMonotonicCumulativeSum + - name: postgres_query_time + attributes: + system.type: postgresql + database: postgres + postgres_port: "5432" + user: test_user + type: DoubleMonotonicCumulativeSum + - name: postgres_query_time + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + user: postgres + type: DoubleMonotonicCumulativeSum + - name: postgres_query_time + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + user: test_user + type: DoubleMonotonicCumulativeSum + - name: postgres_block_hit_ratio + attributes: + system.type: postgresql + database: test_db + index: table_two_pkey + postgres_port: "5432" + schemaname: test_schema + table: table_two + type: user + type: DoubleGauge + - name: postgres_block_hit_ratio + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + type: DoubleGauge + - name: postgres_block_hit_ratio + attributes: + system.type: postgresql + database: postgres + postgres_port: "5432" + type: DoubleGauge + - name: postgres_deadlocks + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + type: DoubleMonotonicCumulativeSum + - name: postgres_sessions + attributes: + system.type: postgresql + database: + postgres_port: "5432" + state: + type: DoubleGauge + - name: postgres_deadlocks + attributes: + system.type: postgresql + database: postgres + postgres_port: "5432" + type: DoubleMonotonicCumulativeSum + - name: postgres_database_size + attributes: + system.type: postgresql + database: postgres + postgres_port: "5432" + type: DoubleGauge + - name: postgres_database_size + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + type: DoubleGauge + - name: postgres_block_hit_ratio + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + schemaname: test_schema + table: table_one + type: user + type: DoubleGauge + - name: postgres_block_hit_ratio + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + schemaname: test_schema + table: table_two + type: user + type: DoubleGauge + - name: postgres_block_hit_ratio + attributes: + system.type: postgresql + database: test_db + index: table_one_pkey + postgres_port: "5432" + schemaname: test_schema + table: table_one + type: user + type: DoubleGauge + - name: postgres_rows_inserted + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + schemaname: test_schema + table: table_two + tablespace: "" + type: user + type: DoubleMonotonicCumulativeSum + - name: postgres_rows_updated + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + schemaname: test_schema + table: table_two + tablespace: "" + type: user + type: DoubleMonotonicCumulativeSum + - name: postgres_rows_deleted + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + schemaname: test_schema + table: table_two + tablespace: "" + type: user + type: DoubleMonotonicCumulativeSum + - name: postgres_sequential_scans + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + schemaname: test_schema + table: table_two + tablespace: "" + type: user + type: DoubleMonotonicCumulativeSum + - name: postgres_index_scans + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + schemaname: test_schema + table: table_two + tablespace: "" + type: user + type: DoubleMonotonicCumulativeSum + - name: postgres_table_size + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + schemaname: test_schema + table: table_two + tablespace: "" + type: user + type: DoubleGauge + - name: postgres_live_rows + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + schemaname: test_schema + table: table_two + tablespace: "" + type: user + type: DoubleGauge + - name: postgres_live_rows + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + schemaname: test_schema + table: table_one + tablespace: "" + type: user + type: DoubleGauge + - name: postgres_rows_inserted + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + schemaname: test_schema + table: table_one + tablespace: "" + type: user + type: DoubleMonotonicCumulativeSum + - name: postgres_rows_updated + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + schemaname: test_schema + table: table_one + tablespace: "" + type: user + type: DoubleMonotonicCumulativeSum + - name: postgres_rows_deleted + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + schemaname: test_schema + table: table_one + tablespace: "" + type: user + type: DoubleMonotonicCumulativeSum + - name: postgres_sequential_scans + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + schemaname: test_schema + table: table_one + tablespace: "" + type: user + type: DoubleMonotonicCumulativeSum + - name: postgres_index_scans + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + schemaname: test_schema + table: table_one + tablespace: "" + type: user + type: DoubleMonotonicCumulativeSum + - name: postgres_table_size + attributes: + system.type: postgresql + database: test_db + postgres_port: "5432" + schemaname: test_schema + table: table_one + tablespace: "" + type: user + type: DoubleGauge + - attributes: + http.scheme: http + net.host.port: "8888" + service.instance.id: 0.0.0.0:8888 + service.name: otel-collector + scope_metrics: + - instrumentation_scope: + attributes: {} + name: otelcol/prometheusreceiver + version: + metrics: + - attributes: + exporter: otlp + service_instance_id: + service_name: otelcol + service_version: + description: Current size of the retry queue (in batches) + name: otelcol_exporter_queue_size + type: DoubleGauge + - attributes: + service_instance_id: + service_name: otelcol + service_version: + description: Bytes of allocated heap objects (see 'go doc runtime.MemStats.HeapAlloc') + name: otelcol_process_runtime_heap_alloc_bytes + type: DoubleGauge + - attributes: + service_instance_id: + service_name: otelcol + service_version: + description: Cumulative bytes allocated for heap objects (see 'go doc runtime.MemStats.TotalAlloc') + name: otelcol_process_runtime_total_alloc_bytes + type: DoubleMonotonicCumulativeSum + - attributes: + service_instance_id: + service_name: otelcol + service_version: + description: Uptime of the process + name: otelcol_process_uptime + type: DoubleMonotonicCumulativeSum + - attributes: + exporter: otlp + service_instance_id: + service_name: otelcol + service_version: + description: Number of metric points successfully sent to destination. + name: otelcol_exporter_sent_metric_points + type: DoubleMonotonicCumulativeSum + - description: Duration of the scrape + name: scrape_duration_seconds + type: DoubleGauge + unit: seconds + - attributes: + receiver: + service_instance_id: + service_name: otelcol + service_version: + transport: internal + description: Number of metric points that could not be pushed into the pipeline. + name: otelcol_receiver_refused_metric_points + type: DoubleMonotonicCumulativeSum + - description: The number of samples remaining after metric relabeling was applied + name: scrape_samples_post_metric_relabeling + type: DoubleGauge + - attributes: + exporter: otlp + service_instance_id: + service_name: otelcol + service_version: + description: Number of log records failed to be added to the sending queue. + name: otelcol_exporter_enqueue_failed_log_records + type: DoubleMonotonicCumulativeSum + - attributes: + exporter: otlp + service_instance_id: + service_name: otelcol + service_version: + description: Number of metric points failed to be added to the sending queue. + name: otelcol_exporter_enqueue_failed_metric_points + type: DoubleMonotonicCumulativeSum + - attributes: + exporter: otlp + service_instance_id: + service_name: otelcol + service_version: + description: Fixed capacity of the retry queue (in batches) + name: otelcol_exporter_queue_capacity + type: DoubleGauge + - attributes: + service_instance_id: + service_name: otelcol + service_version: + description: Total CPU user and system time in seconds + name: otelcol_process_cpu_seconds + type: DoubleMonotonicCumulativeSum + - description: The scraping was successful + name: up + type: DoubleGauge + - description: The number of samples the target exposed + name: scrape_samples_scraped + type: DoubleGauge + - description: The approximate number of new series in this scrape + name: scrape_series_added + type: DoubleGauge + - attributes: + exporter: otlp + service_instance_id: + service_name: otelcol + service_version: + description: Number of spans failed to be added to the sending queue. + name: otelcol_exporter_enqueue_failed_spans + type: DoubleMonotonicCumulativeSum + - attributes: + service_instance_id: + service_name: otelcol + service_version: + description: Total physical memory (resident set size) + name: otelcol_process_memory_rss + type: DoubleGauge + - attributes: + service_instance_id: + service_name: otelcol + service_version: + description: Total bytes of memory obtained from the OS (see 'go doc runtime.MemStats.Sys') + name: otelcol_process_runtime_total_sys_memory_bytes + type: DoubleGauge + - attributes: + receiver: + service_instance_id: + service_name: otelcol + service_version: + transport: internal + description: Number of metric points successfully pushed into the pipeline. + name: otelcol_receiver_accepted_metric_points + type: DoubleMonotonicCumulativeSum diff --git a/tests/installation/testdata/systemd/Dockerfile.deb b/tests/installation/testdata/systemd/Dockerfile.deb new file mode 100644 index 0000000000..57d2fe1ace --- /dev/null +++ b/tests/installation/testdata/systemd/Dockerfile.deb @@ -0,0 +1,33 @@ +# A debian image with systemd enabled. Must be run with: +# `-d --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro` flags +FROM debian:bullseye +ARG DOCKER_GID=998 + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get update &&\ + apt-get install -yq ca-certificates procps systemd iproute2 curl tree + +ENV container docker +RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \ + "systemd-tmpfiles-setup.service" ] || rm -f $i; done); \ + rm -f /lib/systemd/system/multi-user.target.wants/*;\ + rm -f /lib/systemd/system/local-fs.target.wants/*; \ + rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ + rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ + rm -f /lib/systemd/system/anaconda.target.wants/*; + +RUN systemctl set-default multi-user.target +ENV init /lib/systemd/systemd + +RUN groupadd -g ${DOCKER_GID} docker + +COPY --chown=999 service.yaml /etc/otel/collector/config.d/service.yaml +COPY --chown=999 otlp-exporter.yaml /etc/otel/collector/config.d/exporters/otlp-exporter.yaml +COPY --chown=999 prometheus-internal.yaml /etc/otel/collector/config.d/receivers/prometheus-internal.yaml +COPY --chown=999 properties.discovery.yaml /etc/otel/collector/config.d/properties.discovery.yaml +COPY --chown=999 splunk-otel-collector.conf /etc/otel/collector/splunk-otel-collector.conf + +VOLUME [ "/sys/fs/cgroup" ] + +ENTRYPOINT ["/lib/systemd/systemd"] diff --git a/tests/installation/testdata/systemd/Dockerfile.rpm b/tests/installation/testdata/systemd/Dockerfile.rpm new file mode 100644 index 0000000000..2a7cf66c7b --- /dev/null +++ b/tests/installation/testdata/systemd/Dockerfile.rpm @@ -0,0 +1,31 @@ +# A centos9 image with systemd enabled. Must be run with: +# `-d --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro` flags +FROM quay.io/centos/centos:stream9 +ARG DOCKER_GID=998 + +ENV container docker + +RUN groupadd -g ${DOCKER_GID} docker + +RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial +RUN echo 'fastestmirror=1' >> /etc/yum.conf +RUN dnf install -y procps initscripts systemd tree + +RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i = \ + "systemd-tmpfiles-setup.service" ] || rm -f $i; done); \ + rm -f /lib/systemd/system/multi-user.target.wants/*;\ + rm -f /lib/systemd/system/local-fs.target.wants/*; \ + rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ + rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ + rm -f /lib/systemd/system/basic.target.wants/*;\ + rm -f /lib/systemd/system/anaconda.target.wants/*; + +COPY --chown=999 service.yaml /etc/otel/collector/config.d/service.yaml +COPY --chown=999 otlp-exporter.yaml /etc/otel/collector/config.d/exporters/otlp-exporter.yaml +COPY --chown=999 prometheus-internal.yaml /etc/otel/collector/config.d/receivers/prometheus-internal.yaml +COPY --chown=999 properties.discovery.yaml /etc/otel/collector/config.d/properties.discovery.yaml +COPY --chown=999 splunk-otel-collector.conf /etc/otel/collector/splunk-otel-collector.conf + +VOLUME [ "/sys/fs/cgroup" ] + +ENTRYPOINT ["/usr/sbin/init"] diff --git a/tests/installation/testdata/systemd/otlp-exporter.yaml b/tests/installation/testdata/systemd/otlp-exporter.yaml new file mode 100644 index 0000000000..45af5ad873 --- /dev/null +++ b/tests/installation/testdata/systemd/otlp-exporter.yaml @@ -0,0 +1,4 @@ +otlp: + endpoint: "${env:OTLP_ENDPOINT}" + tls: + insecure: true diff --git a/tests/installation/testdata/systemd/prometheus-internal.yaml b/tests/installation/testdata/systemd/prometheus-internal.yaml new file mode 100644 index 0000000000..cac24adfdd --- /dev/null +++ b/tests/installation/testdata/systemd/prometheus-internal.yaml @@ -0,0 +1,11 @@ +prometheus/internal: + config: + scrape_configs: + - job_name: 'otel-collector' + scrape_interval: 10s + static_configs: + - targets: ['0.0.0.0:8888'] + metric_relabel_configs: + - source_labels: [ __name__ ] + regex: '.*grpc_io.*' + action: drop \ No newline at end of file diff --git a/tests/installation/testdata/systemd/properties.discovery.yaml b/tests/installation/testdata/systemd/properties.discovery.yaml new file mode 100644 index 0000000000..f2fdf1a9aa --- /dev/null +++ b/tests/installation/testdata/systemd/properties.discovery.yaml @@ -0,0 +1,8 @@ +splunk.discovery: + receivers: + smartagent/postgresql: + config: + masterDBName: test_db + params: + username: test_user + password: test_password diff --git a/tests/installation/testdata/systemd/service.yaml b/tests/installation/testdata/systemd/service.yaml new file mode 100644 index 0000000000..d89bf2822c --- /dev/null +++ b/tests/installation/testdata/systemd/service.yaml @@ -0,0 +1,4 @@ +pipelines: + metrics: + receivers: [prometheus/internal] + exporters: [otlp] diff --git a/tests/installation/testdata/systemd/splunk-otel-collector.conf b/tests/installation/testdata/systemd/splunk-otel-collector.conf new file mode 100644 index 0000000000..b31baac12c --- /dev/null +++ b/tests/installation/testdata/systemd/splunk-otel-collector.conf @@ -0,0 +1,4 @@ +OTELCOL_OPTIONS="--configd --discovery" +SPLUNK_DISCOVERY_LOG_LEVEL=debug +SPLUNK_DISCOVERY_EXTENSIONS_docker_observer_CONFIG_endpoint="unix:///opt/docker/docker.sock" +SPLUNK_CONFIG=/dev/null diff --git a/tests/installation/testdata/tree b/tests/installation/testdata/tree new file mode 100644 index 0000000000..0b9bb9ba90 --- /dev/null +++ b/tests/installation/testdata/tree @@ -0,0 +1,18 @@ +/etc/otel/collector/config.d +|-- exporters +| `-- otlp-exporter.yaml +|-- extensions +| |-- docker-observer.discovery.yaml +| |-- host-observer.discovery.yaml +| `-- k8s-observer.discovery.yaml +|-- processors +|-- properties.discovery.yaml +|-- properties.discovery.yaml.example +|-- receivers +| |-- prometheus-internal.yaml +| |-- smartagent-collectd-mysql.discovery.yaml +| |-- smartagent-collectd-nginx.discovery.yaml +| `-- smartagent-postgresql.discovery.yaml +`-- service.yaml + +4 directories, 11 files