[Datadog] Unable to lee metrics in Datadog metric explorer(Datadog Docker agent)

Hey guys,

I am trying to send customer metric from local using docker. I am running two containers:

  1. datadog agent: exposing on 8126/tcp
  2. datadog statsD agent: exposing on 8125/udp
    This is my docker-compose file:
  agent:
    image: "datadog/agent:latest"
    environment:
      - DD_API_KEY=<key>
      - DD_APM_ENABLED=true
      - DD_LOGS_ENABLED=true
      - DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true
      - DD_PROCESS_AGENT_ENABLED=true
      - DD_TAGS='ohm:local'
    ports:
      - "8126:8126/tcp"
    networks:
      - imploy_net
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /proc/:/host/proc/:ro
      - /sys/fs/cgroup/:/host/sys/fs/cgroup:ro
  StatsD:
    image: "datadog/dogstatsd:latest"
    environment:
      - DD_API_KEY=<key>
      - DD_APM_ENABLED=true
      - DD_LOGS_ENABLED=true
      - DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true
      - DD_PROCESS_AGENT_ENABLED=true
      - DD_TAGS='ohm:local'
      - DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true
      - DD_ENABLE_METADATA_COLLECTION=true
      - DD_SEND_HOST_METADATA=true
      - DD_DOGSTATSD_DISABLE=false
      - DD_AGENT_HOST=agent
    ports:
      - "8125:8125/udp"
    networks:
      - imploy_net
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /proc/:/host/proc/:ro
      - /sys/fs/cgroup/:/host/sys/fs/cgroup:ro```
I am connecting to `localhost:8125`  in code and trying to send some `Incr`  and `Gauge`  metric. but i could not able to see it in my datadog metric explorer. Just FYI, all the logs in the application is being appeared normally on datadog but its just the metrics which I am not able to see.

can some please help me out with this.

I fixed it. in case if someone faces the same issue, while connecting from code, you need to specify the container name, instead of localhost:8125 you need to specify StatsD:8125

Curious why you’re running the agent AND the statsd image. If I’m not mistaken the dogstatsd standalone image is meant for setups where you don’t need the full agent.

https://docs.datadoghq.com/agent/#overview

> This package is used in containerized environments where DogStatsD runs as a sidecar or environments running a DogStatsD server without full Agent functionality.

Actually when i exposed the PORT: 8125/udp on the main agent, it was not detecting the metrics

I am using ECS, so just to confirm, I have to just expose 8125 on existing agent container and it would work fine?

I believe that is correct. We expose/map 8125 and 8126 on our agent. You may also need to allow for non-local traffic.

Yeah, you’ll need to set DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true

https://docs.datadoghq.com/containers/amazon_ecs/?tab=awscli#create-an-ecs-task

Not sure, why but on local setup with above docker-compose, it was not taking it

Do i need to use any specific version may be like v6 instead of v5?

Of the agent? No. I don’t think that should matter. I don’t have any experience with using the agent with docker-compose, though.

Do logs and traces work?

Yes logs and traces works perfectly fine

I just dont want to run a saperate side car, it will increase the AWS costs, so it would be better if it just works from agent itself :crossed_fingers:

Looking at the compose example from Datadog:
https://github.com/DataDog/docker-compose-example

Perhaps you need to add the links section? Not sure if your network setup does the same thing.

Yeah i check those, I am running all the containers on same network, so it should be accessible

I think link should not be an issue, coz traces and logs are working fine

That makes sense. I fear I may have reached the limits of my usefulness. Perhaps reaching out to DD directly will yield better results?

Ohh yes, Thanks a lot, it was really helpful :smile: . I will try to first expose 8125 on same container, lets see if it works, if it does not, will reach out to dd