LoginSignup
1
2

More than 3 years have passed since last update.

WindowsのイベントログをWinlogbeat経由でElastic Cloudに取り込み、Kibanaで確認する方法

Posted at

はじめに

WindowsのイベントログをWinlogbeat経由でElastic Cloudに取り込み、Kibanaで確認する方法をまとめました。

手順

1. Elastic Cloudの準備

今回は無料トライアルを使ってみたいと思います。
以下のページに移動してください。

次にメールアドレスを入力して、[トライアルを始める]をクリックしてください。

image.png

しばらくするとメールが届きますので、メール本文中の[Verify and Accept]をクリックしてください。
以下のページが表示されたら適当なパスワードを入力して[Set password and login]をクリックしてください。

image.png

以下のページが表示されたら[Start your free trial]をクリックしてください。

image.png

名前の入力、Cloud Platformの選択、リージョンの選択をしたのち、[Create deployment]をクリックしてください。

image.png
image.png

UsernameとPasswordが表示されますのでメモしてください。
次に[your deployments]をクリックしてください。

image.png

Cloud IDの内容をメモしてください。
Winlogbeatの設定時に必要になります。

image.png

1つ前の画面に戻り画面右の[Launch Kibana]をクリックしてください。

image.png

ログインページが表示されたら先ほどメモしたUsernameとPasswordを入力し[Log in]をクリックしてください。

image.png

[Explore on my own]をクリックしてください。

image.png

これでElastic Cloudの準備が完了です。

2. Winlogbeatの準備

ダウンロード

以下からダウンロードします。
https://www.elastic.co/jp/downloads/beats/winlogbeat

展開

C:\Program Files に展開し、ディレクトリ名をwinlogbeat-<version>からWinlogbeatに変更します。

インストール

管理者権限でPowershellを起動し、以下のコマンドを実行します。

cd 'C:\Program Files\Winlogbeat'
.\install-service-winlogbeat.ps1

以下の結果が出力されればOKです。

Status   Name               DisplayName
------   ----               -----------
Stopped  winlogbeat         winlogbeat

3. Winlogbeatの設定

C:\Program Files\Winlogbeat\winlogbeat.ymlを開き設定をします。

取得するログを選ぶ

以下で取得するログ種別を選びます。
私の場合、セキュリティイベントログだけを取得したいのでname: Securityの項目以外をコメントアウトしました。

winlogbeat.event_logs:
  # - name: Application
  #   ignore_older: 72h

  # - name: System

  - name: Security
    processors:
      - script:
          lang: javascript
          id: security
          file: ${path.home}/module/security/config/winlogbeat-security.js

  # - name: Microsoft-Windows-Sysmon/Operational
  #   processors:
  #     - script:
  #         lang: javascript
  #         id: sysmon
  #         file: ${path.home}/module/sysmon/config/winlogbeat-sysmon.js

アウトプットの指定

今回はWinlogbeatからElastic Cloudに出力するので、まずElasticsearch outputをコメントアウトします。

#-------------------------- Elasticsearch output ------------------------------
# output.elasticsearch:
  # Array of hosts to connect to.
  # hosts: ["localhost:9200"]

次にElastic Cloudを指定します。
cloud.idにはCloud IDを、cloud.authにはユーザ名とパスワードをユーザ名:パスワードの形式で記入してください。

#============================= Elastic Cloud ==================================

# These settings simplify using Winlogbeat with the Elastic Cloud (https://cloud.elastic.co/).

# The cloud.id setting overwrites the `output.elasticsearch.hosts` and
# `setup.kibana.host` options.
# You can find the `cloud.id` in the Elastic Cloud web UI.
cloud.id: "test:********"

# The cloud.auth setting overwrites the `output.elasticsearch.username` and
# `output.elasticsearch.password` settings. The format is `<user>:<pass>`.
cloud.auth: "elastic:********"

winlogbeat.ymlのテスト

以下のコマンドを実行してください。
実行結果の最後にConfig OKと表示されていれば問題ありません。

.\winlogbeat.exe test config -c .\winlogbeat.yml -e

4. Winlogbeatの起動

管理者権限でPowershellを起動し、以下のコマンドを実行してください。

Start-Service winlogbeat

ちなみに停止は以下のコマンドでできます。

Stop-Service winlogbeat

5. ログ可視化

インデックスパターン作成

Kibanaでログ検索・可視化をするためにはインデックスパターンというものを作成する必要があります。

Kibanaの画面で[Discover]のアイコンをクリックしてください。
(もしくはManagement(左下の歯車のアイコン) -> Index Patterns -> Create index pattern をクリックしてください)

image.png

以下は現在存在するインデックスの一覧です。(システム的なインデックスは除く)
Winlogbeatのログはwinlogbeat-7.6.2-2020.04.02-000001というような形式でElasticsearchに取り込まれます。

image.png

winlogbeat-*と入力して[Next step]をクリックしてください。

image.png

時系列で使用するフィールドを選択します。
@timestampを選択して[Create index pattern]をクリックしてください。

image.png

これでインデックスパターンが作成されました。

6. Kibanaでログ確認

Kibanaの画面で[Discover]のアイコンをクリックしてください。
以下のようにWindowsのイベントログが表示されます。

image.png

関連

WindowsのログをWinlogbeatとLogstash経由でBigQueryに取り込む
https://qiita.com/hanzawak/items/bb18a7b88c92bd488f33

Kibanaでログ検索・可視化をするために最低限必要な知識と技
https://qiita.com/hanzawak/items/c9a31f61cbec641d7140

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2