I'm running JPetStore6 with no code otel java agent and otel collector in the same docker container. Everything starts, but jpet is unable to export data to the collector, despite they are in the same docker container a separate services.
That's the error: Failed to connect to otel-collector/172.19.0.2:4317
docker-compose and otel-collector-config are in the root, the agent is in src/lib folder
docker-compose.yaml:
services:
jpetstore:
container_name: jpetstore
build:
context: .
ports:
- 8080:8080
restart: always
environment:
- JAVA_TOOL_OPTIONS="-javaagent:/opentelemetry-javaagent.jar"
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT:"http://otel-collector:4318/"
- OTEL_EXPORTER_OTLP_METRICS_ENDPOINT:"http://otel-collector:4318/"
- OTEL_EXPORTER_OTLP_LOGS_ENDPOINT:"http://otel-collector:4318/"
volumes:
- ./src/lib/opentelemetry-javaagent.jar:/opentelemetry-javaagent.jar
depends_on:
- otel-collector
otel-collector:
image: otel/opentelemetry-collector-contrib:latest
command: ["--config=/otel-collector-config.yaml"]
volumes:
- ./otel-collector-config.yaml:/otel-collector-config.yaml
expose:
- "4317"
- "4318"
ports:
- "4317:4317"
- "4318:4318"
restart: always
otel-collector-config
extensions:
zpages:
endpoint: "localhost:55679"
basicauth/grafana_cloud:
client_auth:
username: "MYUSERNAME"
password: "MYPASSWORD"
receivers:
otlp:
protocols:
grpc:
http:
hostmetrics:
scrapers:
cpu:
load:
memory:
docker_stats:
endpoint: unix:///var/run/docker.sock
collection_interval: 10s
processors:
batch:
resourcedetection:
detectors: ["env", "system"]
override: false
transform/drop_unneeded_resource_attributes:
error_mode: ignore
trace_statements:
- context: resource
statements:
- delete_key(attributes, "k8s.pod.start_time")
- delete_key(attributes, "os.description")
- delete_key(attributes, "os.type")
- delete_key(attributes, "process.command_args")
- delete_key(attributes, "process.executable.path")
- delete_key(attributes, "process.pid")
- delete_key(attributes, "process.runtime.description")
- delete_key(attributes, "process.runtime.name")
- delete_key(attributes, "process.runtime.version")
metric_statements:
- context: resource
statements:
- delete_key(attributes, "k8s.pod.start_time")
- delete_key(attributes, "os.description")
- delete_key(attributes, "os.type")
- delete_key(attributes, "process.command_args")
- delete_key(attributes, "process.executable.path")
- delete_key(attributes, "process.pid")
- delete_key(attributes, "process.runtime.description")
- delete_key(attributes, "process.runtime.name")
- delete_key(attributes, "process.runtime.version")
log_statements:
- context: resource
statements:
- delete_key(attributes, "k8s.pod.start_time")
- delete_key(attributes, "os.description")
- delete_key(attributes, "os.type")
- delete_key(attributes, "process.command_args")
- delete_key(attributes, "process.executable.path")
- delete_key(attributes, "process.pid")
- delete_key(attributes, "process.runtime.description")
- delete_key(attributes, "process.runtime.name")
- delete_key(attributes, "process.runtime.version")
transform/add_resource_attributes_as_metric_attributes:
error_mode: ignore
metric_statements:
- context: datapoint
statements:
- set(attributes["deployment.environment"], resource.attributes["deployment.environment"])
- set(attributes["service.version"], resource.attributes["service.version"])
exporters:
otlphttp/grafana_cloud:
endpoint: "https://otlp-gateway-prod-eu-west-2.grafana.net/otlp"
auth:
authenticator: basicauth/grafana_cloud
debug:
verbosity: detailed
service:
extensions: [basicauth/grafana_cloud, zpages]
pipelines:
traces:
receivers: [otlp]
processors: [resourcedetection, transform/drop_unneeded_resource_attributes, batch]
exporters: [otlphttp/grafana_cloud, debug]
metrics:
receivers: [otlp, hostmetrics]
processors: [resourcedetection, transform/drop_unneeded_resource_attributes, transform/add_resource_attributes_as_metric_attributes, batch]
exporters: [otlphttp/grafana_cloud, debug]
logs:
receivers: [otlp]
processors: [resourcedetection, transform/drop_unneeded_resource_attributes, batch]
exporters: [otlphttp/grafana_cloud, debug]
I supposed it is a problem that the agent is trying to reach localhost, which doesn't exist inside docker, but also after overriding with enviroments still nothing.