我在将标签添加到 Grafana 时遇到问题,但此问题仅存在于一个节点中。我已经有 3 个标签工作正常的 Promtail,我在这台机器上尝试了相同的示例,它属于同一个集群并且还连接到 Loki 端口。
这是我所拥有的:
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:
因此,当我将 grafana 放入变量时,我输入 'label_values(zeppelinError) 并且不显示标签。
以下是 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}"
这里是我要跟踪的日志:
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)
可能是我在这里缺少的一些小东西,希望你能帮我解决这个问题。
以下: 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/(遵循类似的构建)