From 1687f5c44a175e61386ddf2c61be1e79a8126374 Mon Sep 17 00:00:00 2001 From: Kush Upadhyay Date: Wed, 24 Jul 2024 10:20:01 +0000 Subject: [PATCH 1/2] packages: add aws-otel-collector Signed-off-by: Kush Upadhyay --- ...ge-logger-and-extraconfig-file-paths.patch | 40 ++++++++++ packages/aws-otel-collector/Cargo.toml | 16 ++++ .../aws-otel-collector-tmpfiles.conf | 1 + .../aws-otel-collector.service | 14 ++++ .../aws-otel-collector.spec | 77 +++++++++++++++++++ .../aws-otel-collector.yaml | 24 ++++++ 6 files changed, 172 insertions(+) create mode 100644 packages/aws-otel-collector/0001-change-logger-and-extraconfig-file-paths.patch create mode 100644 packages/aws-otel-collector/Cargo.toml create mode 100644 packages/aws-otel-collector/aws-otel-collector-tmpfiles.conf create mode 100644 packages/aws-otel-collector/aws-otel-collector.service create mode 100644 packages/aws-otel-collector/aws-otel-collector.spec create mode 100644 packages/aws-otel-collector/aws-otel-collector.yaml diff --git a/packages/aws-otel-collector/0001-change-logger-and-extraconfig-file-paths.patch b/packages/aws-otel-collector/0001-change-logger-and-extraconfig-file-paths.patch new file mode 100644 index 000000000..0415e6ce2 --- /dev/null +++ b/packages/aws-otel-collector/0001-change-logger-and-extraconfig-file-paths.patch @@ -0,0 +1,40 @@ +From 1f1fc80e5869e125f5900aca76c3dbd3f1a24d81 Mon Sep 17 00:00:00 2001 +From: Kush Upadhyay +Date: Thu, 15 Aug 2024 09:12:55 +0000 +Subject: [PATCH] change logger and extraconfig file paths + +Signed-off-by: Kush Upadhyay +--- + pkg/extraconfig/extraconfig.go | 2 +- + pkg/logger/logger.go | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/pkg/extraconfig/extraconfig.go b/pkg/extraconfig/extraconfig.go +index 9c14d5f7..8ee7cbd9 100644 +--- a/pkg/extraconfig/extraconfig.go ++++ b/pkg/extraconfig/extraconfig.go +@@ -23,7 +23,7 @@ import ( + ) + + var ( +- UnixExtraConfigPath = "/opt/aws/aws-otel-collector/etc/extracfg.txt" ++ UnixExtraConfigPath = "/etc/aws-otel-collector/extracfg.txt" + WindowsExtraConfigPath = "C:\\ProgramData\\Amazon\\AWSOTelCollector\\Configs\\extracfg.txt" + ) + +diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go +index 9805eeab..7fcbab31 100644 +--- a/pkg/logger/logger.go ++++ b/pkg/logger/logger.go +@@ -31,7 +31,7 @@ import ( + ) + + var ( +- UnixLogPath = "/opt/aws/aws-otel-collector/logs/aws-otel-collector.log" ++ UnixLogPath = "/var/log/aws/aws-otel-collector.log" + WindowsLogPath = "C:\\ProgramData\\Amazon\\AWSOTelCollector\\Logs\\aws-otel-collector.log" + logfile = getLogFilePath() + lumberjackLogger = tryNewLumberJackLogger() +-- +2.40.1 + diff --git a/packages/aws-otel-collector/Cargo.toml b/packages/aws-otel-collector/Cargo.toml new file mode 100644 index 000000000..6aca0322b --- /dev/null +++ b/packages/aws-otel-collector/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "aws-otel-collector" +version = "0.1.0" +edition = "2021" +publish = false +build = "../build.rs" + +[lib] +path = "../packages.rs" + +[[package.metadata.build-package.external-files]] +url = "https://github.com/aws-observability/aws-otel-collector/archive/v0.40.0/aws-otel-collector-v0.40.0.tar.gz" +sha512 = "4dc90d798fc818f357c93424e3111697e6830a2dc9913fb71e754959ec4f6002be8f079220208cad93b3b6850d337174fa0e52f57d517364d004dd08bae97e14" + +[build-dependencies] +glibc = { path = "../glibc" } diff --git a/packages/aws-otel-collector/aws-otel-collector-tmpfiles.conf b/packages/aws-otel-collector/aws-otel-collector-tmpfiles.conf new file mode 100644 index 000000000..123f81eb0 --- /dev/null +++ b/packages/aws-otel-collector/aws-otel-collector-tmpfiles.conf @@ -0,0 +1 @@ +C /etc/aws-otel-collector.yaml - - - - - diff --git a/packages/aws-otel-collector/aws-otel-collector.service b/packages/aws-otel-collector/aws-otel-collector.service new file mode 100644 index 000000000..b8b215ff5 --- /dev/null +++ b/packages/aws-otel-collector/aws-otel-collector.service @@ -0,0 +1,14 @@ +[Unit] +Description=AWS OTEL collector +After=network-online.target configured.target +Wants=network-online.target configured.target + +[Service] +Type=simple +ExecStart=/usr/bin/aws-otel-collector --config /etc/aws-otel-collector.yaml +KillMode=process +Restart=always +RestartSec=5s + +[Install] +WantedBy=multi-user.target diff --git a/packages/aws-otel-collector/aws-otel-collector.spec b/packages/aws-otel-collector/aws-otel-collector.spec new file mode 100644 index 000000000..29143bde6 --- /dev/null +++ b/packages/aws-otel-collector/aws-otel-collector.spec @@ -0,0 +1,77 @@ +%global goproject github.com/aws-observability +%global gorepo aws-otel-collector +%global goimport %{goproject}/%{gorepo} + +Name: %{_cross_os}aws-otel-collector +Version: 0.40.0 +Release: 1%{?dist} +Summary: AWS Distro for OpenTelemetry Collector +License: Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND MIT AND MPL-2.0 +URL: https://github.com/aws-observability/aws-otel-collector +Source0: %{gorepo}-v%{version}.tar.gz +Source1: aws-otel-collector.service +Source2: aws-otel-collector-tmpfiles.conf +Source3: aws-otel-collector.yaml + +# Change log and extraconfig file paths from /opt to /var/log and /etc, respectively +Patch0001: 0001-change-logger-and-extraconfig-file-paths.patch + +BuildRequires: %{_cross_os}glibc-devel +Requires: %{name}(binary) + +%description +%{summary}. + +%package bin +Summary: Telemetry collector binary +Provides: %{name}(binary) +Requires: (%{_cross_os}image-feature(no-fips) and %{name}) +Conflicts: (%{_cross_os}image-feature(fips) or %{name}-fips-bin) + +%description bin +%{summary}. + +%package fips-bin +Summary: Telemetry collector binary, FIPS edition +Provides: %{name}(binary) +Requires: (%{_cross_os}image-feature(fips) and %{name}) +Conflicts: (%{_cross_os}image-feature(no-fips) or %{name}-bin) + +%description fips-bin +%{summary}. + +%prep +%autosetup -n %{gorepo}-%{version} -p1 + +%build +export GO_MAJOR="1.22" + +%set_cross_go_flags + +go build -ldflags "${GOLDFLAGS}" -o aws-otel-collector ./cmd/awscollector +gofips build -ldflags "${GOLDFLAGS}" -o fips/aws-otel-collector ./cmd/awscollector + +%install +install -D -p -m 0644 %{S:1} %{buildroot}%{_cross_unitdir}/aws-otel-collector.service + +install -d %{buildroot}%{_cross_tmpfilesdir} +install -p -m 0644 %{S:2} %{buildroot}%{_cross_tmpfilesdir} + +install -d %{buildroot}%{_cross_factorydir}%{_cross_sysconfdir} +install -p -m 0644 %{S:3} %{buildroot}%{_cross_factorydir}%{_cross_sysconfdir} + +install -d %{buildroot}{%{_cross_bindir},%{_cross_fips_bindir}} +install -p -m 0755 aws-otel-collector %{buildroot}%{_cross_bindir} +install -p -m 0755 fips/aws-otel-collector %{buildroot}%{_cross_fips_bindir} + +%files +%{_cross_attribution_file} +%{_cross_unitdir}/aws-otel-collector.service +%{_cross_tmpfilesdir}/aws-otel-collector-tmpfiles.conf +%{_cross_factorydir}%{_cross_sysconfdir}/aws-otel-collector.yaml + +%files bin +%{_cross_bindir}/aws-otel-collector + +%files fips-bin +%{_cross_fips_bindir}/aws-otel-collector diff --git a/packages/aws-otel-collector/aws-otel-collector.yaml b/packages/aws-otel-collector/aws-otel-collector.yaml new file mode 100644 index 000000000..84c55490b --- /dev/null +++ b/packages/aws-otel-collector/aws-otel-collector.yaml @@ -0,0 +1,24 @@ +receivers: + otlp: + protocols: + grpc: + endpoint: 127.0.0.1:4317 + +processors: + batch/traces: + batch/metrics: + +exporters: + otlp: + endpoint: 127.0.0.1:4318 + +service: + pipelines: + traces: + receivers: [otlp] + processors: [batch/traces] + exporters: [otlp] + metrics: + receivers: [otlp] + processors: [batch/metrics] + exporters: [otlp] From d2f348d5c1f0455cc1e571479cd46078f746db1d Mon Sep 17 00:00:00 2001 From: Kush Upadhyay Date: Wed, 24 Jul 2024 10:34:24 +0000 Subject: [PATCH 2/2] kits: add aws-otel-collector to core-kit Signed-off-by: Kush Upadhyay --- Cargo.lock | 8 ++++++++ Cargo.toml | 1 + kits/bottlerocket-core-kit/Cargo.toml | 1 + 3 files changed, 10 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index a087619e4..b3024d7b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,6 +23,13 @@ dependencies = [ "glibc", ] +[[package]] +name = "aws-otel-collector" +version = "0.1.0" +dependencies = [ + "glibc", +] + [[package]] name = "aws-signing-helper" version = "0.1.0" @@ -54,6 +61,7 @@ dependencies = [ "acpid", "amazon-ssm-agent", "aws-iam-authenticator", + "aws-otel-collector", "aws-signing-helper", "bash", "binutils", diff --git a/Cargo.toml b/Cargo.toml index 16e1a50b9..21aaa1bf9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ members = [ "packages/acpid", "packages/amazon-ssm-agent", "packages/aws-iam-authenticator", + "packages/aws-otel-collector", "packages/aws-signing-helper", "packages/bash", "packages/binutils", diff --git a/kits/bottlerocket-core-kit/Cargo.toml b/kits/bottlerocket-core-kit/Cargo.toml index 27d401a59..eee189f14 100644 --- a/kits/bottlerocket-core-kit/Cargo.toml +++ b/kits/bottlerocket-core-kit/Cargo.toml @@ -15,6 +15,7 @@ path = "../kit.rs" acpid = { path = "../../packages/acpid" } amazon-ssm-agent = { path = "../../packages/amazon-ssm-agent" } aws-iam-authenticator = { path = "../../packages/aws-iam-authenticator" } +aws-otel-collector = { path = "../../packages/aws-otel-collector" } aws-signing-helper = { path = "../../packages/aws-signing-helper" } bash = { path = "../../packages/bash" } binutils = { path = "../../packages/binutils" }