Parsing Values

You can also extract and set values with a pattern_db, like this;
(Note, nxlog uses perl pattern matching syntax if you need to look things up)


<?xml version="1.0" encoding="UTF-8"?>
<patterndb>

  <group>
    <name>ADFS Logs</name>
    <id>1</id>

   <pattern>
      <id>2</id>
      <name>Identify user login fails</name>
      <matchfield>
        <name>EventID</name>
        <type>exact</type>
        <value>111</value>
      </matchfield>

      <matchfield>
        <name>Message</name>
        <type>REGEXP</type>
        <value>LogonUser failed for the '(\S+)'</value>
        <capturedfield>
          <name>ADFSLoginFailUsername</name>
          <type>STRING</type>
        </capturedfield>
      </matchfield>

      <set>
        <field>
          <name>ADFSLoginFail</name>
          <value>failure</value>
          <type>string</type>
        </field>
      </set>
    </pattern>

And a more complex example, where we're matching agains a sting like:

2015-03-03T19:45:03 get_records 58  DailyAddAcct completed (Success) with: 15 Records Processed 0 adds 0 removes 0 modified 15 unchanged 

<?xml version="1.0" encoding="UTF-8"?>
<patterndb>

  <group>
    <name>Bbts Logs</name>
    <id>1</id>
  
    <pattern>
      <id>2</id>
      <name>Get TS Records</name> 
 
      <matchfield>
        <name>raw_event</name>
        <type>REGEXP</type>
        <value>^(\S+) get_record (\S+)\s+(\S+) completed \((\S+)\) with: (\S+) Records Processed (\S+) adds (\S+) removes (\S+) modified (\S+) unchanged</value>
<capturedfield>
          <name>timestamp</name>
          <type>STRING</type>
        </capturedfield>

<capturedfield>
          <name>Transaction_ID</name>
          <type>STRING</type>
        </capturedfield>

<capturedfield>
          <name>Job_Subtype</name>
          <type>STRING</type>
        </capturedfield>

<capturedfield>
          <name>Job_Status</name>
          <type>STRING</type>
        </capturedfield>

<capturedfield>
          <name>Record_Total</name>
          <type>STRING</type>
        </capturedfield>

<capturedfield>
          <name>Record_Add</name>
          <type>STRING</type>
        </capturedfield>

<capturedfield>
          <name>Record_Remove</name>
          <type>STRING</type>
        </capturedfield>

<capturedfield>
          <name>Record_Mod</name>
          <type>STRING</type>
        </capturedfield>

<capturedfield>
          <name>Record_NoChange</name>
          <type>STRING</type>
        </capturedfield>
      </matchfield>

      <set>
        <field>
          <name>Job_Type</name>
          <value>Get_Records</value>
          <type>string</type>
        </field>
      </set>
    </pattern>


  </group>
</patterndb>

 
Comments