简体   繁体   English

促销标签

[英]Promtail labels

I'm having trouble adding labels into Grafana, but this issue is only in one node.我在将标签添加到 Grafana 时遇到问题,但此问题仅出现在一个节点中。 I have already 3 Promtails with labels working properly, I tried the same example on this machine which belongs to the same cluster and also has connectivity to Loki port.我已经有 3 个带有标签的 Promtails 正常工作,我在这台机器上尝试了相同的例子,它属于同一个集群并且也连接到 Loki 端口。

Here is what I have:这是我所拥有的:

server:
  http_listen_port: 9080
  grpc_listen_port: 0

positions:
  filename: /usr/hdp/promtail/data/positions.yaml

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

scrape_configs:
  - job_name: zeppelin
    static_configs:
    - targets:
        - machine1:9080
      labels:
        host: machine1
        stream: zeppelin
        job: zeppelin
        __path__: /usr/hdp/logs/zeppelin/zeppelin-zeppelin-machine1.log
    pipeline_stages:
    - match:
        selector: '{job="zeppelin"}'
        stages:
        - regex:
            expression: '(?P<zeppelinError>RemoteInterpreterManagedProcess)'
        - labels:
            zeppelinError:

So when I go to grafana into variables I type 'label_values(zeppelinError) and don't show me the label.因此,当我将 grafana 转到变量时,我键入“label_values(zeppelinError)”并且不向我显示标签。

Here are the logs from Promtail, with looks fine:以下是 Promtail 的日志,看起来不错:

Aug 10 11:47:14 machine1 systemd[1]: Started Promtail service.
Aug 10 11:47:14 machine1 promtail[25496]: level=info ts=2021-08-10T10:47:14.666205865Z caller=server.go:225 http=0.0.0.0:9080 grpc=0.0.0.0:44903 msg="server listening on addresses"
Aug 10 11:47:14 machine1 promtail[25496]: level=info ts=2021-08-10T10:47:14.666573544Z caller=main.go:108 msg="Starting Promtail" version="(version=2.0.0, branch=HEAD, revision=6978ee5d)"
Aug 10 11:47:19 machine1 promtail[25496]: level=info ts=2021-08-10T10:47:19.663478261Z caller=filetargetmanager.go:261 msg="Adding target" key="{host=\"machine1\", job=\"zeppelin\", stream=\"zeppelin\"}"
Aug 10 11:47:19 machine1 promtail[25496]: level=info ts=2021-08-10T10:47:19.667623654Z caller=tailer.go:122 component=tailer msg="tail routine: started" path=/usr/hdp/logs/zeppelin/zeppelin-zeppelin-machine1.log
Aug 10 11:47:19 machine1 promtail[25496]: ts=2021-08-10T10:47:19.668843991Z caller=log.go:124 component=tailer level=info msg="Seeked /usr/hdp/logs/zeppelin/zeppelin-zeppelin-machine1.log - &{Offset:713999 Whence:0}"

And here the log I want to trace:这里是我想跟踪的日志:

ERROR [2021-07-30 06:37:40,836] ({pool-4-thread-74} NotebookServer.java[afterStatusChange]:2294) - Error
java.lang.RuntimeException: 
    at org.apache.zeppelin.interpreter.remote.RemoteInterpreterManagedProcess.start(RemoteInterpreterManagedProcess.java:205)

Probably is something small I'm missing here, hope you can give me a hand on this matter.可能是我在这里遗漏的一些小东西,希望你能帮我解决这个问题。

Following: https://grafana.com/docs/loki/latest/clients/promtail/stages/regex/#schema (how to capture data), https://github.com/google/re2/wiki/Syntax (Regex Expression Rules), https://sbcode.net/grafana/nginx-promtail/ (following a similar build)以下: https : //grafana.com/docs/loki/latest/clients/promtail/stages/regex/#schema (如何捕获数据), https://github.com/google/re2/wiki/Syntax (Regex表达式规则), https://sbcode.net/grafana/nginx-promtail/ (遵循类似的构建)

Oddly, I ended up implementing this just like you did and had the same issue, so if we are doing something wrong, it means the docs are not as clear as they could be.奇怪的是,我最终像你一样实现了这个,并遇到了同样的问题,所以如果我们做错了什么,这意味着文档不够清晰。 I couldn't get more than one label to be recognised and the only working label would work on one machine but not another, with the same config.我无法识别多个标签,唯一的工作标签可以在一台机器上工作,但不能在另一台机器上工作,具有相同的配置。

Looking at the documentation though, I spotted that starting with Loki 2.3.0, LogQL supports dynamic creation of labels on query:不过查看文档,我发现从 Loki 2.3.0 开始,LogQL 支持在查询时动态创建标签:

https://grafana.com/docs/loki/latest/logql/log_queries/#parser-expression https://grafana.com/docs/loki/latest/logql/log_queries/#parser-expression

So, after spending way too long trying to get this fixed to no avail, I decided to rip out the pipeline stages from the Promtail config and apply the regex directly on the Loki query:因此,在花了很长时间试图解决这个问题却无济于事之后,我决定从 Promtail 配置中删除管道阶段,并直接在 Loki 查询上应用正则表达式:

https://grafana.com/docs/loki/latest/logql/log_queries/#regular-expression https://grafana.com/docs/loki/latest/logql/log_queries/#regular-expression

Which finally fixed my problem.这最终解决了我的问题。 I've now applied this on all Promtail-ed machines.我现在已经在所有 Promtail-ed 机器上应用了它。

I hope this helps but if someone knows how to fix labelling via the Promtail config, that would still be very helpful to know as an alternative since there's a limit to dynamic labels before they start making querying too heavy.我希望这会有所帮助,但如果有人知道如何通过 Promtail 配置修复标签,那么知道作为替代方案仍然非常有帮助,因为在动态标签开始使查询变得过于繁重之前存在限制。

Cheers.干杯。

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

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