-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move NGINX discovery to OTel receiver (#5689)
* Initial changes to move NGINX discovery to OTel receiver * Initial changes to add discovery test * Fix typo * fix discovery endpoint * Fix typo * Add changelog entry * Remove smartagent-collectd-nginx generated file * Small README.md fix
- Loading branch information
Showing
16 changed files
with
170 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
cmd/otelcol/config/collector/config.d.linux/receivers/nginx.discovery.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
##################################################################################### | ||
# This file is generated by the Splunk Distribution of the OpenTelemetry Collector. # | ||
# # | ||
# It reflects the default configuration bundled in the Collector executable for use # | ||
# in discovery mode (--discovery) and is provided for reference or customization. # | ||
# Please note that any changes made to this file will need to be reconciled during # | ||
# upgrades of the Collector. # | ||
##################################################################################### | ||
# nginx: | ||
# enabled: true | ||
# rule: | ||
# docker_observer: type == "container" and any([name, image, command], {# matches "(?i)nginx"}) and not (command matches "splunk.discovery") | ||
# host_observer: type == "hostport" and command matches "(?i)nginx" and not (command matches "splunk.discovery") | ||
# k8s_observer: type == "port" and pod.name matches "(?i)nginx" | ||
# config: | ||
# default: | ||
# endpoint: '`(port in [443] ? "https://" : "http://")``endpoint`/nginx_status}}' | ||
# status: | ||
# metrics: | ||
# - status: successful | ||
# strict: nginx.connections_accepted | ||
# message: nginx receiver is working! | ||
# statements: | ||
# - status: failed | ||
# regexp: "Failed to fetch nginx stats" | ||
# message: Failed to retrieve metrics from NGINX stub_status endpoint. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
internal/confmapprovider/discovery/bundle/bundle.d/receivers/nginx.discovery.yaml.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{{ receiver "nginx" }}: | ||
enabled: true | ||
rule: | ||
docker_observer: type == "container" and any([name, image, command], {# matches "(?i)nginx"}) and not (command matches "splunk.discovery") | ||
host_observer: type == "hostport" and command matches "(?i)nginx" and not (command matches "splunk.discovery") | ||
k8s_observer: type == "port" and pod.name matches "(?i)nginx" | ||
config: | ||
default: | ||
endpoint: '`(port in [443] ? "https://" : "http://")``endpoint`/nginx_status}}' | ||
status: | ||
metrics: | ||
- status: successful | ||
strict: nginx.connections_accepted | ||
message: nginx receiver is working! | ||
statements: | ||
- status: failed | ||
regexp: "Failed to fetch nginx stats" | ||
message: Failed to retrieve metrics from NGINX stub_status endpoint. |
24 changes: 0 additions & 24 deletions
24
...rovider/discovery/bundle/bundle.d/receivers/smartagent-collectd-nginx.discovery.yaml.tmpl
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// 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 discovery_integration_nginx | ||
|
||
package tests | ||
|
||
import ( | ||
"path/filepath" | ||
"runtime" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/signalfx/splunk-otel-collector/tests/internal/discoverytest" | ||
) | ||
|
||
func TestIntegrationNGINXAutoDiscovery(t *testing.T) { | ||
if runtime.GOOS == "darwin" || runtime.GOOS == "windows" { | ||
t.Skip("Integration tests are only run on linux architecture: https://github.com/signalfx/splunk-otel-collector/blob/main/.github/workflows/integration-test.yml#L35") | ||
} | ||
|
||
tests := map[string]struct { | ||
configFileName string | ||
logMessageToAssert string | ||
}{ | ||
"Successful Discovery test": { | ||
configFileName: "docker_observer_nginx_config.yaml", | ||
logMessageToAssert: `nginx receiver is working!`, | ||
}, | ||
} | ||
|
||
for name, test := range tests { | ||
t.Run(name, func(t *testing.T) { | ||
otelConfigPath, err := filepath.Abs(filepath.Join(".", "testdata", test.configFileName)) | ||
require.NoError(t, err) | ||
discoverytest.Run(t, "nginx", otelConfigPath, test.logMessageToAssert) | ||
}) | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
tests/receivers/nginx/testdata/docker_observer_nginx_config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
extensions: | ||
docker_observer: | ||
use_host_bindings: true | ||
basicauth: | ||
client_auth: | ||
username: some_user | ||
password: some_password | ||
|
||
receivers: | ||
discovery: | ||
embed_receiver_config: true | ||
receivers: | ||
nginx: | ||
config: | ||
endpoint: '`(port in [443] ? "https://" : "http://")``endpoint`/nginx_status}}' | ||
auth: | ||
authenticator: basicauth | ||
collection_interval: 1s | ||
rule: type == "container" and any([name, image, command], {# matches "(?i)nginx"}) and not (command matches "splunk.discovery") | ||
status: | ||
metrics: | ||
- status: successful | ||
strict: nginx.connections_accepted | ||
message: nginx receiver is working! | ||
statements: | ||
- status: failed | ||
regexp: "Failed to fetch nginx stats" | ||
message: Failed to retrieve metrics from NGINX stub_status endpoint. | ||
watch_observers: | ||
- docker_observer | ||
|
||
exporters: | ||
debug: | ||
verbosity: detailed | ||
otlp: | ||
endpoint: "${OTLP_ENDPOINT}" | ||
tls: | ||
insecure: true | ||
|
||
service: | ||
telemetry: | ||
logs: | ||
level: info | ||
extensions: | ||
- docker_observer | ||
- basicauth | ||
pipelines: | ||
logs: | ||
receivers: [discovery] | ||
exporters: [otlp, debug] |