<?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: Count events with differing strings in same field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Count-events-with-differing-strings-in-same-field/m-p/568539#M198142</link>
    <description>&lt;P&gt;Thank you&amp;nbsp;&lt;A href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957" target="_blank"&gt;@richgalloway&lt;/A&gt; for the explanation.&amp;nbsp; Stats look great but it isn't charting properly and I'm not sure why.&amp;nbsp; Seems to be putting the first count on the X-axis then charting the other two counts.&lt;/P&gt;</description>
    <pubDate>Mon, 27 Sep 2021 09:49:36 GMT</pubDate>
    <dc:creator>guywood13</dc:creator>
    <dc:date>2021-09-27T09:49:36Z</dc:date>
    <item>
      <title>Count events with differing strings in same field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-events-with-differing-strings-in-same-field/m-p/568345#M198050</link>
      <description>&lt;P&gt;So this search...&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="myindex" source="/data/logs/log.json" "Calculation Complete"&lt;/LI-CODE&gt;&lt;P&gt;... the results return a MessageBody field which has various different strings in.&amp;nbsp; I need to do the most simple regex in the world (*my string) and then want to count the messages which match that string eventually charting them.&amp;nbsp; I thought this would work, but it just returns 0 for them all.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="myindex" source="/data/logs/log.json" "Calculation Complete"
| stats
| count(eval(MessageBody="*my string")) as My_String
| count(eval(MessageBody="*your string")) as Your_String
| count(eval(MessageBody="*other string")) as Other_String&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 09:17:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-events-with-differing-strings-in-same-field/m-p/568345#M198050</guid>
      <dc:creator>guywood13</dc:creator>
      <dc:date>2021-09-24T09:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: Count events with differing strings in same field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-events-with-differing-strings-in-same-field/m-p/568376#M198068</link>
      <description>&lt;P&gt;There are a few corrections to make here.&lt;/P&gt;&lt;P&gt;1) "*my string" is not a valid regex.&amp;nbsp; In regular expressions, the "*" character means to repeat the previous character zero or more times - which makes no sense when the "*" is the first character.&amp;nbsp; If the "*" is intended to be a wildcard then what you have is a pattern rather than a regex.&lt;/P&gt;&lt;P&gt;2) The stats command and its three count functions must be a single command.&amp;nbsp; Since the pipe character ("|") separates commands, this query has an empty stats command (not allowed) and three count commands (which isn't a thing).&lt;/P&gt;&lt;P&gt;3) The eval function within stats compares strings literally so, in this example, it's checking that the MessageBody field starts with an asterisk and the text "my string".&lt;/P&gt;&lt;P&gt;Try this query&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="myindex" source="/data/logs/log.json" "Calculation Complete"
| stats count(eval(like(MessageBody, "%my string"))) as My_String,
  count(eval(like(MessageBody, "%your string"))) as Your_String,
  count(eval(like(MessageBody, "%other string"))) as Other_String&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 24 Sep 2021 12:47:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-events-with-differing-strings-in-same-field/m-p/568376#M198068</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-09-24T12:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: Count events with differing strings in same field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-events-with-differing-strings-in-same-field/m-p/568539#M198142</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;A href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957" target="_blank"&gt;@richgalloway&lt;/A&gt; for the explanation.&amp;nbsp; Stats look great but it isn't charting properly and I'm not sure why.&amp;nbsp; Seems to be putting the first count on the X-axis then charting the other two counts.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Sep 2021 09:49:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-events-with-differing-strings-in-same-field/m-p/568539#M198142</guid>
      <dc:creator>guywood13</dc:creator>
      <dc:date>2021-09-27T09:49:36Z</dc:date>
    </item>
    <item>
      <title>Re: Count events with differing strings in same field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-events-with-differing-strings-in-same-field/m-p/568543#M198143</link>
      <description>&lt;P&gt;It _is_ charting properly. It's just the way the chart works. It just does a chart over _rows_ of your data. If you have separate series of data in columns, it charts them alongside. So in your case - since you have all your data in one row, it's a chart of two different variables (Your_String and Other_String) over values of a variable My_String.&lt;/P&gt;&lt;P&gt;That's obviously not what you want, so you should do&lt;/P&gt;&lt;PRE&gt;| transpose 0&lt;/PRE&gt;&lt;P&gt;To get your data in a proper aspect.&lt;/P&gt;&lt;P&gt;You might also do some renaming on the resulting fields.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Sep 2021 10:28:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-events-with-differing-strings-in-same-field/m-p/568543#M198143</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-09-27T10:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: Count events with differing strings in same field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-events-with-differing-strings-in-same-field/m-p/568780#M198220</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt; this did the trick on the chart &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 15:47:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-events-with-differing-strings-in-same-field/m-p/568780#M198220</guid>
      <dc:creator>guywood13</dc:creator>
      <dc:date>2021-09-28T15:47:34Z</dc:date>
    </item>
  </channel>
</rss>

