トラブルシューティング

iptablesのログが正常に転送されない

事象

転送元(iptablesを動かしている側)で下記のFilebeat設定を行ったが正常なデータがElasticsearchに転送されない。

  • /etc/filebeat/filebeat.yml
output.elasticsearch: hosts: ["10.9.6.193:9200"] indices: - index: "iptables-%{+yyyy.MM.dd}" when.equals: event.module: "iptables"
  • /etc/filebeat/modules.d/iptables.yml`
- module: iptables log: enabled: true var.input: "file" var.paths: - /var/log/syslog

原因(予想を多分に含む)

/var/log/syslogにiptables以外のログが大量に出ていることが動作に影響しているっぽい?

対策

kernファシリティを/var/log/kern.logファイルに別出力するようにし、そちらを参照したらうまくいった。

  • /etc/rsyslog.d/50-default.conf
kern.* -/var/log/kern.log
  • /etc/filebeat/modules.d/iptables.yml`
- module: iptables log: enabled: true var.input: "file" var.paths: - /var/log/kern.log

cluster.max_shards_per_node の設定変更

データが増えてきたときにelasticsearch ver7系のデフォルト1000では足りなくなる時がある。
コマンド例
<設定変更>

# curl -X PUT localhost:9200/_cluster/settings -H "Content-Type: application/json" -d '{ "persistent": { "cluster.max_shards_per_node": "3000" } }' # curl -X PUT localhost:9200/_cluster/settings -H "Content-Type: application/json" -d '{ "persistent": { "cluster.max_shards_per_node": "10000" } }'

<確認>

# curl -XGET localhost:9200/_cluster/allocation/explain?pretty # curl -XGET localhost:9200/_cluster/allocation/explain?pretty | grep -i shard # watch -n0 'curl -s localhost:9200/_cluster/health?pretty | grep "active_shards_percent"'

設定系

iptablesのIndex Template登録

geoip使えたりメッセージ全体を検索可能にしたり・・
elasticsearch_template_iptables
↑このファイルを下記のコマンドで投入する

# curl -H "Content-Type: application/json" -XPUT http://localhost:9200/_template/iptables?pretty -d @./elasticsearch_template_iptables