<?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 do I create a bar chart that shows the count of an event type? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-bar-chart-that-shows-the-count-of-an-event/m-p/239697#M71218</link>
    <description>&lt;P&gt;Not sure what the TimeWindowCount field is doing in your query (considering you want to show count of type A and type b only), but I'will keep that field in the result. Try like this (change the field name typeA and typeB per your need, in all places)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=demo_bs 
| eval typeA=if(searchmatch("&amp;lt;field id="39" value="00"/&amp;gt;"),1,0)
| eval typeB=abs(1-typeA)
| eval TimeWindow=if((date_hour&amp;gt;=23) OR (date_hour&amp;lt;11),1,0)
| timechart span=1d sum(typeA) as "Aproved Transactions" sum(typeB) as "NameOfTypeB Here" sum(TimeWindow) as "Historical Count During Window"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 16 Jan 2017 19:36:34 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2017-01-16T19:36:34Z</dc:date>
    <item>
      <title>How do I create a bar chart that shows the count of an event type?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-bar-chart-that-shows-the-count-of-an-event/m-p/239694#M71215</link>
      <description>&lt;P&gt;I'm new to Splunk, trying to understand how these codes work out&lt;/P&gt;

&lt;P&gt;Basically i have 2 kinds of events, that comes in txt log files.&lt;BR /&gt;
type A has "id="39" = 00" and type B has something else other than 00 into this same field..&lt;/P&gt;

&lt;P&gt;How can I create a bar chart that shows, day-to-day, how many A's and B's do I have?&lt;/P&gt;

&lt;P&gt;I searched a lot of examples and the best I could get was a Type A (badly formed)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=demo_bs 
     | bucket _time span=24h 
     | stats sum(eval(if((date_hour&amp;gt;=23) OR (date_hour&amp;lt;11),1,0))) as TimeWindowCount by _time 
     | appendcols 
       [search index=demo_bs "&amp;lt;field id="39" value="00"/&amp;gt;" 
        | stats count as Aprovadas] 
     | eventstats max(Aprovadas) as Aprovadas 
     | rename TimeWindowCount as "Historical Count During Window" 
     | rename Aprovadas as "Aproved Transactions"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Jan 2017 18:36:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-bar-chart-that-shows-the-count-of-an-event/m-p/239694#M71215</guid>
      <dc:creator>coronelfoca</dc:creator>
      <dc:date>2017-01-16T18:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a bar chart that shows the count of an event type?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-bar-chart-that-shows-the-count-of-an-event/m-p/239695#M71216</link>
      <description>&lt;P&gt;Hi coronetfoca,&lt;/P&gt;

&lt;P&gt;I hope I got your question right, but this should give you a point to start:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 
| eval foo="\"id=\"39\" = 00\", \"id=\"39\" = 01\"", _time=now() 
| rex max_match=0 field=foo "\"id=\"39\"\s=\s(?&amp;lt;myFoo&amp;gt;[^\"]+)\"" 
| mvexpand myFoo 
| eval approved=if(myFoo="00",1,null()), not-approved=if(myFoo&amp;gt;"00",1,null()) 
| chart count(approved) AS approved count(not-approved) AS not-approved by _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will give you an example and the important lines are the two last ones, lines 1-4 are only used to produce fake events.&lt;/P&gt;

&lt;P&gt;So what happens here:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;will create a dummy event&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval foo="\"id=\"39\" = 00\", \"id=\"39\" = 01\"", _time=now() 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;evals &lt;CODE&gt;foo&lt;/CODE&gt; and &lt;CODE&gt;_time&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex max_match=0 field=foo "\"id=\"39\"\s=\s(?&amp;lt;myFoo&amp;gt;[^\"]+)\"" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;using regex we get the value you need into a field called &lt;CODE&gt;myFoo&lt;/CODE&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| mvexpand myFoo 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;expands the multivalue field into single value field&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval approved=if(myFoo="00",1,null()), not-approved=if(myFoo&amp;gt;"00",1,null()) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;checking if the value of &lt;CODE&gt;myFoo&lt;/CODE&gt; matches an approved or a not-approved&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| chart count(approved) AS approved count(not-approved) AS not-approved by _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;charting it by time&lt;/P&gt;

&lt;P&gt;Just adapt it to your needs with the historical counts.&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2017 19:22:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-bar-chart-that-shows-the-count-of-an-event/m-p/239695#M71216</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2017-01-16T19:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a bar chart that shows the count of an event type?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-bar-chart-that-shows-the-count-of-an-event/m-p/239696#M71217</link>
      <description>&lt;P&gt;Hi coronelfoca, &lt;/P&gt;

&lt;P&gt;When your log was indexed, the id and value fields should have been extracted. If not, extract these two fields from your events. &lt;BR /&gt;
Then you can use the eval command to classify event types using id and value as criteria. The following example assumes all your events are either TypeA or TypeB: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=demo_bs | timechart span=1d count(eval(id="39" AND value="00")) as TypeA, count as All | eval TypeB = All - TypeA | fields - All
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then, use visualization to view the data in a bar chart. &lt;BR /&gt;
Hope this helps. Thanks!&lt;BR /&gt;
Hunter&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2017 19:31:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-bar-chart-that-shows-the-count-of-an-event/m-p/239696#M71217</guid>
      <dc:creator>hunters_splunk</dc:creator>
      <dc:date>2017-01-16T19:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a bar chart that shows the count of an event type?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-bar-chart-that-shows-the-count-of-an-event/m-p/239697#M71218</link>
      <description>&lt;P&gt;Not sure what the TimeWindowCount field is doing in your query (considering you want to show count of type A and type b only), but I'will keep that field in the result. Try like this (change the field name typeA and typeB per your need, in all places)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=demo_bs 
| eval typeA=if(searchmatch("&amp;lt;field id="39" value="00"/&amp;gt;"),1,0)
| eval typeB=abs(1-typeA)
| eval TimeWindow=if((date_hour&amp;gt;=23) OR (date_hour&amp;lt;11),1,0)
| timechart span=1d sum(typeA) as "Aproved Transactions" sum(typeB) as "NameOfTypeB Here" sum(TimeWindow) as "Historical Count During Window"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Jan 2017 19:36:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-bar-chart-that-shows-the-count-of-an-event/m-p/239697#M71218</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-16T19:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a bar chart that shows the count of an event type?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-bar-chart-that-shows-the-count-of-an-event/m-p/239698#M71219</link>
      <description>&lt;P&gt;@coronelfoca - Looks like you have a few possible solutions to your question. If one of them provided a working solution, please don't forget to click "Accept" below the best answer to resolve this post. If you still need help, please leave a comment. Don’t forget to upvote anything that was helpful too. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 01:24:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-create-a-bar-chart-that-shows-the-count-of-an-event/m-p/239698#M71219</guid>
      <dc:creator>aaraneta_splunk</dc:creator>
      <dc:date>2017-01-23T01:24:55Z</dc:date>
    </item>
  </channel>
</rss>

