<?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: Timechart multiple events by a field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49684#M11932</link>
    <description>&lt;P&gt;Timechart does not sort by the field, as it orders the data by time. What exactly are you trying to sort? Are you certain that the &lt;CODE&gt;timechart&lt;/CODE&gt; command is the best way to express your results?&lt;/P&gt;</description>
    <pubDate>Mon, 04 Mar 2013 13:12:29 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2013-03-04T13:12:29Z</dc:date>
    <item>
      <title>Timechart multiple events by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49681#M11929</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I have multiple events that I wish to timechart the top 20, the events look like this:&lt;/P&gt;

&lt;P&gt;s.d.r.rrm.0.TIME.Range[1,2].hod.-1.number = 100&lt;BR /&gt;&lt;BR /&gt;
s.d.r.rrm.500.TIME.Range[1,2].hod.-1.number = 300&lt;BR /&gt;&lt;BR /&gt;
s.d.r.rrm.300.TIME.Range[1,2].hod.-1.number = 500&lt;BR /&gt;&lt;BR /&gt;
total of around 200+ of those.&lt;/P&gt;

&lt;P&gt;I want to create a timechart of the top 20 results using a by of the 4th field(0,500,300) so I will have a timechart of 20 lines based on the 4th field&lt;/P&gt;

&lt;P&gt;if i do a search with &lt;CODE&gt;s.d.r.rrm.*.TIME.Range[1,2].hod.-1.number&lt;/CODE&gt; then I see my search bringing back all the results which is good but &lt;CODE&gt;top&lt;/CODE&gt; doesn't work and using &lt;CODE&gt;timechart max(*number)&lt;/CODE&gt; doesn't work either&lt;/P&gt;

&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2013 08:53:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49681#M11929</guid>
      <dc:creator>nirt</dc:creator>
      <dc:date>2013-03-04T08:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart multiple events by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49682#M11930</link>
      <description>&lt;P&gt;Do you actually &lt;EM&gt;have&lt;/EM&gt; a field for the fourth element? What is its name? If you don't have a field defined, then you can't do &lt;CODE&gt;top&lt;/CODE&gt; or &lt;CODE&gt;timechart&lt;/CODE&gt; on it.&lt;/P&gt;

&lt;P&gt;This might work, if you don't have a field:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;s.d.r.rrm.*.TIME.Range[1,2].hod.-1.number
| rex "s\.d\.r\.rrm\.(?&amp;lt;myfield&amp;gt;.*?)\."
| top myfield
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;s.d.r.rrm.*.TIME.Range[1,2].hod.-1.number
| rex "s\.d\.r\.rrm\.(?&amp;lt;myfield&amp;gt;.*?)\."
| stats count by myfield
| sort -count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;etc.&lt;/P&gt;

&lt;P&gt;Adding additional reporting based on comments below...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;s.d.r.rrm.*.TIME.Range[1,2].hod.-1.number
| rex "s\.d\.r\.rrm\.(?&amp;lt;country&amp;gt;.*?)\."
| timechart span=1h limit=20 useother=f usenull=f count by country
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Mar 2013 10:32:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49682#M11930</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-03-04T10:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart multiple events by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49683#M11931</link>
      <description>&lt;P&gt;Thanks, I took the rex you provided and that have created my field(as it did not have one in the past),I've added afterwards timechart and it seems to be looking better!&lt;BR /&gt;
my query looks as following now:&lt;BR /&gt;
s.d.r.rrm.&lt;EM&gt;.TIME.Range[1,2].hod.-1.number&lt;BR /&gt;
| rex "s.d.r.rrm.(?&lt;MYFIELD&gt;.&lt;/MYFIELD&gt;&lt;/EM&gt;?)." | timechart span=1h per_hour(number) BY myfield&lt;BR /&gt;
As i have 3 hosts that give me this information i need to aggregate them and do the timechart based on that(using per_hour)&lt;BR /&gt;
however I do notice that it does not sort it, and adding the sort command before doesn't help as it does sort count events.any idea how to fix?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:26:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49683#M11931</guid>
      <dc:creator>nirt</dc:creator>
      <dc:date>2020-09-28T13:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart multiple events by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49684#M11932</link>
      <description>&lt;P&gt;Timechart does not sort by the field, as it orders the data by time. What exactly are you trying to sort? Are you certain that the &lt;CODE&gt;timechart&lt;/CODE&gt; command is the best way to express your results?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2013 13:12:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49684#M11932</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-03-04T13:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart multiple events by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49685#M11933</link>
      <description>&lt;P&gt;I want to see the data in timeframe(1 day or maybe 1 week), the data is per country so i want to see the top results as i don't care about countries with low amount of values and line chart seemed like the best way to do it to see the data and easiest to understand it but perhaps i'm wrong?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2013 19:42:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49685#M11933</guid>
      <dc:creator>nirt</dc:creator>
      <dc:date>2013-03-04T19:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart multiple events by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49686#M11934</link>
      <description>&lt;P&gt;The line chart is fine, I just didn't understand how you want to sort things.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2013 23:03:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49686#M11934</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-03-04T23:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart multiple events by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49687#M11935</link>
      <description>&lt;P&gt;i sort the data per event(each event is different country) and i want to see the top events(in the sum of a day)&lt;BR /&gt;
could be what i want to do is over-kill and maybe it's better to show a bar chart of the total amount every day(data is taken every hour) and then will it be possible to perform top 20 on that bar timechart?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2013 06:34:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49687#M11935</guid>
      <dc:creator>nirt</dc:creator>
      <dc:date>2013-03-05T06:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart multiple events by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49688#M11936</link>
      <description>&lt;P&gt;i'll try to rephrase the question.&lt;BR /&gt;
How can I take all the data - and do top on the avg of all the data BY myfield and then do timechart on that?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2013 14:30:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49688#M11936</guid>
      <dc:creator>nirt</dc:creator>
      <dc:date>2013-03-05T14:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart multiple events by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49689#M11937</link>
      <description>&lt;P&gt;Thanks, I keep seeing that I forgot to give all the picture.&lt;BR /&gt;
Besides the country parameter I also have TimeRange parameters&lt;BR /&gt;
so:&lt;BR /&gt;
s.d.r.rrm.*.TIME.Range[1,2].hod.-1.number&lt;/P&gt;

&lt;P&gt;and&lt;BR /&gt;
s.d.r.rrm.*.TIME.Range[3,4].hod.-1.number&lt;/P&gt;

&lt;P&gt;To make it easier I will make it span=1d instead of 1h to ease the view as daily check is good enough&lt;BR /&gt;
However I need to split by country and range... meaning the count of number of country is per range&lt;BR /&gt;
so country 1 has 2-3 ranges, each range has it's own number&lt;/P&gt;

&lt;P&gt;Thanks again and sorry that i missed this&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2013 18:24:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49689#M11937</guid>
      <dc:creator>nirt</dc:creator>
      <dc:date>2013-03-05T18:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart multiple events by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49690#M11938</link>
      <description>&lt;P&gt;I am starting an entirely new answer thread, as so much more information has been shared - the old answer no longer makes sense. Try this, and see if it is closer to the information that you want.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"s.d.r.rrm.*.TIME.Range[*].hod.-1.number"
| rex "s\.d\.r\.rrm\.(?&amp;lt;country&amp;gt;.*?)\.TIME\.Range\[?&amp;lt;timeRange&amp;gt;\d+\,"
| search [ search "s.d.r.rrm.*.TIME.Range[*].hod.-1.number"
    | rex "s\.d\.r\.rrm\.(?&amp;lt;country&amp;gt;.*?)\."
    | stats sum(number) as Total by country 
    | sort -Total
    | return 20 country ]
| chart sum(number) as TotalCount by timeRange country
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The subsearch identifies the top 20 countries and returns the list to the main search. The main search then filters so that only those countries remain. &lt;/P&gt;

&lt;P&gt;You cannot have a timechart with multiple fields in the "by" clause, so I have used chart instead. The timeRange field represents only the first integer in the time range.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2013 11:00:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49690#M11938</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-03-06T11:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: Timechart multiple events by a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49691#M11939</link>
      <description>&lt;P&gt;This is much better!, however a few issues:&lt;BR /&gt;
1. the first rex did not work so i changed it to:&lt;BR /&gt;
rex "s.d.r.rrm.(?&lt;COUNTRY&gt;.&lt;EM&gt;?).TIME.(?&lt;TIMERANGE&gt;.&lt;/TIMERANGE&gt;&lt;/EM&gt;?).&lt;BR /&gt;
2. For some reason in each timerange i see a country called 'OTHER' and 'VALUE'&lt;BR /&gt;
3. if i manually try to find those countries by running search:&lt;BR /&gt;
"s.d.r.rrm.OTHER.TIME.Range[*].hod.-1.number" , it finds no results - so it doesn't exist. Splunk adds this manually?&lt;/COUNTRY&gt;&lt;/P&gt;

&lt;P&gt;Other than that - AMAZING!&lt;BR /&gt;
Thanks!!!&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2013 16:28:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Timechart-multiple-events-by-a-field/m-p/49691#M11939</guid>
      <dc:creator>nirt</dc:creator>
      <dc:date>2013-03-06T16:28:14Z</dc:date>
    </item>
  </channel>
</rss>

