Random Java API container for testing APM/DBM.
863
This container starts a java webserver that queries an upstream public API when the /fetch endpoint is hit. When the /query endpoint is hit the server queries a postgres database and returns results to the client.
This is meant to be used as a sandbox environment for testing Datadog's APM and DBM products and collecting JVM/JMX metrics.
To run this program, you need to pass the following environmental variables to the container, for example using docker-compose:
DB_HOST=172.20.0.2
DB_NAME=db
DB_PORT=5432
DB_USER=myuser
DB_PASSWORD=mypassword
JAVA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8001 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -XX:FlightRecorderOptions=stackdepth=256 -Ddd.profiling.enabled=true -Ddd.logs.injection=true -Ddd.service=java_app -Ddd.env=java -Ddd.version=1.0"
And your docker docker compose file would look like below (calls a postgres database and creates the user tables)
version: '3'
services:
postgres_test_db:
image: postgres:latest
restart: always
environment:
- POSTGRES_HOST=127.0.0.1
- POSTGRES_PORT=${DB_PORT}
- POSTGRES_DB=${DB_NAME}
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASSWORD}
- DD_TAGS=env:java
ports:
- 5445:5432
networks:
mynetwork:
ipv4_address: 172.20.0.2
healthcheck:
test: ["CMD", "pg_isready", "-U", "${DB_USER}", "-d", "${DB_NAME}"]
interval: 10s
timeout: 5s
retries: 3
random_java_api:
build:
context: .
dockerfile: Dockerfile
environment:
- JAVA_OPTS=${JAVA_OPTS}
- DBHOST=${DB_HOST}
- DBPORT=${DBPORT}
- DATABASE_USER=${DB_USER}
- DATABASE_PASSWORD=${DB_PASSWORD}
- DATABASE_NAME=${DB_NAME}
ports:
- 8000:8000
- 8001:8001
networks:
mynetwork:
ipv4_address: 172.20.0.3
depends_on:
postgres_test_db:
condition: service_healthy
networks:
mynetwork:
ipam:
config:
- subnet: 172.20.0.0/16
Content type
Image
Digest
sha256:1a4f67169…
Size
344.3 MB
Last updated
about 3 years ago
docker pull bhartford419/random_java_api