<?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: REGEX Extraction (same log format, different fields in DNS data) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279449#M84417</link>
    <description>&lt;P&gt;I attempted this extraction, but it didn't match anything my friend. I'm using RegExr as well, and it doesn't match for either section. &lt;/P&gt;</description>
    <pubDate>Fri, 03 Jun 2016 15:44:14 GMT</pubDate>
    <dc:creator>tmarlette</dc:creator>
    <dc:date>2016-06-03T15:44:14Z</dc:date>
    <item>
      <title>REGEX Extraction (same log format, different fields in DNS data)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279442#M84410</link>
      <description>&lt;P&gt;I am attempting to extract 2 fields, that are structured the same in an event, however represent 2 actions. one represents a query, the other a response for DNS data. &lt;/P&gt;

&lt;P&gt;Here is a sample event:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    QUESTION SECTION:
        Offset = 0x000c, RR count = 0
        Name      ".www.couponcabin.com.distil.us."
          QTYPE   A .
          QCLASS  1
        ANSWER SECTION:
        Offset = 0x002f, RR count = 0
        Name      ".www.couponcabin.com.DISTIL[C027].us."
          TYPE   CNAME  .
          CLASS  1
          TTL    34
          DLEN   9
          DATA   .scotch[C020].distil.us.
        Offset = 0x005f, RR count = 1
        Name      ".scotch[C043].DISTIL[C027].us."
          TYPE   CNAME  .
          CLASS  1
          TTL    21
          DLEN   5
          DATA   .us[C056].scotch[C020].distil.us.
        Offset = 0x0077, RR count = 2
        Name      ".us[C05F].scotch[C043].DISTIL[C027].us."
          TYPE   CNAME  .
          CLASS  1
          TTL    51
          DLEN   27
          DATA   .shard1.premium.newjersey[C020].distil.us.
        Offset = 0x00a1, RR count = 3
        Name      ".shard1.premium.newjersey[C043].DISTIL[C027].us."
          TYPE   A  .
          CLASS  1
          TTL    86
          DLEN   4
          DATA   10.10.10.10
        AUTHORITY SECTION:
          empty
        ADDITIONAL SECTION:
        Offset = 0x00ca, RR count = 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Notice that there is a 'QUESTION SECTION' and an 'ANSWER SECTION', both of which have the value 'Name ...'&lt;/P&gt;

&lt;P&gt;I am attempting to extract the QUESTION SECTION Name value as the field 'query', and the ANSWER SECTION Name values as the field 'answer'. I know how to make an mv field, I just need the extractions themselves. &lt;/P&gt;

&lt;P&gt;Here is what I currently have &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EXTRACT-qa = Name\s+(?&amp;lt;query&amp;gt;\"[^\"]+\")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I use the MV_ADD transform to make this field a multivalue field, however this extracts ALL of the matches, not separating the 'query' field from the 'answers' fields. &lt;/P&gt;

&lt;P&gt;Thank you for any help you can provide!&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2016 20:31:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279442#M84410</guid>
      <dc:creator>tmarlette</dc:creator>
      <dc:date>2016-06-02T20:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: REGEX Extraction (same log format, different fields in DNS data)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279443#M84411</link>
      <description>&lt;P&gt;If there always a single QUESTION SECTION followed by multiple ANSWER SECTIONs?  If so, you could take the first value of the multivalue field as 'query' and the remainder as 'answer'.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2016 20:39:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279443#M84411</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-06-02T20:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: REGEX Extraction (same log format, different fields in DNS data)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279444#M84412</link>
      <description>&lt;P&gt;are you talking about using a | stats first() function of some kind? &lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2016 21:17:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279444#M84412</guid>
      <dc:creator>tmarlette</dc:creator>
      <dc:date>2016-06-02T21:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: REGEX Extraction (same log format, different fields in DNS data)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279445#M84413</link>
      <description>&lt;P&gt;You could break it up into two regexes. Like this (REGEX NOT TESTED)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EXTRACT-q = QUESTION.*Name\s+(?&amp;lt;query&amp;gt;\"[^\"]+\")
EXTRACT-ans = ANSWER.*Name\s+(?&amp;lt;query&amp;gt;\"[^\"]+\") 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and have MV_ADD for the ans and not q&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2016 21:29:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279445#M84413</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-06-02T21:29:58Z</dc:date>
    </item>
    <item>
      <title>Re: REGEX Extraction (same log format, different fields in DNS data)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279446#M84414</link>
      <description>&lt;P&gt;Here is a search-bar solution; you should be able to convert it to a conf-file solution:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "(?s)^[\r\n]*QUESTION\s+SECTION:(?&amp;lt;QUESTION_SECTION&amp;gt;.*?)[\r\n]*ANSWER\s+SECTION:(?&amp;lt;ANSWER_SECTION&amp;gt;.*?)[\r\n]*(?:AUTHORITY\s+SECTION:(?&amp;lt;AUTHORITY_SECTION&amp;gt;.*?)[\r\n]*)(?:ADDITIONAL\s+SECTION:(?&amp;lt;ADDITIONAL_SECTION&amp;gt;.*?)[\r\n]*)?$"
| rex max_match=99 field = QUESTION_SECTION "(?s)[\r\n]+Name\s+(?&amp;lt;query&amp;gt;[^\r\n]+)"
| rex max_match=99 field = ANSWER_SECTION "(?s)[\r\n]+Name\s+(?&amp;lt;answer&amp;gt;[^\r\n]+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Jun 2016 22:05:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279446#M84414</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-06-02T22:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: REGEX Extraction (same log format, different fields in DNS data)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279447#M84415</link>
      <description>&lt;P&gt;Just a simple &lt;CODE&gt;eval query=mvindex(foo, 0)&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2016 12:01:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279447#M84415</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-06-03T12:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: REGEX Extraction (same log format, different fields in DNS data)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279448#M84416</link>
      <description>&lt;P&gt;When I use the 'answer' extraction you have here, the REGEX match stops at the end of the line. Is there a way to make it span multiple lines?  I tried using [^?N] but that doesn't work either. &lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2016 15:31:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279448#M84416</guid>
      <dc:creator>tmarlette</dc:creator>
      <dc:date>2016-06-03T15:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: REGEX Extraction (same log format, different fields in DNS data)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279449#M84417</link>
      <description>&lt;P&gt;I attempted this extraction, but it didn't match anything my friend. I'm using RegExr as well, and it doesn't match for either section. &lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2016 15:44:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279449#M84417</guid>
      <dc:creator>tmarlette</dc:creator>
      <dc:date>2016-06-03T15:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: REGEX Extraction (same log format, different fields in DNS data)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279450#M84418</link>
      <description>&lt;P&gt;OK, i'm working on this, but I can't seem to put a REGEX in transforms.conf that looks through a field. Do you happen to know a way woodcock? &lt;/P&gt;

&lt;P&gt;I have the 'answer_section' field extracted through props.conf. How Do I tell Splunk to search through 'answer_section' for another extraction? &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:53:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279450#M84418</guid>
      <dc:creator>tmarlette</dc:creator>
      <dc:date>2020-09-29T09:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: REGEX Extraction (same log format, different fields in DNS data)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279451#M84419</link>
      <description>&lt;P&gt;You need to activate multi-line mode matching for the regex by specifying (?m) at the start. Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?m)ANSWER.*Name\s+(?&amp;lt;query&amp;gt;\"[^\"]+\")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Jun 2016 18:17:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279451#M84419</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-06-03T18:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: REGEX Extraction (same log format, different fields in DNS data)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279452#M84420</link>
      <description>&lt;P&gt;There is an attribute called SOURCE_KEY in transforms.conf but it only takes indexed fields (your answer_section field is search time field extraction, so you can use it). You may be able to use field _raw (default SOURCE_KEY value), by merging the regex for your answer_section field extraction and these new field extractions.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:53:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279452#M84420</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-29T09:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: REGEX Extraction (same log format, different fields in DNS data)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279453#M84421</link>
      <description>&lt;P&gt;Negative, this doesn't work my friend. It doesn't even capture the first 'Name' line. Thank you! &lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2016 19:36:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279453#M84421</guid>
      <dc:creator>tmarlette</dc:creator>
      <dc:date>2016-06-03T19:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: REGEX Extraction (same log format, different fields in DNS data)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279454#M84422</link>
      <description>&lt;P&gt;Alrighty, this is what I have now for this. &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;props.conf&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;PRE&gt;&lt;CODE&gt; [myDNS]
EXTRACT-ans_sec = ANSWER\sSECTION:(?&amp;lt;answer_section&amp;gt;[^*]+)AUTHORITY
REPORT-fields = answer_section_mv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;transforms.conf&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;PRE&gt;&lt;CODE&gt;[answer_section_mv]
REGEX = Name\s+\"(?&amp;lt;answer&amp;gt;[^\"]+)\"
MV_ADD = true
SOURCE_KEY = field:answer_section
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Naturally, the 'answer' field is not being extracted. I'm not sure how to combine the REGEX for the answer_section and the answer fields. &lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2016 19:39:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279454#M84422</guid>
      <dc:creator>tmarlette</dc:creator>
      <dc:date>2016-06-03T19:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: REGEX Extraction (same log format, different fields in DNS data)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279455#M84423</link>
      <description>&lt;P&gt;You do this by stacking the transforms with the correct details.  Try this:&lt;/P&gt;

&lt;P&gt;In props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[myDNS]
Report-ThisPartIsArbitraryButMustBeUnique = extract_answer_section answer_section_mv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[extract_answer_section ]
REGEX = ANSWER\s+SECTION:([^*]+)AUTHORITY
FORMAT = answer_section::$1

[answer_section_mv]
SOURCE_KEY = answer_section
REGEX = (Name)\s+\"([^\"]+)\"
FORMAT = $1::$2
MV_ADD = true
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jun 2016 06:54:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279455#M84423</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-06-08T06:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: REGEX Extraction (same log format, different fields in DNS data)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279456#M84424</link>
      <description>&lt;P&gt;I took part of this and I think it works well enough. &lt;/P&gt;

&lt;P&gt;here are my settings&lt;/P&gt;

&lt;P&gt;in props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[myDns]
REPORT-mv = answer_section_MV
EXTRACT-ans_sec = ANSWER\sSECTION:(?[^*]+)AUTHORITY
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;in transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[answer_section_MV]
SOURCE_KEY = answer_section
REGEX = (Name)\s+\"([^\"]+)\"
FORMAT = $1::$2
MV_ADD = true    
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When I attempted to extract the 'answer_section' field in transforms.conf, it wouldn't pull out the 'Name' field. &lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2016 19:33:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REGEX-Extraction-same-log-format-different-fields-in-DNS-data/m-p/279456#M84424</guid>
      <dc:creator>tmarlette</dc:creator>
      <dc:date>2016-06-08T19:33:31Z</dc:date>
    </item>
  </channel>
</rss>

