繁体   English   中英

Grafana 看不到 loki(docker-compose 设置)

[英]Grafana does not see loki (docker-compose setup)

我正在尝试使用相同的 docker 组合将我的应用程序登录到 grafana/loki/promtail,并且在连接到 loki 时出现以下错误:

localhost:3100 -> 404 页面未找到

当我尝试将它挂在 grafana 中时:

URL [http://loki:3100 ]-> Loki:错误的网关。 502错误的网关

我已经看到你必须在 grafana 中输入容器的名称才能检测到它,但我得到了同样的错误。

promtail 和 loki 容器在它们的日志中都没有显示错误。

version: "3.7"

services:   
my-service-to-log:
    image: example:latest
    ports:
      - "8080:8080"
      - "8443:8443"
 loki:
    image: grafana/loki:2.4.1
    ports:
      - "3100:3100"
    volumes:
      - "C:/path/loki-config.yaml:/etc/loki/local-config.yaml"
    command: -config.file=/etc/loki/local-config.yaml

   promtail:
    image: grafana/promtail:2.4.1
    volumes:
      - "C:/path/promtail-config.yaml:/etc/promtail/config.yml"
      - /var/log:/var/log
    command: -config.file=/etc/promtail/config.yml

   grafana:
    image: grafana/grafana:latest
    ports:
      - "3000:3000"

我的 loki-config.yaml

auth_enabled: false

server:
  http_listen_port: 3100
  grpc_listen_port: 9096

common:
  path_prefix: /tmp/loki
  storage:
    filesystem:
      chunks_directory: /tmp/loki/chunks
      rules_directory: /tmp/loki/rules
  replication_factor: 1
  ring:
    instance_addr: 127.0.0.1
    kvstore:
      store: inmemory

schema_config:
  configs:
    - from: 2020-10-24
      store: boltdb-shipper
      object_store: filesystem
      schema: v11
      index:
        prefix: index_
        period: 24h

ruler:
  alertmanager_url: http://localhost:9093

还有我的 promtail-config.yaml

server:
  http_listen_port: 9080
  grpc_listen_port: 0

positions:
  filename: /tmp/positions.yaml

clients:
  - url: http://loki:3100/loki/api/v1/push

scrape_configs:
- job_name: system
  static_configs:
  - targets:
      - localhost
    labels:
      job: varlogs
      __path__: /opt/app/logs/*.log
/ # nc -vz localhost 3100
localhost (127.0.0.1:3100) open

我尝试从 grafana 容器 nc 到 loki 容器,它似乎看到了……有什么想法吗?

当你想从另一个容器访问它时,Loki 需要监听所有接口,而不仅仅是本地主机:

common:
  path_prefix: /tmp/loki
  storage:
    filesystem:
      chunks_directory: /tmp/loki/chunks
      rules_directory: /tmp/loki/rules
  replication_factor: 1
  ring:
    instance_addr: 0.0.0.0
    kvstore:
      store: inmemory

在 Grafana 中将 Loki 添加为数据源时,不要使用 http://localhost:3100,而是使用计算机拥有的 ip 地址,而不是 localhost。 示例 http://LAN_IP_ADDR:3100

您必须将所有容器放在同一个 virtual.network 上。 没有这个,他们就无法看到对方。

version: "3.7"

networks:
  loki:

services:   
  my-service-to-log:
    image: example:latest
    ports:
      - "8080:8080"
      - "8443:8443"
    networks:
      - loki

  loki:
    image: grafana/loki:2.4.1
    ports:
      - "3100:3100"
    volumes:
      - "C:/path/loki-config.yaml:/etc/loki/local-config.yaml"
    command: -config.file=/etc/loki/local-config.yaml
    networks:
      - loki

   promtail:
    image: grafana/promtail:2.4.1
    volumes:
      - "C:/path/promtail-config.yaml:/etc/promtail/config.yml"
      - /var/log:/var/log
    command: -config.file=/etc/promtail/config.yml
    networks:
      - loki

   grafana:
    image: grafana/grafana:latest
    ports:
      - "3000:3000"
    networks:
      - loki

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM