Can't add pyroscope datasource - error 404

docker-compose.yml

services:
  pyroscope:
    hostname: pyroscope
    container_name: pyroscope
    image: "pyroscope/pyroscope:latest"
    deploy:
      restart_policy:
        condition: on-failure
    ports:
      - "4040:4040"
    command: "server"
    volumes:
      - pyroscope_data:/var/lib/pyroscope
  grafana:
    hostname: grafana
    container_name: grafana
    image: grafana/grafana:latest
    environment:
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
      - GF_AUTH_DISABLE_LOGIN_FORM=true
      - GF_FEATURE_TOGGLES_ENABLE=traceqlEditor metricsSummary
    ports:
      - "3000:3000"
volumes:
  pyroscope_data:

pyroscope 4040 ok
try add pyroscope in grafana
http://pyroscope:4040

show: unimplemented: 404 Not Found

Ensure that you’re using the correct URL when adding Pyroscope as a datasource in Grafana. The URL should be http://pyroscope:4040, but make sure the DNS resolution works from Grafana container to the Pyroscope container. This might not work if the Grafana container cannot resolve pyroscope as the hostname.

Solution:

  • Instead of using http://pyroscope:4040, try using the full container IP or use localhost or 127.0.0.1 if both Grafana and Pyroscope are in the same container network:
    http://localhost:4040

Add a network section to the docker-compose.yml:

version: "3"
services:
  pyroscope:
    hostname: pyroscope
    container_name: pyroscope
    image: "pyroscope/pyroscope:latest"
    deploy:
      restart_policy:
        condition: on-failure
    ports:
      - "4040:4040"
    command: "server"
    volumes:
      - pyroscope_data:/var/lib/pyroscope
    networks:
      - pyroscope_network

  grafana:
    hostname: grafana
    container_name: grafana
    image: grafana/grafana:latest
    environment:
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
      - GF_AUTH_DISABLE_LOGIN_FORM=true
      - GF_FEATURE_TOGGLES_ENABLE=traceqlEditor metricsSummary
    ports:
      - "3000:3000"
    networks:
      - pyroscope_network

networks:
  pyroscope_network:

volumes:
  pyroscope_data: