<?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 get the field value substring? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395761#M114910</link>
    <description>&lt;P&gt;Try the following. It triggers on the &lt;CODE&gt;{&lt;/CODE&gt; character and then skips the 2 parts after that ("type" and "A" in your examples) and then extracts the next word. It will keep matching and adding to a multivalued field. Then the mvjoin command is used to translate that multivalued field into a comma separated field as you requested.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...your base search to get to this data...
| rex field=response "\{\"\w+\":\"\w+\",\"(?&amp;lt;response_values&amp;gt;[^\"]+)" max_match=0
| eval response_values = mvjoin(response_values,",")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See &lt;A href="https://regex101.com/r/LwxZmR/1"&gt;https://regex101.com/r/LwxZmR/1&lt;/A&gt; for confirmation that the regex works with your samples.&lt;/P&gt;</description>
    <pubDate>Tue, 19 Jun 2018 11:09:35 GMT</pubDate>
    <dc:creator>FrankVl</dc:creator>
    <dc:date>2018-06-19T11:09:35Z</dc:date>
    <item>
      <title>How to get the field value substring?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395757#M114906</link>
      <description>&lt;P&gt;I have a field whose values show DNS query information&lt;BR /&gt;
for example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[{"type":"A","**response**":"204.2.232.240","asn":"2914","asname":"N/A"}]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The field name is named "response"&lt;BR /&gt;
I want to put in a different field all of the different response values (in bold)&lt;BR /&gt;
this field could contain more than 1 response value so I want them all to be in a new field with "," delimiter&lt;BR /&gt;
how do I do that?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 08:22:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395757#M114906</guid>
      <dc:creator>mcohen13</dc:creator>
      <dc:date>2018-06-19T08:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the field value substring?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395758#M114907</link>
      <description>&lt;P&gt;Can you also provide samples of events that contain multiple responses? Bit hard to come up with a regular expression based on just this simple example, while you need it to work also on more complex data apparently.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 08:53:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395758#M114907</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-06-19T08:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the field value substring?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395759#M114908</link>
      <description>&lt;P&gt;[{"type":"N/A","response":"N/A","asn":"N/A","asname":"N/A"}]&lt;BR /&gt;&lt;BR /&gt;
[{"type":"A","response":"172.20.2.105","asn":"reserved","asname":"reserved"}]&lt;BR /&gt;
[{"type":"A","response":"172.22.36.3","asn":"reserved","asname":"reserved"}]&lt;BR /&gt;
[{"type":"A","response":"172.28.76.33","asn":"reserved","asname":"reserved"}]&lt;BR /&gt;&lt;BR /&gt;
[{"type":"A","response":"204.2.232.240","asn":"2914","asname":"N/A"}]&lt;BR /&gt;
[{"type":"A","response":"2.16.76.110","asn":"20940","asname":"N/A"}]&lt;BR /&gt;&lt;BR /&gt;
[{"type":"A","response":"153.254.159.149","asn":"2914","asname":"N/A"}] &lt;BR /&gt;
[{"type":"A","response":"209.99.64.18","asn":"40034","asname":"N/A"}]&lt;BR /&gt;&lt;BR /&gt;
[{"type":"A","response":"64.124.235.203","asn":"6461","asname":"N/A"}]&lt;BR /&gt;
[{"type":"A","response":"67.225.218.50","asn":"32244","asname":"N/A"}]&lt;BR /&gt;
[{"type":"A","response":"63.237.67.237","asn":"209","asname":"qwest"}]&lt;BR /&gt;&lt;BR /&gt;
[{"type":"A","response":"184.84.165.252","asn":"20940","asname":"N/A"}] &lt;BR /&gt;
[{"type":"A","response":"23.55.56.71","asn":"20940","asname":"N/A"}]&lt;BR /&gt;
[{"type":"A","response":"96.17.148.189","asn":"20940","asname":"N/A"}]&lt;BR /&gt;&lt;BR /&gt;
[{"type":"A","response":"104.110.189.77","asn":"20940","asname":"N/A"}]&lt;BR /&gt;
[{"type":"A","response":"2.16.165.55","asn":"20940","asname":"N/A"}]&lt;BR /&gt;
[{"type":"A","response":"104.79.196.66","asn":"20940","asname":"N/A"}]&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 10:20:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395759#M114908</guid>
      <dc:creator>mcohen13</dc:creator>
      <dc:date>2018-06-19T10:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the field value substring?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395760#M114909</link>
      <description>&lt;P&gt;[{"type":"A","response":"52.7.102.57","asn":"14618","asname":"aws"},{"type":"A","response":"52.71.245.135","asn":"14618","asname":"aws"}]&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 10:21:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395760#M114909</guid>
      <dc:creator>mcohen13</dc:creator>
      <dc:date>2018-06-19T10:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the field value substring?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395761#M114910</link>
      <description>&lt;P&gt;Try the following. It triggers on the &lt;CODE&gt;{&lt;/CODE&gt; character and then skips the 2 parts after that ("type" and "A" in your examples) and then extracts the next word. It will keep matching and adding to a multivalued field. Then the mvjoin command is used to translate that multivalued field into a comma separated field as you requested.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...your base search to get to this data...
| rex field=response "\{\"\w+\":\"\w+\",\"(?&amp;lt;response_values&amp;gt;[^\"]+)" max_match=0
| eval response_values = mvjoin(response_values,",")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;See &lt;A href="https://regex101.com/r/LwxZmR/1"&gt;https://regex101.com/r/LwxZmR/1&lt;/A&gt; for confirmation that the regex works with your samples.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 11:09:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395761#M114910</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-06-19T11:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the field value substring?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395762#M114911</link>
      <description>&lt;P&gt;tried and it's not working&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 14:01:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395762#M114911</guid>
      <dc:creator>mcohen13</dc:creator>
      <dc:date>2018-06-19T14:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the field value substring?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395763#M114912</link>
      <description>&lt;P&gt;Any errors / what does "not working" mean?&lt;/P&gt;

&lt;P&gt;It works fine for me when I test it like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval response="[{\"type\":\"A\",\"response\":\"52.7.102.57\",\"asn\":\"14618\",\"asname\":\"aws\"},{\"type\":\"A\",\"response\":\"52.71.245.135\",\"asn\":\"14618\",\"asname\":\"aws\"}]"
| rex field=response "\{\"\w+\":\"\w+\",\"(?&amp;lt;response_values&amp;gt;[^\"]+)" max_match=0
| eval response_values = mvjoin(response_values,",")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can you share a screenshot of your attempt?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 14:33:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395763#M114912</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-06-19T14:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the field value substring?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395764#M114913</link>
      <description>&lt;P&gt;in the response_values field i get the response twice, what i want is the ip address&lt;BR /&gt;
2018-06-20 12:33:02 [{"type":"A","response":"52.7.102.57","asn":"14618","asname":"aws"},{"type":"A","response":"52.71.245.135","asn":"14618","asname":"aws"}]   response,response&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jun 2018 12:34:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395764#M114913</guid>
      <dc:creator>mcohen13</dc:creator>
      <dc:date>2018-06-20T12:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the field value substring?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395765#M114914</link>
      <description>&lt;P&gt;Well, you asked for extracting the bold "response" values. So that's what I thought you wanted. But extracting the address makes a lot more sense, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...your base search to get to this data...
 | rex "\"response\":\"(?&amp;lt;response_values&amp;gt;[^\"]+)" max_match=0
 | eval response_values = mvjoin(response_values,",")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Jun 2018 12:42:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395765#M114914</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-06-20T12:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the field value substring?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395766#M114915</link>
      <description>&lt;P&gt;works thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jun 2018 15:23:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-field-value-substring/m-p/395766#M114915</guid>
      <dc:creator>mcohen13</dc:creator>
      <dc:date>2018-06-20T15:23:45Z</dc:date>
    </item>
  </channel>
</rss>

