<?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 choose only some values extracted from rex command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-choose-only-some-values-extracted-from-rex-command/m-p/250010#M74624</link>
    <description>&lt;P&gt;how would it be a second filter. If i put another filter i will still apply to version either the first or the second one.&lt;BR /&gt;
also, what do you mean with "if you have numbers choose the highest between them; "&lt;/P&gt;</description>
    <pubDate>Mon, 23 Jan 2017 17:21:14 GMT</pubDate>
    <dc:creator>guillecasco</dc:creator>
    <dc:date>2017-01-23T17:21:14Z</dc:date>
    <item>
      <title>How to choose only some values extracted from rex command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-choose-only-some-values-extracted-from-rex-command/m-p/250008#M74622</link>
      <description>&lt;P&gt;Hey, i have this  rex command which extract me some fields as json data from a lot of logs&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=summary "BODY: (?\{.*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;logs&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;BODY: {"shared": {"System.ProcessorName": "Intel(R) Core(TM) i7-4720HQ CPU @ 2.60GHz", "System.Manufacturer": "GIGABYTE",  "Graphics.PCReleaseMajor": "15",  "OS.Arch": "64",, "a_data": [{"version": "9.1.4", "id": "7c965dd7-28f6-4e79-8a9c-a5d85425c371"}, {"version": "25678", "id": "8c177884-6479-48ec-8634-1243bd9c9206"}]}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;so in the interesting fields i have (among others):  shared.system.processorname, shared.system.manufacturer.....and so on.&lt;BR /&gt;
Thing is that in a_data.version i have 2 types of version in logs but that are named the same (a_data.version). How can i choose/select only the second one? a. i need to only have: a_data.version: 25678 and not a_data.version: 9.1.4&lt;/P&gt;

&lt;P&gt;is there a way to do this or not? when i'm doing  &lt;CODE&gt;stats count by version&lt;/CODE&gt; i get all versions,  but only need last version and not the first one. is there a way to "name" them differently or something like that?&lt;/P&gt;

&lt;P&gt;this is the search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index: foo | rex field=summary "BODY: (?\{.*)" | spath input=json_data |  stats count by adata{}.version | sort -count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:31:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-choose-only-some-values-extracted-from-rex-command/m-p/250008#M74622</guid>
      <dc:creator>guillecasco</dc:creator>
      <dc:date>2020-09-29T12:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose only some values extracted from rex command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-choose-only-some-values-extracted-from-rex-command/m-p/250009#M74623</link>
      <description>&lt;P&gt;Hi guillecasco,&lt;BR /&gt;
there are many things that you could to do:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;format your rex as you prefer (e.g.: &lt;CODE&gt;\d+&lt;/CODE&gt;); &lt;/LI&gt;
&lt;LI&gt;if you have numbers choose the  highest between them; &lt;/LI&gt;
&lt;LI&gt;put a second  filter in your search&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 16:44:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-choose-only-some-values-extracted-from-rex-command/m-p/250009#M74623</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-01-23T16:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose only some values extracted from rex command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-choose-only-some-values-extracted-from-rex-command/m-p/250010#M74624</link>
      <description>&lt;P&gt;how would it be a second filter. If i put another filter i will still apply to version either the first or the second one.&lt;BR /&gt;
also, what do you mean with "if you have numbers choose the highest between them; "&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 17:21:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-choose-only-some-values-extracted-from-rex-command/m-p/250010#M74624</guid>
      <dc:creator>guillecasco</dc:creator>
      <dc:date>2017-01-23T17:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose only some values extracted from rex command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-choose-only-some-values-extracted-from-rex-command/m-p/250011#M74625</link>
      <description>&lt;P&gt;Try like this (check the rex command as it was truncated in ques)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index: foo | rex field=summary "BODY: (?{.*)" | spath input=json_data | eval version=mvindex('adata{}.version',-1) | stats count by version | sort -count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Jan 2017 17:29:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-choose-only-some-values-extracted-from-rex-command/m-p/250011#M74625</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-23T17:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose only some values extracted from rex command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-choose-only-some-values-extracted-from-rex-command/m-p/250012#M74626</link>
      <description>&lt;P&gt;getting this error with that command which i think would work. the -1 only takes last value doesn´t it?&lt;/P&gt;

&lt;P&gt;"Error in 'eval' command: Arguments are missing. Usage: eval dest_key = expression"&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 17:56:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-choose-only-some-values-extracted-from-rex-command/m-p/250012#M74626</guid>
      <dc:creator>guillecasco</dc:creator>
      <dc:date>2017-01-23T17:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose only some values extracted from rex command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-choose-only-some-values-extracted-from-rex-command/m-p/250013#M74627</link>
      <description>&lt;P&gt;There seems to be an extra comma in the data you posted, so that nothing extracts after OS.Arch.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval summary="BODY: {\"shared\": {\"System.ProcessorName\": \"Intel(R) Core(TM) i7-4720HQ CPU @ 2.60GHz\", \"System.Manufacturer\": \"GIGABYTE\", \"Graphics.PCReleaseMajor\": \"15\", \"OS.Arch\": \"64\",, \"a_data\": [{\"version\": \"9.1.4\", \"id\": \"7c965dd7-28f6-4e79-8a9c-a5d85425c371\"}, {\"version\": \"25678\", \"id\": \"8c177884-6479-48ec-8634-1243bd9c9206\"}]}" 
| rex field=summary "BODY: (?&amp;lt;json_data&amp;gt;.*)"  
| spath input=json_data
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Test data with extra comma removed &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=2
| eval summary="BODY: {\"shared\": {\"System.ProcessorName\": \"Intel(R) Core(TM) i7-4720HQ CPU @ 2.60GHz\", \"System.Manufacturer\": \"GIGABYTE\", \"Graphics.PCReleaseMajor\": \"15\", \"OS.Arch\": \"64\", \"a_data\": [{\"version\": \"9.1.4\", \"id\": \"7c965dd7-28f6-4e79-8a9c-a5d85425c371\"}, {\"version\": \"25678\", \"id\": \"8c177884-6479-48ec-8634-1243bd9c9206\"}]}" 
| rex field=summary "BODY: (?&amp;lt;json_data&amp;gt;.*)"  
| spath input=json_data
| rename shared.a_data{}.version as version, shared.a_data{}.id as id 
| eval version = mvindex(version,-1) 
| eval id = mvindex(id,-1) 
| stats count by version
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Jan 2017 18:45:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-choose-only-some-values-extracted-from-rex-command/m-p/250013#M74627</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-01-23T18:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose only some values extracted from rex command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-choose-only-some-values-extracted-from-rex-command/m-p/250014#M74628</link>
      <description>&lt;P&gt;the field name was omitted by the web interface from somesoni2's code&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=summary "BODY: (?&amp;lt;json_data&amp;gt;{.*)" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Jan 2017 18:56:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-choose-only-some-values-extracted-from-rex-command/m-p/250014#M74628</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-01-23T18:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose only some values extracted from rex command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-choose-only-some-values-extracted-from-rex-command/m-p/250015#M74629</link>
      <description>&lt;P&gt;awesome! that worked&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 19:15:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-choose-only-some-values-extracted-from-rex-command/m-p/250015#M74629</guid>
      <dc:creator>guillecasco</dc:creator>
      <dc:date>2017-01-23T19:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose only some values extracted from rex command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-choose-only-some-values-extracted-from-rex-command/m-p/250016#M74630</link>
      <description>&lt;P&gt;Great!  Glad to help.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 20:18:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-choose-only-some-values-extracted-from-rex-command/m-p/250016#M74630</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-01-23T20:18:10Z</dc:date>
    </item>
  </channel>
</rss>

