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

Better local docker instructions for misbehaving-jmx-server #479

Merged
merged 5 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
20 changes: 13 additions & 7 deletions tools/misbehaving-jmx-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,18 @@ There are a couple of ways you can get the Agent to pull metrics from this test
Copy `misbehaving-jmxfetch-conf.yaml` to `/etc/datadog-agent/conf.d/` and just run the `with-dependencies` jar created by Maven.
You will need to restart the Agent to pick up the config.

### Using Docker Compose

```shell
$ docker compose up
```

The Agent will auto discover the container and begin to collect metrics from it.
scottopell marked this conversation as resolved.
Show resolved Hide resolved

### Using Docker

After building the `misbehaving-jmx-server` you can simply run:
If your container's IP is directly
accessible by your Agent, you can use the following run command and use AD.
scottopell marked this conversation as resolved.
Show resolved Hide resolved

```shell
$ docker run \
Expand All @@ -66,10 +75,7 @@ misbehaving-jmx-server

The Agent will auto discover the container and begin to collect metrics from it.

### Using Docker Compose
Note that this implicitly sets the `RMI_HOSTNAME` to `localhost` which is where
the host port mapping comes into play. If this is giving you trouble, consider
using the docker-compose setup above.
scottopell marked this conversation as resolved.
Show resolved Hide resolved

```shell
$ docker compose up
```

The Agent will auto discover the container and begin to collect metrics from it.
19 changes: 16 additions & 3 deletions tools/misbehaving-jmx-server/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,24 @@
version: "3.9"

services:

test-server:
# The docker compose service name is used as the hostname for the misbehaving-jmx-server
# Note it is in the entrypoint as the --rmi-host and in the AD label as the hostname
# that the Agent should reach out to.
jmx-test-server:
build:
context: .
# Override entrypoint to specify the docker-compose service name as the RMI host
entrypoint: ["java", "-cp", "misbehavingjmxserver-1.0-SNAPSHOT-jar-with-dependencies.jar", "org.datadog.misbehavingjmxserver.App", "--rmi-host", "jmx-test-server"]
ports:
- "1099:1099"
labels:
com.datadoghq.ad.checks: '{"misbehaving":{"init_config":{"is_jmx":true},"instances":[{"host":"%%host%%","port":"1099","collect_default_jvm_metrics":false,"max_returned_metrics":300000,"conf":[{"include":{"domain":"Bohnanza"}}]}]}}'
com.datadoghq.ad.checks: '{"misbehaving":{"init_config":{"is_jmx":true},"instances":[{"host":"jmx-test-server","port":"1099","collect_default_jvm_metrics":false,"max_returned_metrics":300000,"conf":[{"include":{"domain":"Bohnanza"}}]}]}}'
datadog:
image: datadog/agent:7-jmx
pid: host
environment:
- DD_API_KEY=000000001
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /proc/:/host/proc/:ro
- /sys/fs/cgroup:/host/sys/fs/cgroup:ro
Loading