“未找到的日志”在格拉法纳

发布于 2025-01-20 11:34:35 字数 1167 浏览 3 评论 0原文

我安装了Loki,Grafana和Promtail以及所有三个跑步。在http:// localhost:9080/准备就绪的目标是正确的,但是日志没有显示在grafana中,并在探索部分显示“未找到的logs”

Promtail-loctail-local-config-yaml:

server:
  http_listen_port: 9080
  grpc_listen_port: 0

positions:
  filename: /tmp/positions.yaml

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

scrape_configs:
- job_name: system
  static_configs:
  - targets:
      - localhost
    labels:
      job: varlogs
      host: ward_workstation
      agent: promtail
      __path__: D:/LOGs/*log

loki-loci-local-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

如何我可以解决这个问题吗?

I installed Loki, grafana and promtail and all three runing. on http://localhost:9080/targets Ready is True, but the logs are not displayed in Grafana and show in the explore section "No logs found"

promtail-local-config-yaml:

server:
  http_listen_port: 9080
  grpc_listen_port: 0

positions:
  filename: /tmp/positions.yaml

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

scrape_configs:
- job_name: system
  static_configs:
  - targets:
      - localhost
    labels:
      job: varlogs
      host: ward_workstation
      agent: promtail
      __path__: D:/LOGs/*log

loki-local-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

How can i solve this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只是偏爱你 2025-01-27 11:34:35

也许您在Windows中使用Loki?

在您的Promtail Varlogs作业中,“ D:/logs/*log”路径显然是错误的,您无法直接从Docker访问Windows文件。

您会像这样将Windows文件安装到Docker上:

  promtail:
    image: grafana/promtail:2.5.0
    volumes:
      - D:/LOGs:/var/log
    command: -config.file=/etc/promtail/config.yml
    networks:
      - loki

那么一切都会好起来的。

请注意,在您的Promtail Docker中,配置就是这样:

您可以调整两者以进行匹配...

Perhaps you are using Loki in Windows ?

In your promtail varlogs job ,the Path "D:/LOGs/*log" is obviously wrong, you cannot access the windows file from your docker directly.

You shoud mount your windows file to your docker like this:

  promtail:
    image: grafana/promtail:2.5.0
    volumes:
      - D:/LOGs:/var/log
    command: -config.file=/etc/promtail/config.yml
    networks:
      - loki

Then everything will be ok.

Note that, in your promtail docker the config is like this:
enter image description here

you can adjust both to make a match...

谁许谁一生繁华 2025-01-27 11:34:35

这是根据问题的标题进行调试的一般建议:

(1)检查Promtail日志
如果发现错误发送批处理您需要修复 Promtail 配置。

level=warn ts=2022-10-12T16:26:20.667560426Z caller=client.go:369 component=client host=monitor:3100 msg="error sending batch, will retry" status=-1 error="Post \"http://loki:3100/loki/api/v1/push\": dial tcp: lookup *Loki* on 10.96.0.10:53: no such host"

(2)打开 Promtail 配置页面并检查,如果 promtail 已读取您的给定配置:http:// localhost:3101/config

(3)打开 ProMTAIL 目标页面http:// localhost:3101/targets,并检查

  1. 您的服务是否列为 Ready
  2. 如果日志文件包含了通缉的内容,并且可以通过 PromTail 。如果您使用Docker或Kubernetes,我将登录到Promtail容器中,并尝试手动阅读日志文件。

对于发问者的具体问题:

发问者说,这些服务在目标页面中已准备就绪。因此,我建议检查(1)Promtail配置和(3B)访问日志文件(作为弗兰克)。

Here's a general advice how to debug Loki according to the question's title:

(1) Check promtail logs
If you discover such as error sending batch you need to fix your Promtail configuration.

level=warn ts=2022-10-12T16:26:20.667560426Z caller=client.go:369 component=client host=monitor:3100 msg="error sending batch, will retry" status=-1 error="Post \"http://loki:3100/loki/api/v1/push\": dial tcp: lookup *Loki* on 10.96.0.10:53: no such host"

(2) Open the Promtail config page and check, if Promtail has read your given configuration: http://localhost:3101/config

(3) Open the Promtail targets page http://localhost:3101/targets and check

  1. if your service is listed as Ready
  2. if the log file contains the wanted contents and is readable by Promtail. If you're using docker or kubernetes I would log into the Promtail Container and would try to read the logfile manually.

To the specific problem of the questioner:

The questioner said, that the services are shown as READY in the targets page. So I recommend to check (1) Promtail configuration and (3b) access to log files (as Frank).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文