簡體   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