0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Windowsイベントログを収集し、Fluentdを利用して別システムへ転送する

Last updated at Posted at 2024-12-24

概要

Windowsイベントログを収集する環境を作成し、そのログをさらに別システムへ転送するための手順を記載します。

環境

本手順で取り扱う内容は、次の環境にて確認しています。

  • Windows Client
    マシン:Amazon EC2
    OS:Windows Server 2022

  • Windows Event Collector & Fluentd Server
    マシン:Amazon EC2
    OS:Windows Server 2022

構成図は次のようになります。
image.png

Windows ClientはWindows Event Collectorと呼ばれるログ収集マシンにイベントログを転送します。
そしてWindows Event Collectorと同じマシン上にFluentdを導入し、収集したイベントログを別システムへ転送する仕組みです。

また、Windows Clientは通常、複数台存在するはずですが、本記事では話をシンプルにするために1台構成としています。

手順

ログ収集環境セットアップ

ログ収集環境をセットアップするための手順を記載します。

Windows ClientからWindows Event Collectorへのログ転送については、Windows Event Fowardingという仕組みによって実現します。

なお、Windows ClientはADサーバによって操作するため、前提としてADサーバが存在し、Windows Clientがドメイン参加していることが作業条件となります。AD等のセットアップについてはこちらの手順が参考になります。

通信設定

Windows Event Collectorのセキュリティグループのインバウンドルールにて、Windows ClientからのTCP 5985 Port接続を許可して下さい。

Windows Client設定

本手順はADサーバにて実施して下さい。

GPO(Group Policy Management)の画面を開きます。
image.png

Forest > Domains > Group Policy Objectを押下して下さい。
Default Domain Policyを右クリックしてeditします。
image.png

下記の画面に遷移するはずです。
image.png

Computer Configuration > Policies > Administrative Templates > Windows Components > Event Forwardingを押下して下さい。
Configure target Subscription Managerを右クリックしてeditします。
image.png

下記の画面に遷移するはずです。
Not ConfiguredEnabledに変更して下さい。
image.png

また、Optionsの欄のShowを押下して下さい。
Valueに次の値を入力して下さい。

"Server=http://`<Windows Event CollectorのFQDN>`:5985/wsman/SubscriptionManager/WEC,Refresh=10"

※Windows Event CollectorのFQDNとは、EC2のDNS名ではなく、ADドメイン(例:EC2AMAZ-XXXXXXX.test.jp)のことを指します。

入力が完了したら、cmdにて次のコマンドを実行して下さい。
GPOの設定が反映されます。

> gpupdate /force

Windows Event Collector設定

本手順はWindows Event Collectorマシンにて実施して下さい。

Event Viewerを起動して下さい。
image.png

Subscriptionsを右クリックし、Create Subscriptionを選択します。
image.png

Event Collectorのサービス再起動設定が求められるため、Yesを選択して下さい。
image.png

表示されたSubscription Propertiesで次の情報を入力します。

  • Subscription Name:任意の名前
  • Subscription Type and source computer:source computer initiatedを選択し、Computer Groupsの選択から、Add Domain Computers…を押下し、Windows Clientのコンピューター オブジェクト(例:EC2AMAZ-XXXXXXX)を指定して下さい。
  • Events to collect:必要に応じて、次のように収集対象のイベントをフィルターで指定ください。
    image.png

OKを押下して下さい。
動作確認として、Event ViewerForwarding Eventsにて、次のようにログが記録されることを確認してください。
image.png

以上でログ収集環境のセットアップは完了です。

Fluentdセットアップ及び、別システムへの転送設定

Fluentdインストール

本手順はWindows Event Collectorマシンにて実施して下さい。

次のページにアクセスし、インストールしたいバージョンのmsiファイルをダウンロードして下さい。
https://td-agent-package-browser.herokuapp.com/

ダウンロードしたインストーラをWindows Event Collectorマシンにて実行してFluentdをインストールしてください。

Config設定

C:/opt/fluent/etc/fluent/fluentd.confファイルを編集します。
次のfluentd.confはサンプルになります。
各パラメータの詳細が知りたい場合は、ドキュメントを参照して下さい。
Windows eventlog plugin
Http output plugin

<source>
  @type windows_eventlog2
  @id windows_eventlog2
  channels application,system,security
  read_existing_events false
  tag winevt.raw
  rate_limit 200
  <storage>
    @type local
    persistent true
    path C:\opt\fluent\winlog.json
  </storage>
</source>

<match winevt.raw>
  @type http
  endpoint <YOUR-ENDPOINT>
  headers "Authorization: Bearer <YOUR-ACCESSTOKEN>"
  content_type application/json
  <buffer>
    flush_interval 10s
  </buffer>
</match>

編集が完了したら、
WindowsサービスとしてFluentdを起動して下さい。
また、自動起動の設定がデフォルトでは無効となっているため、有効化して下さい。

動作確認

転送先システムにて、ログが受信できていることを確認して下さい。

参考

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?