diff --git a/Dockerfile b/Dockerfile index e2e0d8b334..d640268786 100644 --- a/Dockerfile +++ b/Dockerfile @@ -92,12 +92,12 @@ ENV PATH="${PATH}:/usr/local/go/bin" WORKDIR /work -# 1. Download dependencies for the main repository +# 1. Copy go.mod files for both main and submodule COPY go.mod go.sum ./ -RUN go mod download - -# 2. Download dependencies for the OTEL submodule COPY ./submodules/opentelemetry-operations-collector/go.mod ./submodules/opentelemetry-operations-collector/go.sum submodules/opentelemetry-operations-collector/ + +# 2. Download dependencies +RUN go mod download RUN cd submodules/opentelemetry-operations-collector && go mod download # Copy full source code @@ -111,13 +111,8 @@ RUN \ ./builds/otel.sh /work/cache/ # 4. Build ops-agent-engine (CGO disabled) -RUN . VERSION && \ - BUILD_INFO_IMPORT_PATH="github.com/GoogleCloudPlatform/ops-agent/internal/version" && \ - BUILD_X1="-X ${BUILD_INFO_IMPORT_PATH}.BuildDistro=sles12" && \ - BUILD_X2="-X ${BUILD_INFO_IMPORT_PATH}.Version=${PKG_VERSION}" && \ - LD_FLAGS="-s -w ${BUILD_X1} ${BUILD_X2}" && \ - CGO_ENABLED=0 go build -buildvcs=false -o "/work/google_cloud_ops_agent_engine" \ - -ldflags "${LD_FLAGS}" \ +RUN CGO_ENABLED=0 go build -buildvcs=false -o "/work/google_cloud_ops_agent_engine" \ + -ldflags "-s -w" \ github.com/GoogleCloudPlatform/ops-agent/cmd/google_cloud_ops_agent_engine # 5. Build ops_agent plugin helper (CGO disabled) @@ -178,7 +173,7 @@ COPY . /work COPY --from=go-build /work/google_cloud_ops_agent_engine /work/google_cloud_ops_agent_engine COPY --from=go-build /work/cache /work/cache -COPY ./confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml +COPY ./submodules/opentelemetry-operations-collector/confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml COPY --from=centos8-build-systemd /work/cache /work/cache @@ -230,7 +225,7 @@ COPY . /work COPY --from=go-build /work/google_cloud_ops_agent_engine /work/google_cloud_ops_agent_engine COPY --from=go-build /work/cache /work/cache -COPY ./confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml +COPY ./submodules/opentelemetry-operations-collector/confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml COPY --from=rockylinux9-build-systemd /work/cache /work/cache @@ -282,7 +277,7 @@ COPY . /work COPY --from=go-build /work/google_cloud_ops_agent_engine /work/google_cloud_ops_agent_engine COPY --from=go-build /work/cache /work/cache -COPY ./confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml +COPY ./submodules/opentelemetry-operations-collector/confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml COPY --from=rockylinux10-build-systemd /work/cache /work/cache @@ -331,7 +326,7 @@ COPY . /work COPY --from=go-build /work/google_cloud_ops_agent_engine /work/google_cloud_ops_agent_engine COPY --from=go-build /work/cache /work/cache -COPY ./confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml +COPY ./submodules/opentelemetry-operations-collector/confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml COPY --from=bookworm-build-systemd /work/cache /work/cache @@ -380,7 +375,7 @@ COPY . /work COPY --from=go-build /work/google_cloud_ops_agent_engine /work/google_cloud_ops_agent_engine COPY --from=go-build /work/cache /work/cache -COPY ./confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml +COPY ./submodules/opentelemetry-operations-collector/confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml COPY --from=bullseye-build-systemd /work/cache /work/cache @@ -429,7 +424,7 @@ COPY . /work COPY --from=go-build /work/google_cloud_ops_agent_engine /work/google_cloud_ops_agent_engine COPY --from=go-build /work/cache /work/cache -COPY ./confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml +COPY ./submodules/opentelemetry-operations-collector/confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml COPY --from=trixie-build-systemd /work/cache /work/cache @@ -485,7 +480,7 @@ COPY . /work COPY --from=go-build /work/google_cloud_ops_agent_engine /work/google_cloud_ops_agent_engine COPY --from=go-build /work/cache /work/cache -COPY ./confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml +COPY ./submodules/opentelemetry-operations-collector/confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml COPY --from=sles12-build-systemd /work/cache /work/cache @@ -535,7 +530,7 @@ COPY . /work COPY --from=go-build /work/google_cloud_ops_agent_engine /work/google_cloud_ops_agent_engine COPY --from=go-build /work/cache /work/cache -COPY ./confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml +COPY ./submodules/opentelemetry-operations-collector/confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml COPY --from=sles15-build-systemd /work/cache /work/cache @@ -585,7 +580,7 @@ COPY . /work COPY --from=go-build /work/google_cloud_ops_agent_engine /work/google_cloud_ops_agent_engine COPY --from=go-build /work/cache /work/cache -COPY ./confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml +COPY ./submodules/opentelemetry-operations-collector/confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml COPY --from=sles16-build-systemd /work/cache /work/cache @@ -634,7 +629,7 @@ COPY . /work COPY --from=go-build /work/google_cloud_ops_agent_engine /work/google_cloud_ops_agent_engine COPY --from=go-build /work/cache /work/cache -COPY ./confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml +COPY ./submodules/opentelemetry-operations-collector/confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml COPY --from=jammy-build-systemd /work/cache /work/cache @@ -683,7 +678,7 @@ COPY . /work COPY --from=go-build /work/google_cloud_ops_agent_engine /work/google_cloud_ops_agent_engine COPY --from=go-build /work/cache /work/cache -COPY ./confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml +COPY ./submodules/opentelemetry-operations-collector/confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml COPY --from=noble-build-systemd /work/cache /work/cache @@ -732,7 +727,7 @@ COPY . /work COPY --from=go-build /work/google_cloud_ops_agent_engine /work/google_cloud_ops_agent_engine COPY --from=go-build /work/cache /work/cache -COPY ./confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml +COPY ./submodules/opentelemetry-operations-collector/confgenerator/default-config.yaml /work/cache/etc/google-cloud-ops-agent/config.yaml COPY --from=questing-build-systemd /work/cache /work/cache diff --git a/Dockerfile.windows b/Dockerfile.windows index 7853cd1275..d408cb5c12 100644 --- a/Dockerfile.windows +++ b/Dockerfile.windows @@ -55,7 +55,8 @@ COPY submodules/opentelemetry-operations-collector /work/submodules/opentelemetr WORKDIR /work/submodules/opentelemetry-operations-collector/otelopscol -RUN & ./build.ps1 -outDir /work/out/bin +RUN Get-Content ../../../VERSION | Where-Object length | ForEach-Object { Invoke-Expression "\`$env:\`$_" }; ` + & ./build.ps1 -outDir /work/out/bin -version $env:PKG_VERSION -buildDistro $env:BUILD_DISTRO ############################################################################### # Config generator/service installer @@ -67,10 +68,9 @@ COPY . /work ARG WINDOWS_VERSION ARG BUILD_DISTRO=windows-$WINDOWS_VERSION -RUN Get-Content VERSION | Where-Object length | ForEach-Object { Invoke-Expression "`$env:$_" }; ` - go build -o bin/google-cloud-ops-agent.exe -ldflags \"-X github.com/GoogleCloudPlatform/ops-agent/internal/version.BuildDistro=$env:BUILD_DISTRO -X github.com/GoogleCloudPlatform/ops-agent/internal/version.Version=$env:PKG_VERSION\" ./cmd/ops_agent_windows; ` +RUN go build -o bin/google-cloud-ops-agent.exe -ldflags "-s -w" ./cmd/ops_agent_windows; ` Copy-Item -Path bin/google-cloud-ops-agent.exe -Destination /work/out/bin/; ` - Copy-Item -Path confgenerator/default-config.yaml -Destination /work/out/config/config.yaml; + Copy-Item -Path submodules/opentelemetry-operations-collector/confgenerator/default-config.yaml -Destination /work/out/config/config.yaml; ############################################################################### @@ -87,7 +87,7 @@ COPY . /work ARG WINDOWS_VERSION ARG BUILD_DISTRO=windows-$WINDOWS_VERSION RUN Get-Content VERSION | Where-Object length | ForEach-Object { Invoke-Expression "`$env:$_" }; ` - go build -o bin/ops_agent.exe -ldflags \"-X github.com/GoogleCloudPlatform/ops-agent/internal/version.BuildDistro=$env:BUILD_DISTRO -X github.com/GoogleCloudPlatform/ops-agent/internal/version.Version=$env:PKG_VERSION\" ./cmd/ops_agent_uap_plugin; ` + go build -o bin/ops_agent.exe -ldflags "-s -w" ./cmd/ops_agent_uap_plugin; ` Copy-Item -Path bin/ops_agent.exe -Destination /work/out/bin/; ` $env:PKG_VERSION | Out-File -FilePath /work/out/bin/OPS_AGENT_VERSION -Encoding UTF8; diff --git a/apps/builtinconf.go b/apps/builtinconf.go deleted file mode 100644 index 558d33d2b6..0000000000 --- a/apps/builtinconf.go +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2021 Google LLC -// -// 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. - -package apps - -import cg "github.com/GoogleCloudPlatform/ops-agent/confgenerator" - -func init() { - cg.BuiltInConfStructs = map[string]*cg.UnifiedConfig{ - "linux": { - Logging: &cg.Logging{ - Receivers: map[string]cg.LoggingReceiver{ - "syslog": &cg.LoggingReceiverFiles{ - ConfigComponent: cg.ConfigComponent{Type: "files"}, - IncludePaths: []string{"/var/log/messages", "/var/log/syslog"}, - }, - }, - Processors: map[string]cg.LoggingProcessor{}, - Service: &cg.LoggingService{ - Pipelines: map[string]*cg.Pipeline{ - "default_pipeline": { - ReceiverIDs: []string{"syslog"}, - }, - }, - }, - }, - Metrics: &cg.Metrics{ - Receivers: map[string]cg.MetricsReceiver{ - "hostmetrics": &MetricsReceiverHostmetrics{ - ConfigComponent: cg.ConfigComponent{Type: "hostmetrics"}, - MetricsReceiverShared: cg.MetricsReceiverShared{CollectionInterval: "60s"}, - }, - }, - Processors: map[string]cg.MetricsProcessor{ - "metrics_filter": &MetricsProcessorExcludeMetrics{ - ConfigComponent: cg.ConfigComponent{Type: "exclude_metrics"}, - }, - }, - Service: &cg.MetricsService{ - Pipelines: map[string]*cg.Pipeline{ - "default_pipeline": { - ReceiverIDs: []string{"hostmetrics"}, - ProcessorIDs: []string{"metrics_filter"}, - }, - }, - }, - }, - }, - "windows": { - Logging: &cg.Logging{ - Receivers: map[string]cg.LoggingReceiver{ - "windows_event_log": &cg.LoggingReceiverWindowsEventLog{ - ConfigComponent: cg.ConfigComponent{Type: "windows_event_log"}, - Channels: []string{"System", "Application", "Security"}, - }, - }, - Processors: map[string]cg.LoggingProcessor{}, - Service: &cg.LoggingService{ - Pipelines: map[string]*cg.Pipeline{ - "default_pipeline": { - ReceiverIDs: []string{"windows_event_log"}, - }, - }, - }, - }, - Metrics: &cg.Metrics{ - Receivers: map[string]cg.MetricsReceiver{ - "hostmetrics": &MetricsReceiverHostmetrics{ - ConfigComponent: cg.ConfigComponent{Type: "hostmetrics"}, - MetricsReceiverShared: cg.MetricsReceiverShared{CollectionInterval: "60s"}, - }, - "iis": &MetricsReceiverIis{ - ConfigComponent: cg.ConfigComponent{Type: "iis"}, - MetricsReceiverShared: cg.MetricsReceiverShared{CollectionInterval: "60s"}, - }, - "mssql": &MetricsReceiverMssql{ - ConfigComponent: cg.ConfigComponent{Type: "mssql"}, - MetricsReceiverShared: cg.MetricsReceiverShared{CollectionInterval: "60s"}, - }, - }, - Processors: map[string]cg.MetricsProcessor{ - "metrics_filter": &MetricsProcessorExcludeMetrics{ - ConfigComponent: cg.ConfigComponent{Type: "exclude_metrics"}, - }, - }, - Service: &cg.MetricsService{ - Pipelines: map[string]*cg.Pipeline{ - "default_pipeline": { - ReceiverIDs: []string{"hostmetrics", "iis", "mssql"}, - ProcessorIDs: []string{"metrics_filter"}, - }, - }, - }, - }, - }, - } -} diff --git a/apps/common_logging_processors.go b/apps/common_logging_processors.go deleted file mode 100644 index 599c260299..0000000000 --- a/apps/common_logging_processors.go +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2021 Google LLC -// -// 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. - -package apps - -import ( - "context" - "fmt" - - "github.com/GoogleCloudPlatform/ops-agent/confgenerator" -) - -const InstrumentationSourceLabel = confgenerator.InstrumentationSourceLabel - -func instrumentationSourceValue(processorType string) *confgenerator.ModifyField { - val := fmt.Sprintf("agent.googleapis.com/%s", processorType) - return &confgenerator.ModifyField{ - StaticValue: &val, - } -} - -// genericAccessLogParser is an internal logging processor that parses access logs. -func genericAccessLogParser(ctx context.Context, processorType string) []confgenerator.InternalOTelProcessor { - c := confgenerator.LoggingProcessorParseRegex{ - // Documentation: - // https://httpd.apache.org/docs/current/logs.html#accesslog - // https://docs.nginx.com/nginx/admin-guide/monitoring/logging/#setting-up-the-access-log - // Sample "common" line: 127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 - // Sample "combined" line: ::1 - - [26/Aug/2021:16:49:43 +0000] "GET / HTTP/1.1" 200 10701 "-" "curl/7.64.0" "0.5" - Regex: `^(?[^ ]*) (?[^ ]*) (?[^ ]*) \[(?