Search code examples
dockerdocker-composegrafanaclickhouse

Grafana+Clickhouse+Docker. Can't connect to data source


I trying to connect to Clickhouse from Grafana. Both running locally in Docker. When I set all required settings in "Add data source" window and click 'Save and test' it immediately says 'Plugin health check failed'.

My docker compose file:

services:
  grafana:
    image: grafana/grafana
    ports:
      - 3000:3000
    volumes:
      - grafana-storage:/var/lib/grafana
  clickhouse:
    image: clickhouse/clickhouse-server
    ports:
      - 8123:8123
      - 9000:9000
      - 9100:9100
      - 9440:9440
    volumes:
      # - ./run/clickhouse/users.xml:/etc/clickhouse-server/users.xml
      - clickhouse-storage:/var/lib/clickhouse/
      - clickhouse-logs:/var/log/clickhouse-server
    environment:
      - CLICKHOUSE_USER=tymbaca
      - CLICKHOUSE_PASSWORD=qwerty
volumes:
  grafana-storage:
  clickhouse-storage:
  clickhouse-logs:

enter image description here enter image description here

I also tryed to set Server address field to 192.168.0.17 (IPv4 from ipconfig) but it leads to connection timeout...


Solution

  • How @Turing85 pointed, the problem was that the request from Grafana to Clickhouse was made from within the Grafana container.

    Therefore the Server address must be not localhost but Clickhouse container name (stackexchange-analyzer-clickhouse-1 in my case).

    enter image description here

    enter image description here

    enter image description here