LoginSignup
1
0

[Grafana Loki+Fluent Bit] "400 Bad Request ... has timestamp too new"の解決方法

Posted at

Grafanaでsyslogが表示されない

Dockerコンテナで動かしているGrafana Lokiに、FluentdでRaspberry Pi 4のsyslogを収集する環境を構築したのですが、Fluentdより軽量なFluent Bitに変えたところ、エラーが発生してGrafanaに表示されない問題が発生しました。解決までに結構苦労したので参考になれば幸いです。

Docker、Grafana Loki、Fluent Bitなどのインストール、設定方法は、公式やその他の記事を参照してください。

エラー内容

Lokiにrsyslogのデータを転送すると、Lokiから"400 Bad Request ... has timestamp too new"というエラーが返ってきて、Grafanaにsyslogが表示されませんでした。

2023-12-30 18:44:15 +0900 [warn]: #0 failed to write post to 
http://192.168.0.15:3100/loki/api/v1/push (400 Bad Request 10 
errors like: entry for stream '{app="dev", host="raspberrypi", pid="95412"}' 
has timestamp too new: 2023-12-30T18:44:13Z)

解決方法

結局、Fluent BitのsyslogパーサーにTime_Offsetを追加したというGitHubのissuesを見つけて試したところ、エラーがなくなりGrafanaでsyslogが表示されるようになりました。

parsers.conf
[PARSER]
    Name        syslog-rfc3164
    Format      regex
    Regex       /^\<(?<pri>[0-9]+)\>(?<time>[^ ]* {1,2}[^ ]* [^ ]*) (?<host>[^ ]*) (?<ident>[a-zA-Z0-9_\/\.\-]*)(?:\[(?<pid>[0-9]+)\])?(?:[^\:]*\:)? *(?<message>.*)$/
    Time_Key    time
    Time_Format %b %d %H:%M:%S
+   Time_Offset +0900
    Time_Keep   On

参考情報

https://grafana.com/docs/loki/latest/setup/install/docker/#install-with-docker-compose
https://docs.fluentbit.io/manual/installation/linux/debian
https://docs.fluentbit.io/manual/pipeline/inputs/syslog#rsyslog_to_fluentbit_network
https://docs.fluentbit.io/manual/pipeline/outputs/loki
https://docs.fluentbit.io/manual/v/1.3/parser
https://github.com/fluent/fluent-bit/issues/4206

以上です。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0