fluentd 設定

single_value

fluent-plugin-file-alternative

https://github.com/tagomoris/fluent-plugin-file-alternative

td-agent 1.1.20 で out_file が format 指定可能になった

single_value
fluent-plugin-file-alternative の代わりに使えるようです。in_tail で format none として読みだしたデータを書き出すのに適しています。ログファイルの1行1行をそのまま集めたい場合ですね

  type tail
  path /path/to/log.%Y%m%d
  format none
  #message_key message
  tag test.access

  type file
  file /path/to/out_file
  format single_value
  #message_key message

key の名前はどちらもデフォルトが message で message_key パラメータで指定可能です。
fluentd / td-agent がいろいろ便利になってた | 1Q77

<filter foo.bar>
  @type record_transformer
  <record>
    message yay, ${record["message"]}
  </record>
</filter>
An input like
{"message":"hello world!"}

https://docs.fluentd.org/filter/record_transformer

Fluentdで集めたログを監視するときに気をつけたいFluentdの設定 | DevelopersIO

https://docs.fluentd.org/output/file

プレースホルダ

Fluentd v0.14 では fluent-plugin-forest が不要な話 - Usual Software Engineer

https://medium.com/@ch1aki/fluentd-v0-14-9-プレースホルダー-b0675ea8b7fe

バッファ

FluentdでバッファつきOutputPluginを使うときのデフォルト値 - たごもりすメモ

fluentdのbuffer周りで注意すべき点 - Qiita

Fluentd v0.14 で buffer chunk が flush されるまでの動きをまとめてみた - reboooot․net

mysqldump 8 5.7 error

エラーメッセージ
mysqldump コマンドでMySQL上のデータのバックアップを取ろうとしたとき、下記のようなエラーが出た。

mysqldump: Couldn't execute 'SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"') FROM information_schema.COLUMN_STATISTICS WHERE SCHEMA_NAME = '$db_name' AND TABLE_NAME = '$table_name';': Unknown table 'COLUMN_STATISTICS' in information_schema (1109)
原因
MySQL 8以降に付属するmysqldumpでそれ以前のMySQL 5.7とかのサーバに対してダンプを実行したらこの問題が起こるらしい。
https://blog.pinkumohikan.com/entry/mysqldump-disable-column-statistics

fluent-bit

fluent-bit

https://fluentbit.io
https://fluentbit.io/announcements/ Release Notes
https://github.com/fluent/fluent-bit

設定

レコードにホスト名を追加

[FILTER]
    Name record_modifier
    Match *
    Record hostname ${HOSTNAME}

https://docs.fluentbit.io/manual/pipeline/filters/record-modifier

fluentd


  @type record_transformer
  
    hostname ${hostname}
  

https://www.fluentd.org/guides/recipes/apache-add-hostname

fluentd

正規表現 グループ コロン

(?:~) パターンのグループ
例)A(?:AB|CD) → AAB、ACDにマッチ
正規表現サンプル集

The better solution:

location ~ ^/phpmyadmin(?:/(.*))?$ {
    alias /home/phpmyadmin/$1;
}

Ensure that server has permissions to /home/phpmyadmin first.

It's all about regular expressions.

First of all, the ^ char means that you want to match from beginning of string and not somewhere in the middle. The $ at the end means matching to the end of the string.

The (?:) means non-capturing group - we don't want it in the capturing results, but we want to simple group some chars. We group it like this, because we want the / char to be a nonsignificant part of the child path, and not a significant part of the parent path.

How can I create a location in nginx that works with AND without a trailing slash? - Server Fault

https://regexr.com/

mod_dosdetector

mod_dosdetector-fork

https://github.com/tkyk/mod_dosdetector-fork
2016

リバースプロキシ下で使用できるようになった
Apache 2.4に標準添付されているremoteipモジュールと組み合わせることで、直接IPがとれないバックエンドでも、正しく動作します。
mod_dosdetector-fork バージョン1.1.0(Apache 2.4対応版)をリリースしました - Qiita

remoteipとの組み合わせ

nginx location

正規表現("~", "~*")の条件の評価を実施
正規表現の条件を設定ファイルに定義した順番に評価する。一致したら、そこで評価を終了して、そのlocationディレクティブを適応する。

nginx連載5回目: nginxの設定、その3 - locationディレクティブ - インフラエンジニアway - Powered by HEARTBEATS

nginx.conf の location の優先順位を正しく理解する - 無印吉澤