我使用PLG堆栈(promtail, loki, grafana)来收集系统日志,并且我需要用从日志消息中提取的日期覆盖loki添加的集成日期,
我不能让它工作,这是我的例子:
scrape_configs:
- job_name: "service-0 "
static_configs:
- targets:
- localhost
labels:
service: service -0
host: " service-0-xyz.local "
timestamp:
environment: "dev"
__path__: /etc/sys.log
pipeline_stages:
- match:
selector: '{service="service -0"}'
stages:
- regex:
expression: '(?P<timestamp>^(^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}))'
- timestamp:
source: timestamp
format: RFC3339Nano
- labels:
'timestamp:
grafana视图你能举个例子吗?
谢谢你的帮助
我已经尝试将loki/promtail更新到最新版本,
我添加了名为"时间戳"的新字段;由从日志消息中提取的日期填充,但无法更改集成日期
我发现了这个讨论,但是我不能使它工作
如果有人需要解决方案,问题是时间戳格式,我通过更改promtail配置使其工作,如下所示:
scrape_configs:
- job_name: "service-0 "
static_configs:
- targets:
- localhost
labels:
service: service-0
host: "service-0-xyz.local "
environnement: "dev"
__path__: /etc/sys.log
pipeline_stages:
- regex:
expression: "^(?P<timestamp>\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\.\d{3}).*$"
- timestamp:
source: timestamp
format: "2006-01-02 15:04:05.000"
location: "Europe/Paris"