Skip to content

Commit 26f2ce9

Browse files
authored
Merge branch 'master' into feat/elasticsearch-v9
2 parents fd2b862 + 656dd8d commit 26f2ce9

79 files changed

Lines changed: 4847 additions & 138 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,11 @@ ARG OPENJDK_MAJOR_VERSION
498498
RUN set -x; apt-get update && \
499499
DEBIAN_FRONTEND=noninteractive apt-get -y install git systemd \
500500
autoconf libtool libcurl4-openssl-dev libltdl-dev libssl-dev libyajl-dev \
501-
build-essential cmake bison flex file libsystemd-dev \
501+
build-essential bison flex file libsystemd-dev \
502502
devscripts cdbs pkg-config openjdk-${OPENJDK_MAJOR_VERSION}-jdk zip
503+
COPY --from=cmake-install-recent /cmake.sh /cmake.sh
504+
RUN set -x; bash /cmake.sh --skip-license --prefix=/usr/local
505+
503506

504507
SHELL ["/bin/bash", "-c"]
505508

@@ -601,7 +604,7 @@ RUN set -x; \
601604
# The 'OSS Update' repo signature is no longer valid, so verify the checksum instead.
602605
zypper --no-gpg-check refresh 'OSS Update' && \
603606
(echo '6dd0b89202b19dae873434c5f2ba01164205071581fc02365712be801e304b3b /var/cache/zypp/raw/OSS Update/repodata/repomd.xml' | sha256sum --check) && \
604-
zypper -n install git systemd autoconf automake flex libtool libcurl-devel libopenssl-devel libyajl-devel gcc gcc-c++ zlib-devel rpm-build expect cmake systemd-devel systemd-rpm-macros unzip zip && \
607+
zypper -n install git systemd autoconf automake flex libtool libcurl-devel libopenssl-devel libyajl-devel gcc8 gcc8-c++ zlib-devel rpm-build expect systemd-devel systemd-rpm-macros unzip zip && \
605608
# Remove expired root certificate.
606609
mv /var/lib/ca-certificates/pem/DST_Root_CA_X3.pem /etc/pki/trust/blacklist/ && \
607610
update-ca-certificates && \
@@ -613,7 +616,11 @@ RUN set -x; \
613616
# If this bug happens to trigger in the future, adding a "zypper -n download" of a subset of the packages can avoid the segfault.
614617
zypper -n install 'bison>3' && \
615618
# Allow fluent-bit to find systemd
616-
ln -fs /usr/lib/systemd /lib/systemd
619+
ln -fs /usr/lib/systemd /lib/systemd && \
620+
# Set newer GCC as default with priority 1
621+
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 1 \
622+
--slave /usr/bin/g++ g++ /usr/bin/g++-8 && \
623+
update-alternatives --set gcc /usr/bin/gcc-8
617624
COPY --from=openjdk-install /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk/ /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk
618625
ENV JAVA_HOME /usr/local/java-${OPENJDK_MAJOR_VERSION}-openjdk/
619626
COPY --from=cmake-install-recent /cmake.sh /cmake.sh

Dockerfile.windows

Lines changed: 149 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ FROM mcr.microsoft.com/windows/servercore:$WINDOWS_VERSION as base
1010
#
1111
# Basic setup
1212
#
13-
RUN setx /M PATH "%PATH%;C:\WinFlexBison;C:\Go\bin;C:\Java\bin;C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin"
13+
RUN setx /M PATH "%PATH%;C:\Go\bin;C:\Java\bin"
1414

1515
RUN setx /M JAVA_HOME "C:\Java"
1616

@@ -28,51 +28,148 @@ RUN Write-Host ('Creating folders'); `
2828
WORKDIR /local
2929

3030
#
31-
# Install Visual Studio 2019
31+
# Install Visual Studio Build Tools 2019 (MSVS_VERSION=16) / 2022 (MSVS_VERSION=17, requires WINDOWS_VERSION=ltsc2022)
32+
# Based on https://github.com/fluent/fluent-bit/blob/v4.0.7/dockerfiles/Dockerfile.windows
3233
#
33-
ADD https://aka.ms/vs/16/release/vs_buildtools.exe /local/vs_buildtools.exe
34-
ADD https://aka.ms/vs/16/release/channel /local/VisualStudio.chman
35-
36-
RUN Start-Process /local/vs_buildtools.exe `
37-
-ArgumentList '--quiet ', '--wait ', '--norestart ', '--nocache', `
38-
'--installPath C:\BuildTools', `
39-
'--channelUri C:\local\VisualStudio.chman', `
40-
'--installChannelUri C:\local\VisualStudio.chman', `
41-
'--add Microsoft.VisualStudio.Workload.VCTools', `
42-
'--includeRecommended' -NoNewWindow -Wait;
34+
ARG MSVS_VERSION="17"
35+
ENV MSVS_BUILD_TOOLS_VERSION="$MSVS_VERSION" `
36+
MSVS_BUILD_TOOLS_DOWNLOAD_URL="https://aka.ms/vs" `
37+
MSVS_HOME="C:\BuildTools"
38+
39+
RUN $msvs_build_tools_dist_name=\"vs_buildtools.exe\"; `
40+
$msvs_build_tools_dist=\"${env:TMP}\${msvs_build_tools_dist_name}\"; `
41+
$msvs_build_tools_channel=\"C:\local\VisualStudio.chman\"; `
42+
$msvs_build_tools_dist_url=\"${env:MSVS_BUILD_TOOLS_DOWNLOAD_URL}/${env:MSVS_BUILD_TOOLS_VERSION}/release/${msvs_build_tools_dist_name}\"; `
43+
$msvs_build_tools_channel_url=\"${env:MSVS_BUILD_TOOLS_DOWNLOAD_URL}/${env:MSVS_BUILD_TOOLS_VERSION}/release/channel\"; `
44+
Write-Host \"Downloading Visual Studio Build Tools...\"; `
45+
Write-Host \"${msvs_build_tools_dist_url} -> ${msvs_build_tools_dist}\"; `
46+
Write-Host \"${msvs_build_tools_channel_url} -> ${msvs_build_tools_channel}\"; `
47+
Invoke-WebRequest -OutFile \"${msvs_build_tools_dist}\" \"${msvs_build_tools_dist_url}\"; `
48+
Invoke-WebRequest -OutFile \"${msvs_build_tools_channel}\" \"${msvs_build_tools_channel_url}\"; `
49+
Write-Host \"Installing Visual Studio Build Tools into ${env:MSVS_HOME}...\"; `
50+
Start-Process \"${msvs_build_tools_dist}\" `
51+
-ArgumentList '--quiet ', '--wait ', '--norestart ', '--nocache', `
52+
\"--installPath ${env:MSVS_HOME}\", `
53+
\"--channelUri ${msvs_build_tools_channel}\", `
54+
\"--installChannelUri ${msvs_build_tools_channel}\", `
55+
'--add Microsoft.VisualStudio.Workload.VCTools', `
56+
'--includeRecommended' -NoNewWindow -Wait; `
57+
Remove-Item -Force \"${msvs_build_tools_dist}\"; `
58+
Remove-Item -Path \"${msvs_build_tools_channel}\" -Force;
4359

4460
#
45-
# Technique from https://github.com/StefanScherer/dockerfiles-windows/blob/master/mongo/3.6/Dockerfile
61+
# Install compatible CMake
4662
#
47-
ADD https://aka.ms/vs/15/release/vc_redist.x64.exe /local/vc_redist.x64.exe
63+
ENV CMAKE_HOME="C:\cmake"
64+
ARG CMAKE_VERSION="3.31.6"
65+
ARG CMAKE_URL="https://github.com/Kitware/CMake/releases/download"
66+
67+
RUN if ([System.Version] \"${env:CMAKE_VERSION}\" -ge [System.Version] \"3.20.0\") { `
68+
$cmake_dist_base_name=\"cmake-${env:CMAKE_VERSION}-windows-x86_64\" `
69+
} else { `
70+
if ([System.Version] \"${env:CMAKE_VERSION}\" -ge [System.Version] \"3.6.0\") { `
71+
$cmake_dist_base_name=\"cmake-${env:CMAKE_VERSION}-win64-x64\" `
72+
} else { `
73+
$cmake_dist_base_name=\"cmake-${env:CMAKE_VERSION}-win32-x86\" `
74+
} `
75+
}; `
76+
$cmake_dist_name=\"${cmake_dist_base_name}.zip\"; `
77+
$cmake_dist=\"${env:TMP}\${cmake_dist_name}\"; `
78+
$cmake_download_url=\"${env:CMAKE_URL}/v${env:CMAKE_VERSION}/${cmake_dist_name}\"; `
79+
Write-Host \"Downloading CMake...\"; `
80+
Write-Host \"${cmake_download_url} -> ${cmake_dist}\"; `
81+
Invoke-WebRequest -OutFile \"${cmake_dist}\" \"${cmake_download_url}\"; `
82+
$cmake_temp_dir=\"${env:TMP}\${cmake_dist_base_name}\"; `
83+
Write-Host \"Extracting CMake...\"; `
84+
Write-Host \"${cmake_dist} -> ${cmake_temp_dir}\"; `
85+
Expand-Archive \"${cmake_dist}\" -Destination \"${env:TMP}\"; `
86+
Remove-Item -Force \"${cmake_dist}\"; `
87+
Write-Host \"Moving CMake...\"; `
88+
Write-Host \"${cmake_temp_dir} -> ${env:CMAKE_HOME}\"; `
89+
[System.IO.Directory]::Move(\"${cmake_temp_dir}\", \"${env:CMAKE_HOME}\"); `
90+
$env:PATH=\"${env:PATH};${env:CMAKE_HOME}\bin\"; `
91+
Write-Host \"Setting PATH...\"; `
92+
Write-Host \"${env:PATH}\"; `
93+
[Environment]::SetEnvironmentVariable(\"PATH\", \"${env:PATH}\", [EnvironmentVariableTarget]::Machine);
4894

49-
RUN Write-Host ('Installing Visual C++ Redistributable Package'); `
50-
Start-Process /local/vc_redist.x64.exe -ArgumentList '/install', '/quiet', '/norestart' -NoNewWindow -Wait; `
51-
Copy-Item -Path /Windows/System32/msvcp140.dll -Destination /work/out/bin/; `
52-
Copy-Item -Path /Windows/System32/vccorlib140.dll -Destination /work/out/bin/; `
53-
Copy-Item -Path /Windows/System32/vcruntime140.dll -Destination /work/out/bin/;
95+
#
96+
# Install WinFlexBison
97+
#
98+
ENV WIN_FLEX_BISON_VERSION="2.5.22" `
99+
WIN_FLEX_BISON_HOME="C:\WinFlexBison" `
100+
WIN_FLEX_BISON_DOWNLOAD_URL="https://github.com/lexxmark/winflexbison/releases/download"
101+
102+
RUN $win_flex_bison_dist_base_name=\"win_flex_bison-${env:WIN_FLEX_BISON_VERSION}\"; `
103+
$win_flex_bison_dist_name=\"${win_flex_bison_dist_base_name}.zip\"; `
104+
$win_flex_bison_dist=\"${env:TMP}\${win_flex_bison_dist_name}\"; `
105+
$win_flex_bison_url=\"${env:WIN_FLEX_BISON_DOWNLOAD_URL}/v${env:WIN_FLEX_BISON_VERSION}/${win_flex_bison_dist_name}\"; `
106+
Write-Host \"Downloading WinFlexBison...\"; `
107+
Write-Host \"${win_flex_bison_url} -> ${win_flex_bison_dist}\"; `
108+
Invoke-WebRequest -OutFile \"${win_flex_bison_dist}\" \"${win_flex_bison_url}\"; `
109+
Write-Host \"Extracting WinFlexBison...\"; `
110+
Write-Host \"${win_flex_bison_dist} -> ${env:WIN_FLEX_BISON_HOME}\"; `
111+
Expand-Archive \"${win_flex_bison_dist}\" -Destination \"${env:WIN_FLEX_BISON_HOME}\"; `
112+
Remove-Item -Force \"${win_flex_bison_dist}\"; `
113+
Write-Host \"Copying...\"; `
114+
Write-Host \"${env:WIN_FLEX_BISON_HOME}\win_bison.exe -> ${env:WIN_FLEX_BISON_HOME}\bison.exe\"; `
115+
Copy-Item -Path \"${env:WIN_FLEX_BISON_HOME}\win_bison.exe\" \"${env:WIN_FLEX_BISON_HOME}\bison.exe\"; `
116+
Write-Host \"Copying...\"; `
117+
Write-Host \"${env:WIN_FLEX_BISON_HOME}\win_flex.exe -> ${env:WIN_FLEX_BISON_HOME}\flex.exe\"; `
118+
Copy-Item -Path \"${env:WIN_FLEX_BISON_HOME}\win_flex.exe\" \"${env:WIN_FLEX_BISON_HOME}\flex.exe\"; `
119+
$env:PATH=\"${env:PATH};${env:WIN_FLEX_BISON_HOME}\"; `
120+
Write-Host \"Setting PATH...\"; `
121+
Write-Host \"${env:PATH}\"; `
122+
[Environment]::SetEnvironmentVariable(\"PATH\", \"${env:PATH}\", [EnvironmentVariableTarget]::Machine);
54123

55124
#
56-
# Install OpenSSL
57-
# This must be done after installing Visual Studio
58-
59-
RUN $files = (iwr -UseBasicParsing https://raw.githubusercontent.com/slproweb/opensslhashes/master/win32_openssl_hashes.json | ConvertFrom-Json).files.psobject.properties.value; `
60-
$installer = $files | ? {$_.arch -eq \"INTEL\" -and $_.bits -eq 64 -and $_.installer -eq \"msi\" -and -not $_.light -and $_.basever -like \"1.*\" }; `
61-
iwr -UseBasicParsing -Uri \"$($installer.url)\" -OutFile /local/openssl.msi; `
62-
$ActualHash = $(Get-FileHash /local/openssl.msi -Algorithm SHA256).Hash.ToLower(); `
63-
if ($ActualHash -ne \"$($installer.sha256)\") { `
64-
throw \"OpenSSL hash mismatch. Expected: $($installer.sha256), Actual: $ActualHash\" `
65-
}; `
66-
Start-Process msiexec.exe -Wait -ArgumentList \"/i C:\local\openssl.msi /quiet\";
125+
# Install VCPKG
126+
#
127+
# https://github.com/microsoft/vcpkg/blob/2024.05.24/scripts/bootstrap.ps1
128+
ENV VCPKG_VERSION=2024.05.24 `
129+
VCPKG_DOWNLOAD_URL="https://github.com/microsoft/vcpkg/archive/refs/tags" `
130+
VCPKG_DISABLE_METRICS="ON" `
131+
VCPKG_ROOT=/dev/vcpkg
132+
133+
WORKDIR /dev
134+
135+
RUN $vcpkg_dist_base_name=\"vcpkg-${env:VCPKG_VERSION}\"; `
136+
$vcpkg_dist=\"${env:TMP}\${vcpkg_dist_base_name}.zip\"; `
137+
$vcpkg_url=\"${env:VCPKG_DOWNLOAD_URL}/${env:VCPKG_VERSION}.zip\"; `
138+
Write-Host \"Downloading vcpkg...\"; `
139+
Write-Host \"${vcpkg_url} -> ${vcpkg_dist}\"; `
140+
Invoke-WebRequest -OutFile \"${vcpkg_dist}\" \"${vcpkg_url}\"; `
141+
$vcpkg_temp_dir=\"${env:TMP}\${vcpkg_dist_base_name}\"; `
142+
Write-Host \"Extracting vcpkg...\"; `
143+
Write-Host \"${vcpkg_dist} -> ${vcpkg_temp_dir}\"; `
144+
Expand-Archive \"${vcpkg_dist}\" -Destination \"${env:TMP}\"; `
145+
Remove-Item -Force \"${vcpkg_dist}\"; `
146+
$vcpkg_home_dir=\"${env:VCPKG_ROOT}\" -replace \"/\", \"\\\"; `
147+
$vcpkg_home_dir=\"C:${vcpkg_home_dir}\"; `
148+
Write-Host \"Moving vcpkg...\"; `
149+
Write-Host \"${vcpkg_temp_dir} -> ${vcpkg_home_dir}\"; `
150+
[System.IO.Directory]::Move(\"${vcpkg_temp_dir}\", \"${vcpkg_home_dir}\"); `
151+
$env:PATH=\"${env:PATH};${vcpkg_home_dir}\"; `
152+
Write-Host \"Setting PATH...\"; `
153+
Write-Host \"${env:PATH}\"; `
154+
[Environment]::SetEnvironmentVariable(\"PATH\", \"${env:PATH}\", [EnvironmentVariableTarget]::Machine); `
155+
Write-Host \"Bootstrapping vcpkg...\"; `
156+
& \"${vcpkg_home_dir}\bootstrap-vcpkg.bat\";
157+
158+
# Ensure we only attempt to build release and static linking
159+
ENV VCPKG_BUILD_TYPE=release `
160+
VCPKG_LIBRARY_LINKAGE=static
67161

68162
#
69-
# Install winflexbison
163+
# Install OpenSSL and LibYAML
70164
#
71-
ADD https://github.com/lexxmark/winflexbison/releases/download/v2.5.22/win_flex_bison-2.5.22.zip /local/win_flex_bison.zip
165+
RUN vcpkg install --recurse openssl --triplet x64-windows-static; `
166+
vcpkg install --recurse libyaml --triplet x64-windows-static;
72167

73-
RUN Expand-Archive /local/win_flex_bison.zip -Destination /WinFlexBison; `
74-
Copy-Item -Path /WinFlexBison/win_bison.exe /WinFlexBison/bison.exe; `
75-
Copy-Item -Path /WinFlexBison/win_flex.exe /WinFlexBison/flex.exe;
168+
# Technique from https://github.com/StefanScherer/dockerfiles-windows/blob/master/mongo/3.6/Dockerfile
169+
WORKDIR /work/out/bin/
170+
RUN Copy-Item -Path C:\Windows\System32\msvcp140.dll -Destination /work/out/bin/; `
171+
Copy-Item -Path C:\Windows\System32\vccorlib140.dll -Destination /work/out/bin/; `
172+
Copy-Item -Path C:\Windows\System32\vcruntime140.dll -Destination /work/out/bin/;
76173

77174
#
78175
# Install Golang
@@ -103,7 +200,14 @@ COPY submodules/fluent-bit /work/submodules/fluent-bit
103200

104201
WORKDIR /work/submodules/fluent-bit/build
105202

106-
RUN cmake -G "'Visual Studio 16 2019'" -DCMAKE_BUILD_TYPE=RELWITHDEBINFO `
203+
RUN cmake --version;
204+
205+
SHELL ["cmd", "/S", "/C"]
206+
RUN call "%MSVS_HOME%\VC\Auxiliary\Build\vcvars64.bat" && `
207+
cmake -G "NMake Makefiles" `
208+
-DOPENSSL_ROOT_DIR='C:\dev\vcpkg\packages\openssl_x64-windows-static' `
209+
-DFLB_LIBYAML_DIR='C:\dev\vcpkg\packages\libyaml_x64-windows-static' `
210+
-DCMAKE_BUILD_TYPE=RELWITHDEBINFO `
107211
-DFLB_WINDOWS_DEFAULTS=Off `
108212
-DFLB_REGEX=On `
109213
-DFLB_BACKTRACE=Off `
@@ -116,6 +220,7 @@ RUN cmake -G "'Visual Studio 16 2019'" -DCMAKE_BUILD_TYPE=RELWITHDEBINFO `
116220
-DFLB_METRICS=On `
117221
-DFLB_WASM=Off `
118222
-DFLB_WAMRC=Off `
223+
-DFLB_KAFKA=Off `
119224
-DFLB_IN_CPU=Off `
120225
-DFLB_IN_DISK=Off `
121226
-DFLB_IN_EXEC=On `
@@ -124,7 +229,6 @@ RUN cmake -G "'Visual Studio 16 2019'" -DCMAKE_BUILD_TYPE=RELWITHDEBINFO `
124229
-DFLB_IN_HEALTH=Off `
125230
-DFLB_IN_HTTP=On `
126231
-DFLB_IN_MEM=Off `
127-
-DFLB_IN_KAFKA=Off `
128232
-DFLB_IN_KMSG=Off `
129233
-DFLB_IN_LIB=On `
130234
-DFLB_IN_RANDOM=On `
@@ -163,8 +267,6 @@ RUN cmake -G "'Visual Studio 16 2019'" -DCMAKE_BUILD_TYPE=RELWITHDEBINFO `
163267
-DFLB_OUT_LIB=On `
164268
-DFLB_OUT_NULL=On `
165269
-DFLB_OUT_FLOWCOUNTER=On `
166-
-DFLB_OUT_KAFKA=Off `
167-
-DFLB_OUT_KAFKA_REST=Off `
168270
-DFLB_FILTER_GREP=On `
169271
-DFLB_FILTER_MODIFY=On `
170272
-DFLB_FILTER_STDOUT=On `
@@ -175,13 +277,15 @@ RUN cmake -G "'Visual Studio 16 2019'" -DCMAKE_BUILD_TYPE=RELWITHDEBINFO `
175277
-DFLB_FILTER_LUA=On `
176278
-DFLB_FILTER_RECORD_MODIFIER=On `
177279
-DFLB_FILTER_REWRITE_TAG=On `
178-
-DFLB_FILTER_WASM=Off ../;
280+
-DFLB_FILTER_WASM=Off ..\ && `
281+
cmake --build . --config Release
282+
283+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
179284

180-
RUN cmake --build . --config Release; `
181-
Copy-Item -Path bin/Release/fluent-bit.exe -Destination /work/out/bin/; `
182-
Copy-Item -Path bin/Release/fluent-bit.dll -Destination /work/out/bin/; `
183-
Copy-Item -Path bin/Release/fluent-bit.pdb -Destination /work/out/bin/; `
184-
Copy-Item -Path bin/Release/fluent-bit.dll.pdb -Destination /work/out/bin/;
285+
RUN Copy-Item -Path bin/fluent-bit.exe -Destination /work/out/bin/; `
286+
Copy-Item -Path bin/fluent-bit.dll -Destination /work/out/bin/; `
287+
Copy-Item -Path bin/fluent-bit.pdb -Destination /work/out/bin/; `
288+
Copy-Item -Path bin/fluent-bit.dll.pdb -Destination /work/out/bin/;
185289

186290
# TODO: Do something with /work/out/bin/fluent-bit.{exe,dll}
187291

apps/otlp.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ type ReceiverOTLP struct {
3939
MetricsMode string `yaml:"metrics_mode" validate:"omitempty,oneof=googlecloudmonitoring googlemanagedprometheus" tracking:""`
4040
}
4141

42+
func (r ReceiverOTLP) AllowCustomProcessors() bool {
43+
return r.MetricsMode == "googlecloudmonitoring"
44+
}
45+
4246
func (r ReceiverOTLP) Type() string {
4347
return "otlp"
4448
}

builds/fluent_bit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ cd build
2626
cmake .. -DCMAKE_INSTALL_PREFIX=$fluent_bit_dir \
2727
-DFLB_HTTP_SERVER=ON -DFLB_DEBUG=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo \
2828
-DWITHOUT_HEADERS=ON -DFLB_SHARED_LIB=OFF -DFLB_STREAM_PROCESSOR=OFF \
29-
-DFLB_IN_KAFKA=OFF -DFLB_OUT_KAFKA=OFF \
29+
-DFLB_KAFKA=OFF \
3030
-DFLB_CONFIG_YAML=OFF \
3131
-DFLB_MSGPACK_TO_JSON_INIT_BUFFER_SIZE=1.5 -DFLB_MSGPACK_TO_JSON_REALLOC_BUFFER_SIZE=.10 \
3232
-DFLB_CONFIG_YAML=OFF

confgenerator/confgenerator.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,21 @@ func googleCloudExporter(userAgent string, instrumentationLabels bool, serviceRe
5757
}
5858
}
5959

60+
func otlpExporter(userAgent string) otel.Component {
61+
return otel.Component{
62+
Type: "otlphttp",
63+
Config: map[string]interface{}{
64+
"endpoint": "https://telemetry.googleapis.com",
65+
"auth": map[string]interface{}{
66+
"authenticator": "googleclientauth",
67+
},
68+
"headers": map[string]string{
69+
"User-Agent": userAgent,
70+
},
71+
},
72+
}
73+
}
74+
6075
func googleManagedPrometheusExporter(userAgent string) otel.Component {
6176
return otel.Component{
6277
Type: "googlemanagedprometheus",
@@ -129,6 +144,7 @@ func (uc *UnifiedConfig) GenerateOtelConfig(ctx context.Context, outDir string)
129144
otel.System: googleCloudExporter(userAgent, false, false),
130145
otel.OTel: googleCloudExporter(userAgent, true, true),
131146
otel.GMP: googleManagedPrometheusExporter(userAgent),
147+
otel.OTLP: otlpExporter(userAgent),
132148
},
133149
}.Generate(ctx)
134150
if err != nil {

confgenerator/config.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ func (uc *UnifiedConfig) ValidateMetrics(ctx context.Context) error {
12231223
if len(p.ExporterIDs) > 0 {
12241224
log.Printf(`The "metrics.service.pipelines.%s.exporters" field is deprecated and will be ignored. Please remove it from your configuration.`, id)
12251225
}
1226-
if err := validateNoCustomGMPProcessors(receivers, p.ReceiverIDs, p.ProcessorIDs, subagent, ctx); err != nil {
1226+
if err := validateAllowCustomProcessors(receivers, p.ReceiverIDs, p.ProcessorIDs); err != nil {
12271227
return err
12281228
}
12291229
}
@@ -1298,24 +1298,26 @@ func validateComponentKeys[V any](components map[string]V, refs []string, subage
12981298
return nil
12991299
}
13001300

1301+
// CustomProcessorValidator checks if receiver or pipeline allows Ops Agent to have processors
1302+
// Ops Agent cannot have processors if the receiver is of prometheus type, or if it
1303+
// is an OTLP receiver that exports metrics to googlemanagedprometheus
1304+
type CustomProcessorValidator interface {
1305+
AllowCustomProcessors() bool
1306+
}
1307+
13011308
// Pipelines that export prometheus metrics are not allowed to have Ops Agent processors
1302-
func validateNoCustomGMPProcessors(receivers metricsReceiverMap, receiverIDs, processorIDs []string, subagent string, ctx context.Context) error {
1309+
func validateAllowCustomProcessors(receivers metricsReceiverMap, receiverIDs, processorIDs []string) error {
13031310
for _, ID := range receiverIDs {
13041311
receiver, ok := receivers[ID]
13051312
if !ok {
1306-
return fmt.Errorf("metric receiver %q is not defined.", ID)
1313+
return fmt.Errorf("metric receiver %q is not defined", ID)
13071314
}
1308-
receiverPipelines, err := receiver.Pipelines(ctx)
1309-
if err != nil {
1310-
return err
1315+
if v, ok := receiver.(CustomProcessorValidator); !ok || v.AllowCustomProcessors() {
1316+
continue
13111317
}
1312-
for _, receiverPipeline := range receiverPipelines {
1313-
// Check the Ops Agent receiver type.
1314-
if receiverPipeline.ExporterTypes[subagent] == otel.GMP {
1315-
if len(processorIDs) > 0 {
1316-
return fmt.Errorf("prometheus receivers are incompatible with Ops Agent processors")
1317-
}
1318-
}
1318+
1319+
if len(processorIDs) > 0 {
1320+
return fmt.Errorf("%s receiver is incompatible with Ops Agent processors", ID)
13191321
}
13201322
}
13211323
return nil

0 commit comments

Comments
 (0)