Skip to content

Commit

Permalink
Add the nginx receiver (#5229)
Browse files Browse the repository at this point in the history
* Add nginx receiver

* Update CHANGELOG.md

Co-authored-by: Curtis Robert <[email protected]>

* Update CHANGELOG.md

Co-authored-by: Curtis Robert <[email protected]>

* make fmt

* make tidy

* Set a small collection_interval

* Add credentials to test configuration

* Correct auth info

* Fix endpoint

* make tidy

* make tidy

* Correct CHANGELOG.md

* Fix typo

---------

Co-authored-by: Curtis Robert <[email protected]>
  • Loading branch information
pjanotti and crobert-1 authored Aug 22, 2024
1 parent 378d405 commit 12484c0
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### 🚀 New components 🚀

- (Splunk) Add `nginx` receiver ([5229](https://github.com/signalfx/splunk-otel-collector/pull/5229))

## v0.107.0

This Splunk OpenTelemetry Collector release includes changes from the [opentelemetry-collector v0.107.0](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.107.0) and the [opentelemetry-collector-contrib v0.107.0](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/v0.107.0) releases where appropriate.
Expand Down Expand Up @@ -319,7 +323,7 @@ This Splunk OpenTelemetry Collector release includes changes from the [opentelem
- (Contrib) `statsdreceiver`: Allow configuring summary percentiles ([#33701](https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/33701))
- (Contrib) `pkg/stanza`: Switch to faster json parser lib for container operator ([#33929](https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/33929))
- (Contrib) `telemetrygen`: telemetrygen `--rate` flag changed from Int64 to Float64 ([#33984](https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/33984))
- (Contrib) `windowsperfcountersreceiver`: `windowsperfcountersreceiver` now appends an index number to additional instance names that share a name. An example of this is when scraping `
rocess(*)` counters with multiple running instances of the same executable. ([#32319](https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/32319))
- (Contrib) `windowsperfcountersreceiver`: `windowsperfcountersreceiver` now appends an index number to additional instance names that share a name. An example of this is when scraping `process(*)` counters with multiple running instances of the same executable. ([#32319](https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/32319))
**NOTES**
- This change can expose cardinality issues where the counters were previously collapsed under the non-indexed instance name.
- The change mimics Windows Performance Monitor behavior: The first instance name remains unchanged, additional instances are suffixed with `#<N>` where `N=1` and is increased for each duplicate.
Expand Down
1 change: 1 addition & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ services:
nginx:
image: quay.io/splunko11ytest/nginx:latest
profiles:
- integration
- smartagent
build: ./nginx
ports:
Expand Down
1 change: 1 addition & 0 deletions docs/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ The distribution offers support for the following components.
| [mongodbatlas](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/mongodbatlasreceiver) | [beta] |
| [mongodb](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/mongodbreceiver) | [beta] |
| [mysql](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/mongodbreceiver) | [beta] |
| [nginx](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/nginxreceiver) | [beta] |
| [oracledb](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/oracledbreceiver) | [alpha] |
| [otlp](https://github.com/open-telemetry/opentelemetry-collector/tree/main/receiver/otlpreceiver) | [stable] |
| [postgres](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/postgresqlreceiver) | [beta] |
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mongodbatlasreceiver v0.107.1-0.20240816183440-44ef4d6c5a2c
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mongodbreceiver v0.107.1-0.20240816183440-44ef4d6c5a2c
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mysqlreceiver v0.107.1-0.20240816183440-44ef4d6c5a2c
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/nginxreceiver v0.107.1-0.20240816183440-44ef4d6c5a2c
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/oracledbreceiver v0.107.1-0.20240816183440-44ef4d6c5a2c
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/postgresqlreceiver v0.107.1-0.20240816183440-44ef4d6c5a2c
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.107.1-0.20240816183440-44ef4d6c5a2c
Expand Down Expand Up @@ -272,6 +273,7 @@ require (
github.com/moby/sys/user v0.1.0 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/mrunalp/fileutils v0.5.1 // indirect
github.com/nginxinc/nginx-prometheus-exporter v0.11.0 // indirect
github.com/okta/okta-sdk-golang/v2 v2.20.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusremotewriteexporter v0.107.1-0.20240816183440-44ef4d6c5a2c // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding v0.107.1-0.20240816183440-44ef4d6c5a2c // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/naoina/go-stringutil v0.1.0 h1:rCUeRUHjBjGTSHl0VC00jUPLz8/F9dDzYI70Hzifhks=
github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0=
github.com/nginxinc/nginx-prometheus-exporter v0.11.0 h1:21xjnqNgxtni2jDgAQ90bl15uDnrTreO9sIlu1YsX/U=
github.com/nginxinc/nginx-prometheus-exporter v0.11.0/go.mod h1:GdyHnWAb8q8OW1Pssrrqbcqra0SH0Vn6UXICMmyWkw8=
github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2 h1:BQ1HW7hr4IVovMwWg0E0PYcyW8CzqDcVmaew9cujU4s=
github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2/go.mod h1:TLb2Sg7HQcgGdloNxkrmtgDNR9uVYF3lfdFIN4Ro6Sk=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
Expand Down Expand Up @@ -1441,6 +1443,8 @@ github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mongodbreceiv
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mongodbreceiver v0.107.1-0.20240816183440-44ef4d6c5a2c/go.mod h1:Yx8k1rSi53RM2NfbJPx7UADYGCmoqtE4ZhHdQBAjAqo=
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mysqlreceiver v0.107.1-0.20240816183440-44ef4d6c5a2c h1:erH9w5uHOIio3JfqyoTt5AHHjHLVhO+TZck1yCvyv9w=
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mysqlreceiver v0.107.1-0.20240816183440-44ef4d6c5a2c/go.mod h1:PDLr2+sk87REjOrg+Z9KCOZYysZrLeDSdTIiiY3Gr1s=
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/nginxreceiver v0.107.1-0.20240816183440-44ef4d6c5a2c h1:YZWPsCDwy8GfMsmM/0NPqESDT7zlQmRlPVoVxKPHtuo=
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/nginxreceiver v0.107.1-0.20240816183440-44ef4d6c5a2c/go.mod h1:Tr38V0YBdQP3wgjt6w9sxCaP9D1t6wp1nDOqrn55oLg=
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/oracledbreceiver v0.107.1-0.20240816183440-44ef4d6c5a2c h1:bUh5o3o4AXsSXcOANwag1hTGZxt7Z0Q7AFkMMrm3/Ic=
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/oracledbreceiver v0.107.1-0.20240816183440-44ef4d6c5a2c/go.mod h1:OtZ44vYVyVc8eX+SPPngMJUEFHJE7jiXYaZNp2bBgBE=
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/postgresqlreceiver v0.107.1-0.20240816183440-44ef4d6c5a2c h1:HW3rRqUIDsnpIVVa9nWHpYkiJVspVgkoAUDLSSCV+PM=
Expand Down
2 changes: 2 additions & 0 deletions internal/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mongodbatlasreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mongodbreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mysqlreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/nginxreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/oracledbreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/postgresqlreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver"
Expand Down Expand Up @@ -190,6 +191,7 @@ func Get() (otelcol.Factories, error) {
mongodbatlasreceiver.NewFactory(),
mongodbreceiver.NewFactory(),
mysqlreceiver.NewFactory(),
nginxreceiver.NewFactory(),
oracledbreceiver.NewFactory(),
otlpreceiver.NewFactory(),
postgresqlreceiver.NewFactory(),
Expand Down
3 changes: 2 additions & 1 deletion internal/components/components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ func TestDefaultComponents(t *testing.T) {
"kafka",
"kafkametrics",
"kubeletstats",
"lightprometheus",
"mongodbatlas",
"mongodb",
"mysql",
"lightprometheus",
"nginx",
"oracledb",
"otlp",
"postgresql",
Expand Down
38 changes: 38 additions & 0 deletions tests/receivers/nginx/nginx_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// 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 integration

package tests

import (
"testing"

"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/pmetrictest"

"github.com/signalfx/splunk-otel-collector/tests/testutils"
)

func TestNginxIntegration(t *testing.T) {
testutils.CheckGoldenFile(t, "all_metrics_config.yaml", "all_expected_metrics.yaml",
pmetrictest.IgnoreScopeVersion(),
pmetrictest.IgnoreMetricDataPointsOrder(),
pmetrictest.IgnoreResourceMetricsOrder(),
pmetrictest.IgnoreScopeMetricsOrder(),
pmetrictest.IgnoreMetricsOrder(),
pmetrictest.IgnoreMetricValues(),
pmetrictest.IgnoreTimestamp(),
pmetrictest.IgnoreStartTimestamp(),
)
}
65 changes: 65 additions & 0 deletions tests/receivers/nginx/testdata/all_expected_metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
resourceMetrics:
- resource: {}
scopeMetrics:
- metrics:
- description: The total number of accepted client connections
name: nginx.connections_accepted
sum:
aggregationTemporality: 2
dataPoints:
- asInt: "1"
timeUnixNano: "1643729289485220000"
isMonotonic: true
unit: connections
- description: The current number of nginx connections by state
sum:
aggregationTemporality: 2
dataPoints:
- asInt: "1"
attributes:
- key: state
value:
stringValue: active
timeUnixNano: "1643729289485220000"
- asInt: "0"
attributes:
- key: state
value:
stringValue: reading
timeUnixNano: "1643729289485220000"
- asInt: "1"
attributes:
- key: state
value:
stringValue: writing
timeUnixNano: "1643729289485220000"
- asInt: "0"
attributes:
- key: state
value:
stringValue: waiting
timeUnixNano: "1643729289485220000"
isMonotonic: false
name: nginx.connections_current
unit: connections
- description: The total number of handled connections. Generally, the parameter value is the same as nginx.connections_accepted unless some resource limits have been reached (for example, the worker_connections limit).
name: nginx.connections_handled
sum:
aggregationTemporality: 2
dataPoints:
- asInt: "1"
timeUnixNano: "1643729289485220000"
isMonotonic: true
unit: connections
- description: Total number of requests made to the server since it started
name: nginx.requests
sum:
aggregationTemporality: 2
dataPoints:
- asInt: "2"
timeUnixNano: "1643729289485220000"
isMonotonic: true
unit: requests
scope:
name: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/nginxreceiver
version: latest
30 changes: 30 additions & 0 deletions tests/receivers/nginx/testdata/all_metrics_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
receivers:
nginx:
endpoint: "http://localhost:8123/nginx_status"
auth:
authenticator: basicauth
collection_interval: 1s

exporters:
otlp:
endpoint: "${OTLP_ENDPOINT}"
tls:
insecure: true

extensions:
basicauth:
client_auth:
username: some_user
password: some_password

service:
telemetry:
logs:
level: "info"
extensions: [ basicauth ]
pipelines:
metrics:
receivers:
- nginx
exporters:
- otlp

0 comments on commit 12484c0

Please sign in to comment.