<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to extract from multiline events using regular expressions with variables? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-multiline-events-using-regular-expressions/m-p/485642#M135871</link>
    <description>&lt;P&gt;try this format&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| rex field=key0 "blah (?&amp;lt;value0&amp;gt;[^/s]+)"  | rex field=key1 "(?&amp;lt;value1&amp;gt;[^/s]+)"  | rex field=key3 "(?&amp;lt;value2&amp;gt;[^/s]+)"&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Sep 2019 15:00:20 GMT</pubDate>
    <dc:creator>Anantha123</dc:creator>
    <dc:date>2019-09-24T15:00:20Z</dc:date>
    <item>
      <title>How to extract from multiline events using regular expressions with variables?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-multiline-events-using-regular-expressions/m-p/485640#M135869</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a rather large multiline event which I am trying to extract data from. The problem is that the format is along the lines of:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;key0 = "bob"
key1 = "foo"
key2 = "bar"
bob = blah $value0 blah
foo = $value1 blah
bar = $value2 blah blah
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It's all rather annoyingly unstructured and arbitrary, so in order to find the values, I have to first extract the key1, key2 and key3 values, to know where to look for the values. I do this with rex, and it goes well. Then I go searching through the text for the values, again using regex.&lt;/P&gt;

&lt;P&gt;The problem is that I somehow have to feed the results from the first search into the subsequent regex searches, and at least REX does not seem to like it if I type 'rex field=_raw "somethingsomething" + $key1 + "something" '&lt;BR /&gt;
Apparently it's static text only, no variables welcome.&lt;BR /&gt;
I did play around with the replace function in eval, but it does not seem to want to look beyond a single line.&lt;/P&gt;

&lt;P&gt;Any ideas how I can solve this?&lt;/P&gt;

&lt;P&gt;Best regards,&lt;/P&gt;

&lt;P&gt;Arild&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 14:30:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-multiline-events-using-regular-expressions/m-p/485640#M135869</guid>
      <dc:creator>arisat</dc:creator>
      <dc:date>2019-09-24T14:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract from multiline events using regular expressions with variables?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-multiline-events-using-regular-expressions/m-p/485641#M135870</link>
      <description>&lt;P&gt;Can you please add a little more detail? Do you have 1 large multi-line event that has both the initial search value and then other text near that value? Are there always exactly 3 "key" values?&lt;/P&gt;

&lt;P&gt;A couple real (sanitized) examples would help a lot.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 14:52:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-multiline-events-using-regular-expressions/m-p/485641#M135870</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2019-09-24T14:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract from multiline events using regular expressions with variables?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-multiline-events-using-regular-expressions/m-p/485642#M135871</link>
      <description>&lt;P&gt;try this format&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| rex field=key0 "blah (?&amp;lt;value0&amp;gt;[^/s]+)"  | rex field=key1 "(?&amp;lt;value1&amp;gt;[^/s]+)"  | rex field=key3 "(?&amp;lt;value2&amp;gt;[^/s]+)"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 15:00:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-multiline-events-using-regular-expressions/m-p/485642#M135871</guid>
      <dc:creator>Anantha123</dc:creator>
      <dc:date>2019-09-24T15:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract from multiline events using regular expressions with variables?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-multiline-events-using-regular-expressions/m-p/485643#M135872</link>
      <description>&lt;P&gt;Sure. I have a few pretty huge multi-line events, and it contains both the initial and subsequent search values. It's an SNMP file, so there might be good techniques for reading this that I am unaware of.&lt;/P&gt;

&lt;P&gt;Here's a sanitized and reduced (for clarity) example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.1.3.6.1.2.1.2.2.1.2.10044 = STRING: "FastEthernet0/12"
.1.3.6.1.2.1.2.2.1.2.10045 = STRING: "FastEthernet0/13"
.1.3.6.1.2.1.2.2.1.2.10046 = STRING: "FastEthernet0/14"
.1.3.6.1.2.1.2.2.1.2.10047 = STRING: "FastEthernet0/15"
.1.3.6.1.2.1.2.2.1.2.10048 = STRING: "FastEthernet0/16"
.1.3.6.1.2.1.2.2.1.2.10101 = STRING: "GigabitEthernet0/1"
.1.3.6.1.2.1.2.2.1.2.10102 = STRING: "GigabitEthernet0/2"
.1.3.6.1.2.1.2.2.1.2.10501 = STRING: "Null0"
[...]
.1.3.6.1.4.1.9.9.23.1.2.1.1.3.10101.1 = INTEGER: 1
.1.3.6.1.4.1.9.9.23.1.2.1.1.4.10101.1 = STRING: "
.1.3.6.1.4.1.9.9.23.1.2.1.1.5.10101.1 = STRING: "Cisco IOS Software"
.1.3.6.1.4.1.9.9.23.1.2.1.1.6.10101.1 = STRING: "cisco-switch-01.example.com"
.1.3.6.1.4.1.9.9.23.1.2.1.1.7.10101.1 = STRING: "GigabitEthernet0/3"
.1.3.6.1.4.1.9.9.23.1.2.1.1.8.10101.1 = STRING: "cisco WS-C2950D"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So, in this case, I can see from the lower section that this switch is connected to another switch called "cisco-switch-01.example.com". And the OID string tells me that the "reference" is "10101". So what I want to do is go back to the event and search for the ".1.3.6.1.2.1.2.2.1.2.10101"-string because I have found "10101". But I am struggling to do just that.&lt;/P&gt;

&lt;P&gt;Is there a way to do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw ".1.3.6.1.2.1.2.2.1.2." + myReference  + ".*STRING: \"(?&amp;lt;myInterface&amp;gt;.*\""
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or something similar?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 07:15:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-from-multiline-events-using-regular-expressions/m-p/485643#M135872</guid>
      <dc:creator>arisat</dc:creator>
      <dc:date>2019-09-25T07:15:35Z</dc:date>
    </item>
  </channel>
</rss>

