Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring Kafkamatrics receiver into the discovery mode #4903

Merged
merged 4 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#####################################################################################
# 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. #
#####################################################################################
# kafkametrics:
# enabled: true
# rule:
# docker_observer: type == "container" and any([name, image, command], {# matches "(?i)kafka.*"}) and not (command matches "splunk.discovery")
# host_observer: type == "hostport" and command matches "(?i)kafka.*" and not (command matches "splunk.discovery")
# k8s_observer: type == "port" and pod.name matches "(?i)kafka.*"
# config:
# default:
# protocol_version: 2.0.0
# scrapers:
# - brokers
# - topics
# - consumers
# status:
# metrics:
# - status: successful
# strict: kafka.brokers
# log_record:
# body: kafkametrics receiver is working!
# statements:
# - status: failed
# regexp: 'connect: network is unreachable'
# log_record:
# body: The container cannot be reached by the Collector. Make sure they're in the same network.
# - status: failed
# regexp: 'connect: connection refused'
# log_record:
# body: The container is refusing kafka server connections.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#####################################################################################
# Do not edit manually! #
# All changes must be made to associated .tmpl file before running 'make bundle.d'. #
#####################################################################################
kafkametrics:
enabled: true
rule:
docker_observer: type == "container" and any([name, image, command], {# matches "(?i)kafka.*"}) and not (command matches "splunk.discovery")
host_observer: type == "hostport" and command matches "(?i)kafka.*" and not (command matches "splunk.discovery")
k8s_observer: type == "port" and pod.name matches "(?i)kafka.*"
config:
default:
protocol_version: 2.0.0
scrapers:
- brokers
- topics
- consumers
status:
metrics:
- status: successful
strict: kafka.brokers
log_record:
samiura marked this conversation as resolved.
Show resolved Hide resolved
body: kafkametrics receiver is working!
statements:
- status: failed
regexp: 'connect: network is unreachable'
log_record:
body: The container cannot be reached by the Collector. Make sure they're in the same network.
- status: failed
regexp: 'connect: connection refused'
log_record:
body: The container is refusing kafka server connections.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{ receiver "kafkametrics" }}:
enabled: true
rule:
docker_observer: type == "container" and any([name, image, command], {# matches "(?i)kafka.*"}) and not (command matches "splunk.discovery")
host_observer: type == "hostport" and command matches "(?i)kafka.*" and not (command matches "splunk.discovery")
k8s_observer: type == "port" and pod.name matches "(?i)kafka.*"
config:
default:
protocol_version: 2.0.0
scrapers:
- brokers
- topics
- consumers
status:
metrics:
- status: successful
strict: kafka.brokers
log_record:
body: kafkametrics receiver is working!
statements:
- status: failed
regexp: 'connect: network is unreachable'
log_record:
body: The container cannot be reached by the Collector. Make sure they're in the same network.
- status: failed
regexp: 'connect: connection refused'
log_record:
body: The container is refusing kafka server connections.
2 changes: 2 additions & 0 deletions internal/confmapprovider/discovery/bundle/bundle_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
//go:generate discoverybundler -r -t bundle.d/extensions/k8s-observer.discovery.yaml.tmpl
//go:generate discoverybundler -r -c -d ../../../../cmd/otelcol/config/collector/config.d.linux/extensions -t bundle.d/extensions/k8s-observer.discovery.yaml.tmpl

//go:generate discoverybundler -r -t bundle.d/receivers/kafkametrics.discovery.yaml.tmpl
//go:generate discoverybundler -r -c -d ../../../../cmd/otelcol/config/collector/config.d.linux/receivers -t bundle.d/receivers/kafkametrics.discovery.yaml.tmpl
//go:generate discoverybundler -r -t bundle.d/receivers/mongodb.discovery.yaml.tmpl
//go:generate discoverybundler -r -c -d ../../../../cmd/otelcol/config/collector/config.d.linux/receivers -t bundle.d/receivers/mongodb.discovery.yaml.tmpl
//go:generate discoverybundler -r -t bundle.d/receivers/mysql.discovery.yaml.tmpl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestBundleDir(t *testing.T) {
receivers, err := fs.Glob(BundledFS, "bundle.d/receivers/*.discovery.yaml")
require.NoError(t, err)
require.Equal(t, []string{
"bundle.d/receivers/kafkametrics.discovery.yaml",
"bundle.d/receivers/mongodb.discovery.yaml",
"bundle.d/receivers/mysql.discovery.yaml",
"bundle.d/receivers/oracledb.discovery.yaml",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
//go:embed bundle.d/extensions/docker-observer.discovery.yaml
//go:embed bundle.d/extensions/host-observer.discovery.yaml
//go:embed bundle.d/extensions/k8s-observer.discovery.yaml
//go:embed bundle.d/receivers/kafkametrics.discovery.yaml
//go:embed bundle.d/receivers/mongodb.discovery.yaml
//go:embed bundle.d/receivers/mysql.discovery.yaml
//go:embed bundle.d/receivers/oracledb.discovery.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
//go:embed bundle.d/extensions/docker-observer.discovery.yaml
//go:embed bundle.d/extensions/host-observer.discovery.yaml
//go:embed bundle.d/extensions/k8s-observer.discovery.yaml
//go:embed bundle.d/receivers/kafkametrics.discovery.yaml
//go:embed bundle.d/receivers/mongodb.discovery.yaml
//go:embed bundle.d/receivers/mysql.discovery.yaml
//go:embed bundle.d/receivers/oracledb.discovery.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestBundleDir(t *testing.T) {
receivers, err := fs.Glob(BundledFS, "bundle.d/receivers/*.discovery.yaml")
require.NoError(t, err)
require.Equal(t, []string{
"bundle.d/receivers/kafkametrics.discovery.yaml",
"bundle.d/receivers/mongodb.discovery.yaml",
"bundle.d/receivers/mysql.discovery.yaml",
"bundle.d/receivers/oracledb.discovery.yaml",
Expand Down
2 changes: 2 additions & 0 deletions internal/confmapprovider/discovery/bundle/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var (
// If they are desired for !windows BundledFS inclusion (and a default linux conf.d entry), ensure they are included
// in Components.Linux. If desired in windows BundledFS, ensure they are included in Components.Windows.
receivers = []string{
"kafkametrics",
"mongodb",
"mysql",
"oracledb",
Expand Down Expand Up @@ -62,6 +63,7 @@ var (
}(),
Windows: func() map[string]struct{} {
windows := map[string]struct{}{
"kafkametrics": {},
"mongodb": {},
"mysql": {},
"oracledb": {},
Expand Down
Loading