2

我正在尝试使用相同的 docker compose 将我的应用程序记录到 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 容器到 loki 容器进行 nc 操作,它似乎看到了它....有什么想法吗?

4

1 回答 1

1

当您想从另一个容器访问 Loki 时,需要侦听所有接口,而不仅仅是 localhost:

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
于 2022-02-10T17:26:40.983 回答