Skip to content

Commit 1728aa7

Browse files
authored
Add cassanda jmx to discovery (#5112)
* Add cassandra jmx to discovery
1 parent 844ca5f commit 1728aa7

File tree

14 files changed

+390
-3
lines changed

14 files changed

+390
-3
lines changed

.github/workflows/integration-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,13 @@ jobs:
336336
id: get-matrix
337337
run: |
338338
includes=""
339-
for service in "mongodb" "kafkametrics"; do
339+
for service in "mongodb" "kafkametrics" "jmx/cassandra"; do
340340
for arch in "amd64" "arm64"; do
341341
if [ "$service" = "mongodb" ]; then
342342
for mongodb_version in "4.0" "4.4" "5.0" "6.0" "7.0"; do
343343
includes="${includes},{\"SERVICE\": \"${service}\", \"ARCH\": \"${arch}\", \"MONGODB_VERSION\": \"${mongodb_version}\"}"
344344
done
345-
else
345+
elif [[ "$service" != "jmx/cassandra" || "arm64" != "$arch" ]]; then
346346
includes="${includes},{\"SERVICE\": \"${service}\", \"ARCH\": \"${arch}\"}"
347347
fi
348348
done
@@ -364,7 +364,7 @@ jobs:
364364
fetch-depth: 0
365365
- run: echo "MONGODB_VERSION=${{ matrix.MONGODB_VERSION }}" > docker/.env
366366
if: matrix.SERVICE == 'mongodb'
367-
- run: docker compose -f docker/docker-compose.yml --profile integration-test-${{ matrix.SERVICE }}-discovery up -d --build --quiet-pull
367+
- run: docker compose -f docker/docker-compose.yml --profile integration-test-${{ matrix.SERVICE }}-discovery up -d --wait --build --quiet-pull
368368
- uses: actions/setup-go@v5
369369
with:
370370
go-version: ${{ env.GO_VERSION }}

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ integration-test-mongodb-discovery:
8383
integration-test-kafkametrics-discovery:
8484
@set -e; cd tests && $(GOTEST_SERIAL) $(BUILD_INFO_TESTS) --tags=discovery_integration_kafkametrics -v -timeout 5m -count 1 ./...
8585

86+
.PHONY: integration-test-jmx/cassandra-discovery
87+
integration-test-jmx/cassandra-discovery:
88+
@set -e; cd tests && $(GOTEST_SERIAL) $(BUILD_INFO_TESTS) --tags=discovery_integration_jmx -v -timeout 5m -count 1 ./...
89+
8690
.PHONY: smartagent-integration-test
8791
smartagent-integration-test:
8892
@set -e; cd tests && $(GOTEST_SERIAL) $(BUILD_INFO_TESTS) --tags=smartagent_integration -v -timeout 5m -count 1 ./...
@@ -224,3 +228,4 @@ install-test-tools:
224228
.PHONY: integration-test-split
225229
integration-test-split: install-test-tools
226230
@set -e; cd tests && gotesplit --total=$(GOTESPLIT_TOTAL) --index=$(GOTESPLIT_INDEX) ./... -- -p 1 $(BUILD_INFO_TESTS) --tags=integration -v -timeout 5m -count 1
231+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#####################################################################################
2+
# This file is generated by the Splunk Distribution of the OpenTelemetry Collector. #
3+
# #
4+
# It reflects the default configuration bundled in the Collector executable for use #
5+
# in discovery mode (--discovery) and is provided for reference or customization. #
6+
# Please note that any changes made to this file will need to be reconciled during #
7+
# upgrades of the Collector. #
8+
#####################################################################################
9+
# jmx/cassandra:
10+
# enabled: true
11+
# rule:
12+
# docker_observer: type == "container" and any([name, image, command], {# matches "(?i)cassandra.*"}) and not (command matches "splunk.discovery")
13+
# host_observer: type == "hostport" and command matches "(?i)cassandra.*" and not (command matches "splunk.discovery")
14+
# k8s_observer: type == "port" and pod.name matches "(?i)cassandra.*"
15+
# config:
16+
# default:
17+
# jar_path: /opt/opentelemetry-java-contrib-jmx-metrics.jar
18+
# endpoint: "service:jmx:rmi:///jndi/rmi://`endpoint`/jmxrmi"
19+
# target_system: cassandra
20+
# collection_interval: 10s
21+
# status:
22+
# metrics:
23+
# - status: successful
24+
# strict: cassandra.client.request.count
25+
# message: jmx/cassandra receiver is working!
26+
# statements:
27+
# - status: failed
28+
# regexp: 'connect: network is unreachable'
29+
# message: The container cannot be reached by the Collector. Make sure they're in the same network.
30+
# - status: failed
31+
# regexp: 'connect: connection refused'
32+
# message: The container is refusing cassandra server connections.

docker/docker-compose.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,36 @@ services:
2424
build: ./cassandra
2525
ports:
2626
- "7199:7199"
27+
# Cassandra without auth
28+
cassandra-jmx-noauth:
29+
profiles:
30+
- cassandra
31+
- integration-test-jmx/cassandra-discovery
32+
build:
33+
dockerfile_inline: |
34+
FROM cassandra:5
35+
ENV LOCAL_JMX=no
36+
RUN sed -ri 's/ -Dcom\.sun\.management\.jmxremote\.authenticate=true/ -Dcom\.sun\.management\.jmxremote\.authenticate=false/' /etc/cassandra/cassandra-env.sh
37+
RUN sed -ri 's/ -Dcom\.sun\.management\.jmxremote\.password\.file=\/etc\/cassandra\/jmxremote\.password//' /etc/cassandra/cassandra-env.sh
38+
# Escape $JVM_OPTS by including extra $
39+
# This command prepends content to /etc/cassandra/cassandra-env.sh
40+
RUN echo "`echo 'JVM_OPTS="$$JVM_OPTS -Djava.rmi.server.hostname=0.0.0.0"'; echo 'export LOCAL_JMX="no"'; cat /etc/cassandra/cassandra-env.sh`" > /etc/cassandra/cassandra-env.sh
41+
environment:
42+
LOCAL_JMX: no
43+
JVM_EXTRA_OPTS: "-Dcom.sun.management.jmxremote.authenticate=false"
44+
JMX_PORT: "${JMX_PORT:-7199}"
45+
ports:
46+
- "${JMX_PORT:-7199}:${JMX_PORT:-7199}"
47+
healthcheck:
48+
interval: 10s
49+
timeout: 10s
50+
retries: 20
51+
test:
52+
- "CMD"
53+
- "grep"
54+
- "-q"
55+
- "Startup complete"
56+
- "/var/log/cassandra/system.log"
2757
# Couchbase image for collectd-couchbase test:
2858
couchbase:
2959
image: quay.io/splunko11ytest/couchbase:latest
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#####################################################################################
2+
# Do not edit manually! #
3+
# All changes must be made to associated .tmpl file before running 'make bundle.d'. #
4+
#####################################################################################
5+
jmx/cassandra:
6+
enabled: true
7+
rule:
8+
docker_observer: type == "container" and any([name, image, command], {# matches "(?i)cassandra.*"}) and not (command matches "splunk.discovery")
9+
host_observer: type == "hostport" and command matches "(?i)cassandra.*" and not (command matches "splunk.discovery")
10+
k8s_observer: type == "port" and pod.name matches "(?i)cassandra.*"
11+
config:
12+
default:
13+
jar_path: /opt/opentelemetry-java-contrib-jmx-metrics.jar
14+
endpoint: "service:jmx:rmi:///jndi/rmi://`endpoint`/jmxrmi"
15+
target_system: cassandra
16+
collection_interval: 10s
17+
status:
18+
metrics:
19+
- status: successful
20+
strict: cassandra.client.request.count
21+
message: jmx/cassandra receiver is working!
22+
statements:
23+
- status: failed
24+
regexp: 'connect: network is unreachable'
25+
message: The container cannot be reached by the Collector. Make sure they're in the same network.
26+
- status: failed
27+
regexp: 'connect: connection refused'
28+
message: The container is refusing cassandra server connections.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{ receiver "jmx/cassandra" }}:
2+
enabled: true
3+
rule:
4+
docker_observer: type == "container" and any([name, image, command], {# matches "(?i)cassandra.*"}) and not (command matches "splunk.discovery")
5+
host_observer: type == "hostport" and command matches "(?i)cassandra.*" and not (command matches "splunk.discovery")
6+
k8s_observer: type == "port" and pod.name matches "(?i)cassandra.*"
7+
config:
8+
default:
9+
jar_path: /opt/opentelemetry-java-contrib-jmx-metrics.jar
10+
endpoint: "service:jmx:rmi:///jndi/rmi://`endpoint`/jmxrmi"
11+
target_system: cassandra
12+
collection_interval: 10s
13+
status:
14+
metrics:
15+
- status: successful
16+
strict: cassandra.client.request.count
17+
message: jmx/cassandra receiver is working!
18+
statements:
19+
- status: failed
20+
regexp: 'connect: network is unreachable'
21+
message: The container cannot be reached by the Collector. Make sure they're in the same network.
22+
- status: failed
23+
regexp: 'connect: connection refused'
24+
message: The container is refusing cassandra server connections.

internal/confmapprovider/discovery/bundle/bundle_gen.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
//go:generate discoverybundler -r -t bundle.d/extensions/k8s-observer.discovery.yaml.tmpl
2424
//go:generate discoverybundler -r -c -d ../../../../cmd/otelcol/config/collector/config.d.linux/extensions -t bundle.d/extensions/k8s-observer.discovery.yaml.tmpl
2525

26+
//go:generate discoverybundler -r -t bundle.d/receivers/jmx-cassandra.discovery.yaml.tmpl
27+
//go:generate discoverybundler -r -c -d ../../../../cmd/otelcol/config/collector/config.d.linux/receivers -t bundle.d/receivers/jmx-cassandra.discovery.yaml.tmpl
2628
//go:generate discoverybundler -r -t bundle.d/receivers/kafkametrics.discovery.yaml.tmpl
2729
//go:generate discoverybundler -r -c -d ../../../../cmd/otelcol/config/collector/config.d.linux/receivers -t bundle.d/receivers/kafkametrics.discovery.yaml.tmpl
2830
//go:generate discoverybundler -r -t bundle.d/receivers/mongodb.discovery.yaml.tmpl

internal/confmapprovider/discovery/bundle/bundledfs_other_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func TestBundleDir(t *testing.T) {
2727
receivers, err := fs.Glob(BundledFS, "bundle.d/receivers/*.discovery.yaml")
2828
require.NoError(t, err)
2929
require.Equal(t, []string{
30+
"bundle.d/receivers/jmx-cassandra.discovery.yaml",
3031
"bundle.d/receivers/kafkametrics.discovery.yaml",
3132
"bundle.d/receivers/mongodb.discovery.yaml",
3233
"bundle.d/receivers/mysql.discovery.yaml",

internal/confmapprovider/discovery/bundle/bundledfs_others.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
//go:embed bundle.d/extensions/docker-observer.discovery.yaml
2626
//go:embed bundle.d/extensions/host-observer.discovery.yaml
2727
//go:embed bundle.d/extensions/k8s-observer.discovery.yaml
28+
//go:embed bundle.d/receivers/jmx-cassandra.discovery.yaml
2829
//go:embed bundle.d/receivers/kafkametrics.discovery.yaml
2930
//go:embed bundle.d/receivers/mongodb.discovery.yaml
3031
//go:embed bundle.d/receivers/mysql.discovery.yaml

internal/confmapprovider/discovery/bundle/bundledfs_windows.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
//go:embed bundle.d/extensions/docker-observer.discovery.yaml
2626
//go:embed bundle.d/extensions/host-observer.discovery.yaml
2727
//go:embed bundle.d/extensions/k8s-observer.discovery.yaml
28+
//go:embed bundle.d/receivers/jmx-cassandra.discovery.yaml
2829
//go:embed bundle.d/receivers/kafkametrics.discovery.yaml
2930
//go:embed bundle.d/receivers/mongodb.discovery.yaml
3031
//go:embed bundle.d/receivers/mysql.discovery.yaml

internal/confmapprovider/discovery/bundle/bundledfs_windows_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func TestBundleDir(t *testing.T) {
2727
receivers, err := fs.Glob(BundledFS, "bundle.d/receivers/*.discovery.yaml")
2828
require.NoError(t, err)
2929
require.Equal(t, []string{
30+
"bundle.d/receivers/jmx-cassandra.discovery.yaml",
3031
"bundle.d/receivers/kafkametrics.discovery.yaml",
3132
"bundle.d/receivers/mongodb.discovery.yaml",
3233
"bundle.d/receivers/mysql.discovery.yaml",

internal/confmapprovider/discovery/bundle/components.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var (
3131
// If they are desired for !windows BundledFS inclusion (and a default linux conf.d entry), ensure they are included
3232
// in Components.Linux. If desired in windows BundledFS, ensure they are included in Components.Windows.
3333
receivers = []string{
34+
"jmx-cassandra",
3435
"kafkametrics",
3536
"mongodb",
3637
"mysql",
@@ -63,6 +64,7 @@ var (
6364
}(),
6465
Windows: func() map[string]struct{} {
6566
windows := map[string]struct{}{
67+
"jmx-cassandra": {},
6668
"kafkametrics": {},
6769
"mongodb": {},
6870
"mysql": {},

0 commit comments

Comments
 (0)