まれによく使う設定や、ハマるパターンなどを適宜追加していきます。
よく使うElasticsearchの操作
- 全indexの取得
curl -XGET http://localhost:9200/_aliases?pretty=1
- typeを指定して取得
curl -XGET 'http://localhost:9200/_all/my_type/_search?pretty'
- 全indexの削除
curl -XDELETE 'http://localhost:9200/_all'
- typeを指定して削除
curl -XDELETE 'http://localhost:9200/_all/my_type/'
Filebeat[6.4]Windows版
- 転送完了しているログファイルを、位置から再度送りたい
-
C:/ProgramData/filebeat/(registry|registry.old)
が、ファイル名と転送完了位置を記録しているファイル。 - これを消すことで、全てのログを再送できる
-
logファイルの再送
C:/ProgramData/Filebeat> sc stop filebeat
C:/ProgramData/Filebeat> del registry registry.old
C:/ProgramData/Filebeat> sc start filebeat
Logstash[6.4]の設定
- logstash.yml に直接input - filter - output を書いちゃダメだ!
- conf.d/*.yml でpipeline毎のファイルを置く
- input - filter - output の pipelineを書く
- pipeline毎に、workerなどを設定可能
- piplines.ymlでqueue.type等が制御できる
- 個別に、workerやqueue.page_capacityなどが設定できる
- 大量のデータを受け付けるときには、これを使わないと、場合によってはES側がソケット不足等に陥るようだ。
- YES! Multiple Pipeline!
- conf.d/*.yml でpipeline毎のファイルを置く
- Multiple Pipelineが動かない?
- logstash.confで、設定が有効ではない。
-
path.config: /etc/logstash/conf.d/*.yml
が設定されていないと、conf.d/ 以下に配置したconfは読み込まれないらしい
-
- logstash.confで、設定が有効ではない。
- なんだかパフォーマンスで問題が出ている
- port:9200のソケットが枯渇とか thread溢れとかで、エラー番号 429が出ている(
retrying failed action with response code: 429
とか)- Logstashのパイプライン限界かES側の処理が追いついていない
- Logstashのパイプライン限界は、上記のようにmultiple pipelineを利用すれば良さそう。worker等を調整しよう。
- ES側は、、クラスタ化するとか analyze:falseにするとかで、入力後のコストを下げるしか無さそう。
- port:9200のソケットが枯渇とか thread溢れとかで、エラー番号 429が出ている(
- UDP/514(syslog)が起動できない
-
UDP listener died {:exception=>#<Errno::EACCES: Permission denied - bind(2) for "0.0.0.0" port 514>, :backtrace=>[...
が出る。 - 特権ポート(1024以下)のポートを非rootユーザはbindできないのは、LIDSで制限しているっぽい
- 回避策は以下の2つが一般的
- サービスをrootで起動する = logstashをrootで起動
- パッケージで入れた場合は、起動スクリプトに起動するユーザが書いてあるので、root変更する
- Ubuntuの場合、
/etc/systemd/system/logstash.service
のUser=logstash
をroot変える。
- iptablesでポートフォワードする = 514/UDPを別ポートに転送してそれを受ける
- ぐぐると出てくる。514を5514に転送し、logstashでは5514を見る、等。
- サービスをrootで起動する = logstashをrootで起動
-
winlogbeatの設定
- 直接Elasticsearchに入力する場合で、index名を変更する
- 以下のように
winlogbeat.yml
のoutput.elasticsearch:
項目を変更する- index名で、
-1-
等のバージョン表記らしき数字がないと、適切にindex templateを適用してくれないようだ。-
https://www.elastic.co/guide/en/beats/winlogbeat/current/winlogbeat-template.html では、
The value that you specify should include the root name of the index plus version and date information.
と言っているので、バージョン情報(デフォルトはwinlogbeat-6.4.0など)が必要みたい。いらんじゃろ? - 適切に適用してくれない = shardが5になってたりする。
-
https://www.elastic.co/guide/en/beats/winlogbeat/current/winlogbeat-template.html では、
- setup.template.nameの名前で、テンプレートが作られる。多分、いつもの winlogbeat-6.4.0 と同じ内容のはず。
- analyze: false な設定が入っているので、ES側の負荷を多少は下げるはず。
- index名で、
- 以下のように
#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
# Array of hosts to connect to.
hosts: ["http://your-es-IP:9200"]
# Optional protocol and basic auth credentials.
#protocol: "https"
index: "eventlog-1-%{+yyyy.MM.w}"
setup.template.name: "template_evetlog-1"
setup.template.pattern: "eventlog-1-*"
Elasticsearch[6.4]
- 推奨は、メモリの半分 or 32GB以下。
- 最高でも32GBなので、筐体には64GB異常割り当てる必要は無さそう。
- 32GB搭載で32GB割り当てると、OS等の動作用が減る。パフォーマンスに影響が出るので、16GB割当から調整をしてみるのが良さそう。