问题描述
该笔记将记录:与 Promtail 有关的内容、使用方法、以及相关问题的解决办法;
解决方案
Promtail,其为日志采集工具,其将采集分散在各个环境中的日志,并发送到集中的日志存储服务 Grafana Loki 中;
概念术语
Configuration
配置文件(promtail.yaml)的配置参数,以及相关说明;
Pipelines
从 抓取日志 到 发送到日志存储服务,总共分为四步:
1)Parsing stages parse the current log line and extract data out of it. The extracted data is then available for use by other stages.
2)Transform stages transform extracted data from previous stages.
3)Action stages take extracted data from previous stages and do something with them. Actions can:
4)Filtering stages optionally apply a subset of stages or drop entries based on some condition.
Scraping
从日志源(诸如 File、systemd journal、Windows Envent、Syslog 等等 )中抓取日志的方法;
Stages
各种 Stages 的使用方法;
Troubleshooting
运行 prometail 命令,能够针对 scrape_configs 配置进行调试,观察其行为
cat my.log | promtail --stdin --dry-run --inspect --client.url http://127.0.0.1:3100/loki/api/v1/push cat my.log | promtail --config.file promtail.yaml
但是 clients.external_labels 似乎无法通过该方式进行显示,或许是 promtail 2.5.0 暂时不支持;
Cloud setup GCP Logs
官方文档的该部分内容与 GCP 相关,所以并非我们关注的重点,所以我们将忽略该部分;
参考文献
Troubleshooting | Grafana Loki documentation