<?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: unique search string from json in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/unique-search-string-from-json/m-p/249578#M341</link>
    <description>&lt;P&gt;Disregard my previous comment, I missed the first part of your question...&lt;/P&gt;

&lt;P&gt;You can use the &lt;CODE&gt;rex&lt;/CODE&gt; command to do the field extraction, and then count by values of your field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; base_search | rex max_match=100 "(?&amp;lt;myextraction&amp;gt;mystr-\d+)"  | stats count by myextraction
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;max_match&lt;/CODE&gt; is needed to tell the rex command to not stop after the first match, but to create a multi-value extraction. If you presumably have more than 100 hits in your events, you need to adjust this accordingly.&lt;/P&gt;</description>
    <pubDate>Wed, 16 Mar 2016 10:09:34 GMT</pubDate>
    <dc:creator>DMohn</dc:creator>
    <dc:date>2016-03-16T10:09:34Z</dc:date>
    <item>
      <title>unique search string from json</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/unique-search-string-from-json/m-p/249576#M339</link>
      <description>&lt;P&gt;hello there,&lt;/P&gt;

&lt;P&gt;i am trying to analyze json data that contains a lot of fields.&lt;BR /&gt;
here i want to first search for a string where one part of it is static and one part of it is variable and then get a count of how many time each string was found.&lt;/P&gt;

&lt;P&gt;example:&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;field1: some text &lt;STRONG&gt;mystr-555&lt;/STRONG&gt; more tex33t&lt;BR /&gt;
field2: other text &lt;STRONG&gt;mystr-555&lt;/STRONG&gt; more textg5&lt;BR /&gt;
field3: foobaar &lt;STRONG&gt;mystr-555&lt;/STRONG&gt; bar bar foo&lt;BR /&gt;
field4: xyz &lt;STRONG&gt;mystr-222&lt;/STRONG&gt; foo 98432&lt;BR /&gt;
field5: random numbers and text &lt;STRONG&gt;mystr-222&lt;/STRONG&gt; more text&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;so i search for "** *mystr-* **"  and get 5 different results (since it found 5 different fields).&lt;BR /&gt;
i'd like to somehow pass only the found string further so i can do further analysis with it, but i fail miserably &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;i tried dedup, eval and return  but most definitely i used them in a wrong way.&lt;/P&gt;

&lt;P&gt;i am very new to working in this field (normally i use grep awk and sed) and i am aware that i am asking newbie things, but i know it is possible and not that hard. maybe some one of you have the five minutes to help me out here.&lt;/P&gt;

&lt;P&gt;any input would be appreciated,&lt;/P&gt;

&lt;P&gt;regards,&lt;BR /&gt;
sam&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 08:48:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/unique-search-string-from-json/m-p/249576#M339</guid>
      <dc:creator>sfreudiger</dc:creator>
      <dc:date>2016-03-16T08:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: unique search string from json</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/unique-search-string-from-json/m-p/249577#M340</link>
      <description>&lt;P&gt;for clarification: i would like my result to be something like this:&lt;/P&gt;

&lt;P&gt;mystr-555:  count:3&lt;BR /&gt;
mystr-222:  count:2&lt;/P&gt;

&lt;P&gt;.. and then i want to go on and add date/time information, but that's next and nothing i worry about now&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 10:03:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/unique-search-string-from-json/m-p/249577#M340</guid>
      <dc:creator>sfreudiger</dc:creator>
      <dc:date>2016-03-16T10:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: unique search string from json</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/unique-search-string-from-json/m-p/249578#M341</link>
      <description>&lt;P&gt;Disregard my previous comment, I missed the first part of your question...&lt;/P&gt;

&lt;P&gt;You can use the &lt;CODE&gt;rex&lt;/CODE&gt; command to do the field extraction, and then count by values of your field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; base_search | rex max_match=100 "(?&amp;lt;myextraction&amp;gt;mystr-\d+)"  | stats count by myextraction
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;max_match&lt;/CODE&gt; is needed to tell the rex command to not stop after the first match, but to create a multi-value extraction. If you presumably have more than 100 hits in your events, you need to adjust this accordingly.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 10:09:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/unique-search-string-from-json/m-p/249578#M341</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2016-03-16T10:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: unique search string from json</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/unique-search-string-from-json/m-p/249579#M342</link>
      <description>&lt;P&gt;not allowed to have more posts since i only have a rep of 40, hence here my reply to dmohn:&lt;/P&gt;

&lt;P&gt;dear dmohn,&lt;/P&gt;

&lt;P&gt;thank you for your fast reply!&lt;BR /&gt;
it looks good but i get an "No results found."&lt;/P&gt;

&lt;P&gt;what does the d+ do?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 11:07:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/unique-search-string-from-json/m-p/249579#M342</guid>
      <dc:creator>sfreudiger</dc:creator>
      <dc:date>2016-03-16T11:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: unique search string from json</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/unique-search-string-from-json/m-p/249580#M343</link>
      <description>&lt;P&gt;ignore my previous post, i was able to get it working.&lt;/P&gt;

&lt;P&gt;my example i gave here was not correct, i managed to get what i want with this search:&lt;/P&gt;

&lt;P&gt;host=twitter | rex max_match=100 "(?mystr-[0-9][0-9][0-9][0-9]-\d+)"  | stats count by myextraction&lt;/P&gt;

&lt;P&gt;thank you a lot!!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 11:18:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/unique-search-string-from-json/m-p/249580#M343</guid>
      <dc:creator>sfreudiger</dc:creator>
      <dc:date>2016-03-16T11:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: unique search string from json</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/unique-search-string-from-json/m-p/249581#M344</link>
      <description>&lt;P&gt;@sfreudiger:&lt;BR /&gt;
Glad you managed it anyway!&lt;/P&gt;

&lt;P&gt;Just for your information: the regex \d+ translates to 'one or more digits [0-9]' - So you could simplify your extraction to &lt;CODE&gt;mystr-\d{4}-\d+&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;To debug regex extractions, have a look at &lt;A href="https://regex101.com"&gt;https://regex101.com&lt;/A&gt; - I gained a ton of regex knowledge there!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 12:54:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/unique-search-string-from-json/m-p/249581#M344</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2016-03-16T12:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: unique search string from json</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/unique-search-string-from-json/m-p/249582#M345</link>
      <description>&lt;P&gt;thank you again!&lt;/P&gt;

&lt;P&gt;cant award any points yet, once i have enough i'll come back here and give you some karma &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2016 13:24:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/unique-search-string-from-json/m-p/249582#M345</guid>
      <dc:creator>sfreudiger</dc:creator>
      <dc:date>2016-03-16T13:24:22Z</dc:date>
    </item>
  </channel>
</rss>

