正規表現を使用して列を選択するのをやめる(wazuhデコーダで)

正規表現を使用して列を選択するのをやめる(wazuhデコーダで)

このログがありますが、いくつかの列を選択する方法がわかりません。

04.07.2021 12:11:31.801 [25760] info  MainForm  -  Database(s) loaded: CA_2021,beforetest,FL_2,FL_Jan_2021,jhon,DC_City_Jan_2021,Statetest,Benchmark_2021

使っ(\d\d\d\d) (\d+:\d+:\d+)て選べました

2021 12:11:31

私が選ぶのに誰が助けることができますか?

2021 12:11:31 [25760] info FL_Jan_2021 DC_City_Jan_2021 Benchmark_2021

https://documentation.wazuh.com/current/user-manual/ruleset/ruleset-xml-syntax/regex.html

ベストアンサー1

次のカスタムデコーダを使用してすべてのフィールドを抽出できます。

<decoder name="log1">
  <prematch>^\d\d.\d\d.\d\d\d\d \d\d:\d\d:\d\d.\d\d\d [\d+]\s+\w+\s+\w+\s+- </prematch>
  <regex>^(\d\d.\d\d.\d\d\d\d \d\d:\d\d:\d\d.\d\d\d) [(\d+)]\s+(\w+)\s+(\w+)\s+-\s+(\.+):\s+(\S+),(\S+),(\S+),(\S+),(\S+),(\S+),(\S+),(\S+)</regex>
  <order>decoded.date,decoded.pid,decoded.type,decoded.source,decoded.action,field1,field2,field3,field4,field5,field6,field7,field8</order>
</decoder>

上記のフィールドはそれぞれ、、、decoded.dateおよびdecoded.piddecoded.type抽出されますfield4。他のフィールドを抽出したくない場合は、ラベルの角かっことラベルの名前を削除してください。field6field8<regex><order>

wazuh-logtestこのデコーダを設定した後、ユーティリティを介してログを実行した結果は/var/ossec/etc/decoders/local_decoders.xml次のとおりです。

**Phase 1: Completed pre-decoding.
    full event: '14.07.2021 12:11:31.801 [25760] info  MainForm  -  Database(s) loaded: CA_2021,beforetest,FL_2,FL_Jan_2021,jhon,DC_City_Jan_2021,Statetest,Benchmark_2021'

**Phase 2: Completed decoding.
    name: 'log1'
    decoded.action: ' Database(s) loaded'
    decoded.date: '14.07.2021 12:11:31.801'
    decoded.pid: '25760'
    decoded.source: 'MainForm'
    decoded.type: 'info'
    field1: 'CA_2021'
    field2: 'beforetest'
    field3: 'FL_2'
    field4: 'FL_Jan_2021'
    field5: 'jhon'
    field6: 'DC_City_Jan_2021'
    field7: 'Statetest'
    field8: 'Benchmark_2021'

おすすめ記事