差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
softwares:fluent_bit:fluent_bit_go_redit_output [2024/01/29 15:50] – [使ってみる: NestDAQ の出力を Redis に保存 (その2)] kobayashsoftwares:fluent_bit:fluent_bit_go_redit_output [2024/02/01 21:25] (現在) – [使ってみる: NestDAQ の出力を Redis に保存 (その2)] kobayash
行 53: 行 53:
 $ pwd # 今いるディレクトリを一応確認 $ pwd # 今いるディレクトリを一応確認
 /home/nestdaq/nestdaq/src/fluent-bit-go-redis-output /home/nestdaq/nestdaq/src/fluent-bit-go-redis-output
-$ fluent-bit -e ./out_redis.so -c fluent-bit.conf 
 $ fluent-bit -e ./out_redis.so -c fluent-bit.conf $ fluent-bit -e ./out_redis.so -c fluent-bit.conf
 Fluent Bit v3.0.0 Fluent Bit v3.0.0
行 278: 行 277:
 133398) "{\"@tag\":\"stdin.0\",\"@timestamp\":\"2024-01-29T06:25:41.867296049Z\"}" 133398) "{\"@tag\":\"stdin.0\",\"@timestamp\":\"2024-01-29T06:25:41.867296049Z\"}"
 133399) "{\"@tag\":\"stdin.0\",\"@timestamp\":\"2024-01-29T06:25:41.867303618Z\",\"message\":\"[\\u001b[01;36m15:25:41\\u001b[0m][\\u001b[01;32mINFO\\u001b[0m] out[0]: in: 0 (0 MB) out: 0.999001 (0.000559441 MB)\"}" 133399) "{\"@tag\":\"stdin.0\",\"@timestamp\":\"2024-01-29T06:25:41.867303618Z\",\"message\":\"[\\u001b[01;36m15:25:41\\u001b[0m][\\u001b[01;32mINFO\\u001b[0m] out[0]: in: 0 (0 MB) out: 0.999001 (0.000559441 MB)\"}"
-<code> この件について高橋さんから2024/1/19 9:09PM (JST) に Mattermost 上でコメントをいただいた。+</code> この件について高橋さんから2024/1/19 9:09PM (JST) に Mattermost 上でコメントをいただいた。<code>
     * https://www.rcnp.osaka-u.ac.jp/mattermost/spadi-alliance/pl/h11f8u91b3fm5rssc1un1guf5y     * https://www.rcnp.osaka-u.ac.jp/mattermost/spadi-alliance/pl/h11f8u91b3fm5rssc1un1guf5y
     * <code>FairMQのコマンドライン引数で     * <code>FairMQのコマンドライン引数で
行 295: 行 294:
 <パネル 4> <パネル 4>
 $ ./start_device.sh FileSink --color false $ ./start_device.sh FileSink --color false
-</code> 結果は以下の画像の感じになる。+</code> 結果は以下の画像の感じになる。おそらく、Metrics plugin の出力がなくなり、Telemetry plugin の出力が残っている?
   * {{:softwares:fluent_bit:nestdaq_fairmq_option_no_color_20240129.png?400|}}   * {{:softwares:fluent_bit:nestdaq_fairmq_option_no_color_20240129.png?400|}}
   * さらに、fluent bit に パイプして、redis に書き込んでみる。<code>   * さらに、fluent bit に パイプして、redis に書き込んでみる。<code>
行 306: 行 305:
 <パネル 4> <パネル 4>
 $ ./start_device.sh FileSink --color false | REDIS_KEY=FileSink fluent-bit -e ./out_redis.so -c ./fluent-bit.conf $ ./start_device.sh FileSink --color false | REDIS_KEY=FileSink fluent-bit -e ./out_redis.so -c ./fluent-bit.conf
-</code>+</code> Redisの結果は以下の感じ。<code>160698) "{\"@tag\":\"stdin.0\",\"@timestamp\":\"2024-01-29T06:51:24.864656566Z\",\"message\":\"{\\\"id\\\":\\\"Scaler-0\\\",\\\"service-name\\\":\\\"Scaler\\\",\\\"process_name\\\":\\\"Scaler\\\",\\\"timestamp\\\":\\\"15:51:24.628999\\\",\\\"file\\\":\\\"Scaler.cxx\\\",\\\"line\\\":\\\"158\\\",\\\"func\\\":\\\"HandleData\\\",\\\"severity\\\":\\\"INFO\\\",\\\"time_t\\\":\\\"1706511084\\\",\\\"log\\\":\\\"tsHeartbeatCounter: 100\\\"}\"}" 
 +160699) "{\"@tag\":\"stdin.0\",\"@timestamp\":\"2024-01-29T06:51:24.864680934Z\"}" 
 +160700) "{\"@tag\":\"stdin.0\",\"@timestamp\":\"2024-01-29T06:51:24.864716753Z\",\"message\":\"{\\\"id\\\":\\\"Scaler-0\\\",\\\"service-name\\\":\\\"Scaler\\\",\\\"process_name\\\":\\\"Scaler\\\",\\\"timestamp\\\":\\\"15:51:24.629088\\\",\\\"file\\\":\\\"Scaler.cxx\\\",\\\"line\\\":\\\"159\\\",\\\"func\\\":\\\"HandleData\\\",\\\"severity\\\":\\\"INFO\\\",\\\"time_t\\\":\\\"1706511084\\\",\\\"log\\\":\\\"tsHeartbeatFlag   : 0\\\"}\"}" 
 +160701) "{\"@tag\":\"stdin.0\",\"@timestamp\":\"2024-01-29T06:51:24.864743743Z\"}"</code>さらに、$HOME/run/fluent-bit.conf で <code> 
 +[SERVICE] 
 +    Flush        1 
 +    Daemon       Off 
 +    Log_Level    debug 
 +    Log_File     /dev/stdout 
 +    Parsers_File parsers.conf 
 + 
 +[INPUT] 
 +    Name stdin 
 +#    Parser plain                                                                                                                                                                                                                            
 + 
 +[OUTPUT] 
 +    Name  stdout 
 +    Match * 
 + 
 +[Output] 
 +    Name redis 
 +    Match * 
 +    UseTLS false 
 +    TLSSkipVerify true 
 +    # if port is ommited, 6379 is used                                                                                                                                                                                                       
 +    Hosts localhost 
 +#    Password                                                                                                                                                                                                                                
 +    DB 4 
 +    Key ${REDIS_KEY} 
 +</code> というように、[INPUT] の Name stdin の Parser plain をコメントアウトし、デフォルトの json パーサーを有効にして、NestDAQ + fluent-bit を走らせると、json フォーマットで出力されたメッセージのみ Redis に書き込まれる。Redis の中身は以下のかんじになる。<code> 
 +571) "{\"@tag\":\"stdin.0\",\"@timestamp\":\"2024-01-29T07:00:46.864559421Z\",\"file\":\"Scaler.cxx\",\"func\":\"HandleData\",\"id\":\"Scaler-0\",\"line\":\"158\",\"log\":\"tsHeartbeatCounter: 995\",\"process_name\":\"Scaler\",\"service-name\":\"Scaler\",\"severity\":\"INFO\",\"time_t\":\"1706511646\",\"timestamp\":\"16:00:46.615054\"}" 
 +572) "{\"@tag\":\"stdin.0\",\"@timestamp\":\"2024-01-29T07:00:47.86408278Z\",\"file\":\"Device.cxx\",\"func\":\"LogSocketRates\",\"id\":\"Scaler-0\",\"line\":\"757\",\"log\":\" in[0]: in: 0.997009 (0.000693918 MB) out: 0 (0 MB)\",\"process_name\":\"Scaler\",\"service-name\":\"Scaler\",\"severity\":\"INFO\",\"time_t\":\"1706511647\",\"timestamp\":\"16:00:47.568216\"}" 
 +573) "{\"@tag\":\"stdin.0\",\"@timestamp\":\"2024-01-29T07:00:47.864251756Z\",\"file\":\"Device.cxx\",\"func\":\"LogSocketRates\",\"id\":\"Scaler-0\",\"line\":\"757\",\"log\":\"out[0]: in: 0 (0 MB) out: 0.997009 (0.000558325 MB)\",\"process_name\":\"Scaler\",\"service-name\":\"Scaler\",\"severity\":\"INFO\",\"time_t\":\"1706511647\",\"timestamp\":\"16:00:47.568961\"}" 
 +574) "{\"@tag\":\"stdin.0\",\"@timestamp\":\"2024-01-29T07:00:47.86440722Z\",\"_attr\":{\"title\":\"Scaler2D\",\"xtitle\":\"\",\"ytitle\":\"\"},\"_stat\":{\"Entries\":0},\"counts\":[[0,2455,0,1496,0,1524,0,1367,0,1328,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,521,0,469,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],\"xbins\":{\"max\":64,\"min\":0},\"ybins\":{\"max\":2,\"min\":0}}" 
 +575) "{\"@tag\":\"stdin.0\",\"@timestamp\":\"2024-01-29T07:00:47.864544819Z\",\"file\":\"Scaler.cxx\",\"func\":\"HandleData\",\"id\":\"Scaler-0\",\"line\":\"158\",\"log\":\"tsHeartbeatCounter: 1000\",\"process_name\":\"Scaler\",\"service-name\":\"Scaler\",\"severity\":\"INFO\",\"time_t\":\"1706511647\",\"timestamp\":\"16:00:47.619254\"}"</code> ちなみに、fluent-bit の出力として標準出力に given time is not in a known format, defaulting to now. というメッセージが出るが、これは、fluent-bit-go-redis-output のプラグインの出力 (もっと言うと、 https://github.com/majst01/fluent-bit-go-redis-output/blob/556919d57c274432e54dcaac5a8c308127fde3b4/out_redis.go の出力) メッセージである。タイムスタンプの型(?)が output.FLBTime にも uint64 にもマッチしないときに出されるようだ。つまり、fluent-bit の入力にタイムスタンプがない場合、このメッセージが出ている?
  
 ==== Troubleshooting ==== ==== Troubleshooting ====
softwares/fluent_bit/fluent_bit_go_redit_output.1706511002.txt.gz · 最終更新: 2024/01/29 15:50 by kobayash
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0