Elastic Stack 7 : Filebeat インストール2019/06/18 |
|
任意のログファイルのデータ収集機能を提供する Filebeat をインストールします。
|
|
| [1] | Filebeat をインストールします。 事前に Elasticsearch リポジトリ設定済みであることが前提です。 |
|
[root@dlp ~]# yum -y install filebeat
|
| [2] | 基本的な設定をして Filebeat を起動します。 |
|
[root@dlp ~]#
vi /etc/filebeat/filebeat.yml # 21行目:収集するファイルを設定 # ログを収集する場合は enabled: true に変更 # デフォルトは以下のように /var/log/*.log ファイルとなっている # 特定のキーワードを含む行/ファイルを対象/除外にする場合はそれぞれコメント解除して設定
- type: log
# Change to true to enable this prospector configuration.
enabled: true
# Paths that should be crawled and fetched. Glob based paths.
paths:
- /var/log/*.log
#- c:\programdata\elasticsearch\logs\*
# Exclude lines. A list of regular expressions to match. It drops the lines thh
at are
# matching any regular expression from the list.
#exclude_lines: ['^DBG']
# Include lines. A list of regular expressions to match. It exports the lines
that are
# matching any regular expression from the list.
#include_lines: ['^ERR', '^WARN']
# Exclude files. A list of regular expressions to match. Filebeat drops the fii
les that
# are matching any regular expression from the list. By default, no files are
dropped.
#exclude_files: ['.gz$']
.....
.....
# 117行目:Kibana を使用する場合はコメント解除して出力先を指定 # Kibana で SSL 有効の場合は証明書に登録したホスト名と合わせる
setup.kibana:
.....
host: "https://dlp.srv.world:5601"
# 148行目:出力先を指定する # デフォルト出力先は以下のように localhost の Elasticsearch # Logstash に出力する場合はコメントアウトして output.logstash 行関連を有効にする output.elasticsearch: # Array of hosts to connect to.l hosts: ["localhost:9200"] ..... ..... #output.logstash: # The Logstash hosts #hosts: ["localhost:5044"]
[root@dlp ~]#
vi /etc/filebeat/filebeat.reference.yml # 15行目:収集する項目を設定
- module: system
# Syslog
syslog:
enabled: true
.....
.....
# Authorization logs
auth:
enabled: true
# 1813行目:Kibana を使用する場合はコメント解除して出力先を指定 # Kibana で SSL 有効の場合は ssl 系設定をコメント解除 # 自己署名の SSL 証明書の場合は ssl.verification_mode を none に要変更 setup.kibana: # Kibana Host # Scheme and port can be left out and will be set to the default (http and 5601) # In case you specify and additional path, the scheme is required: http://localhost:5601/path # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601 host: "dlp.srv.world:5601" # Optional protocol and basic auth credentials. protocol: "https" #username: "elastic" #password: "changeme" # Optional HTTP Path #path: "" # Use SSL settings for HTTPS. Default is true. ssl.enabled: true # Configure SSL verification mode. If `none` is configured, all server hosts # and certificates will be accepted. In this mode, SSL based connections are # susceptible to man-in-the-middle attacks. Use only for testing. Default is # `full`. ssl.verification_mode: none[root@dlp ~]# systemctl start filebeat [root@dlp ~]# systemctl enable filebeat
|
| [3] | データが取り込まれているか確認しておきます。 |
|
# index 一覧 [root@dlp ~]# curl localhost:9200/_cat/indices?v health status index uuid pri rep docs.count docs.deleted store.size pri.store.size green open .kibana_1 OD2lQaCLQFeG7RQbYXigEA 1 0 916 26 655.5kb 655.5kb yellow open test_index u5nanOeOSCmGbSIlrqluZA 1 1 1 0 5.2kb 5.2kb yellow open packetbeat-7.1.1-2019.06.14-000001 azF2ujw4RAeZ9pgdDvRBUg 1 1 3208 0 1.4mb 1.4mb green open .kibana_task_manager yuJ1nGaBSDeoeP6GToztbg 1 0 2 0 45.6kb 45.6kb yellow open sshd_fail-2019.06 Q689hZJTTjG6beQ6XtZsXw 1 1 14 0 86.7kb 86.7kb yellow open metricbeat-7.1.1-2019.06.14-000001 5cFmXcywQVWZTKvPMsZdoQ 1 1 5630 0 1.9mb 1.9mb yellow open filebeat-7.1.1-2019.06.14-000001 sWGv-hPVRuqon6m4ElZYng 1 1 5502 0 851.4kb 851.4kb # indexのドキュメント一覧 [root@dlp ~]# curl localhost:9200/filebeat-7.1.1-2019.06.14-000001/_search?pretty
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 5502,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "filebeat-7.1.1-2019.06.14-000001",
"_type" : "_doc",
"_id" : "enngVGsBrQK6anSSNQxJ",
"_score" : 1.0,
"_source" : {
"@timestamp" : "2019-06-14T07:25:07.568Z",
"agent" : {
"type" : "filebeat",
"ephemeral_id" : "24095da5-98ef-45ac-bd29-0db0f5be521b",
"hostname" : "dlp.srv.world",
"id" : "1f76a08e-342b-4d42-acca-9a342de9ce80",
"version" : "7.1.1"
},
.....
.....
|
| [4] | Kibana を稼働させている場合は、データインポートが可能です。 |
|
[root@dlp ~]# filebeat setup --dashboards Loading dashboards (Kibana must be running and reachable) Loaded dashboards |
|
| Sponsored Link |
|
|