<?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 use rex command to extract two fields and chart the count for both in one search query? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-two-fields-and-chart-the-count/m-p/367143#M108301</link>
    <description>&lt;P&gt;I tried below query but didn't get any success. It is always giving me 0.&lt;/P&gt;

&lt;P&gt;sourcetype=10.240.204.69 "TransactionStatus" | rex field=_raw ".&lt;EM&gt;TransactionStatus (?.&lt;/EM&gt;)" |stats count((status=true)) as success_count&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 14:37:23 GMT</pubDate>
    <dc:creator>anuarora</dc:creator>
    <dc:date>2020-09-29T14:37:23Z</dc:date>
    <item>
      <title>How to use rex command to extract two fields and chart the count for both in one search query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-two-fields-and-chart-the-count/m-p/367142#M108300</link>
      <description>&lt;P&gt;I have a log statement like 2017-06-21 12:53:48,426 INFO  transaction.TransactionManager.Info:181 -{"message":{"TransactionStatus":true,"TransactioName":"removeLockedUser-1498029828160"}} . &lt;BR /&gt;
How can i extract TransactionName and TranscationStatus and print in table form TransactionName and its count&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 07:51:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-two-fields-and-chart-the-count/m-p/367142#M108300</guid>
      <dc:creator>anuarora</dc:creator>
      <dc:date>2017-06-21T07:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to use rex command to extract two fields and chart the count for both in one search query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-two-fields-and-chart-the-count/m-p/367143#M108301</link>
      <description>&lt;P&gt;I tried below query but didn't get any success. It is always giving me 0.&lt;/P&gt;

&lt;P&gt;sourcetype=10.240.204.69 "TransactionStatus" | rex field=_raw ".&lt;EM&gt;TransactionStatus (?.&lt;/EM&gt;)" |stats count((status=true)) as success_count&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:37:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-two-fields-and-chart-the-count/m-p/367143#M108301</guid>
      <dc:creator>anuarora</dc:creator>
      <dc:date>2020-09-29T14:37:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to use rex command to extract two fields and chart the count for both in one search query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-two-fields-and-chart-the-count/m-p/367144#M108302</link>
      <description>&lt;P&gt;hi anuarora&lt;BR /&gt;
you could use this regex to extract your two fields:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\{\"TransactionStatus\"\:(?&amp;lt;TransactionStatus&amp;gt;[^,]*),\"TransactioName\"\:\"(?&amp;lt;TransactioName&amp;gt;[^\"]*)\"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;you can put it in Field extraction or in rex command&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "\{\"TransactionStatus\"\:(?&amp;lt;TransactionStatus&amp;gt;[^,]*),\"TransactioName\"\:\"(?&amp;lt;TransactioName&amp;gt;[^\"]*)\""
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Test it at &lt;A href="https://regex101.com/r/8Ff4ji/1"&gt;https://regex101.com/r/8Ff4ji/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 10:48:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-two-fields-and-chart-the-count/m-p/367144#M108302</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-06-21T10:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to use rex command to extract two fields and chart the count for both in one search query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-two-fields-and-chart-the-count/m-p/367145#M108303</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="2017-06-21 12:53:48,426 INFO transaction.TransactionManager.Info:181 -{\"message\":{\"TransactionStatus\":true,\"TransactioName\":\"removeLockedUser-1498029828160\"}}"

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| rex "{\"TransactionStatus\":(?&amp;lt;TransactionStatus&amp;gt;[^,]*),\"TransactioName\":\"(?&amp;lt;TransactioName&amp;gt;[^\"]*)\""
| chart count OVER TransactioName BY TransactionStatus
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;SPECIAL NOTE: Are you sure there is not a missing &lt;CODE&gt;n&lt;/CODE&gt; in your given text for &lt;CODE&gt;TransactioName&lt;/CODE&gt; (this may have to be adjusted)?&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 14:34:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-two-fields-and-chart-the-count/m-p/367145#M108303</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-21T14:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to use rex command to extract two fields and chart the count for both in one search query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-two-fields-and-chart-the-count/m-p/367146#M108304</link>
      <description>&lt;P&gt;Thanks Mr. Woodcock. This saved me a lot of time.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2017 03:06:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-two-fields-and-chart-the-count/m-p/367146#M108304</guid>
      <dc:creator>anuarora</dc:creator>
      <dc:date>2017-06-22T03:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to use rex command to extract two fields and chart the count for both in one search query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-two-fields-and-chart-the-count/m-p/367147#M108305</link>
      <description>&lt;P&gt;@woodcock&lt;BR /&gt;
btw: Your syntax for "COMMENT" is not wrong, but there is a new one (since 6.5) you might find interesting.&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.6.1/Search/Addcommentstosearches"&gt;http://docs.splunk.com/Documentation/Splunk/6.6.1/Search/Addcommentstosearches&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2017 06:40:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-two-fields-and-chart-the-count/m-p/367147#M108305</guid>
      <dc:creator>horsefez</dc:creator>
      <dc:date>2017-06-22T06:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to use rex command to extract two fields and chart the count for both in one search query?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-two-fields-and-chart-the-count/m-p/367148#M108306</link>
      <description>&lt;P&gt;I like mine better.  When the create a genuine &lt;CODE&gt;comment&lt;/CODE&gt; command, not a &lt;CODE&gt;macro&lt;/CODE&gt;, then I will switch.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2019 15:12:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-rex-command-to-extract-two-fields-and-chart-the-count/m-p/367148#M108306</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-08T15:12:26Z</dc:date>
    </item>
  </channel>
</rss>

