<?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: Not getting proper output of query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Not-getting-proper-output-of-query/m-p/494289#M194513</link>
    <description>&lt;P&gt;Hi punyanit,&lt;BR /&gt;
at first just some hints:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;you don't need of strftime to extract Hour_Of_Day and Week_Day because you can use some automaic fields: date_hour and date_wday;&lt;/LI&gt;
&lt;LI&gt;to compare values of today and values of four days ago, you can use the command wimewrap.&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Anyway, if you run separately your two searches, have you all the values you're waiting for?&lt;/P&gt;

&lt;P&gt;Then, explore a new approach, using stats command instead join that's very slow:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=auto_prod_okta eventType="user.authentication.sso" "target{}.alternateId"=SmartCash earliest=-4w) OR (index=auto_prod_okta eventType="user.authentication.sso" "target{}.alternateId"=SmartCash earliest=@d)
| rename target{}.alternateId AS "id" date_hour AS Hour_Of_Day date_wday AS Week_Day 
| eval Current_Day=if(strftime(_time,"%Y-%m-%d")=strftime(now(),"%Y-%m-%d"),"today","old_time")
| stats count(eval(Current_Day="today") AS Current_Day_Actual count(eval(Current_Day="old_time") AS Current_Day_Average BY Hour_Of_Day 
| eval Current_Day_Average=ceil(Current_Day_Average)
| eval DifferenceFromAverage=(Current_Day_Actual-Current_Day_Average)
| table Hour_Of_Day,Current_Day,Current_Day_Actual,Current_Day_Average,DifferenceFromAverage
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I cannot test it but it should be correct.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 02:25:19 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2020-09-30T02:25:19Z</dc:date>
    <item>
      <title>Not getting proper output of query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Not-getting-proper-output-of-query/m-p/494288#M194512</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;

&lt;P&gt;In my query if my field value(Current_Day,Current_Day_Actual,Current_Day_Average,DifferenceFromAverage) is zero then i am not getting the proper output.&lt;BR /&gt;
For ex:&lt;BR /&gt;
This is the result from my query&lt;BR /&gt;
Hour_Of_Day Current_Day Current_Day_Actual  Current_Day_Average DifferenceFromAverage&lt;BR /&gt;
01  Wed 4   2   2&lt;BR /&gt;
03  Wed 10  5   5&lt;BR /&gt;
04  Wed 4   3   1&lt;BR /&gt;
05  Wed 32  23  9&lt;BR /&gt;
06  Wed 68  130 -62&lt;/P&gt;

&lt;P&gt;For "hour_of_day"=01 i am not getting the output, could any one help me in this.&lt;/P&gt;

&lt;P&gt;this the query:&lt;/P&gt;

&lt;P&gt;index=*** eventType=*** "target{}.alternateId"=*** earliest=-4w &lt;BR /&gt;
| rename target{}.alternateId AS "id" &lt;BR /&gt;
| eval Hour_Of_Day = strftime(_time, "%H") &lt;BR /&gt;
| eval Week_Day = strftime(_time,"%a") &lt;BR /&gt;
| eval Today=strftime(now(),"%a") &lt;BR /&gt;
| eval Current_Day=if(Week_Day=Today,Today,null()) &lt;BR /&gt;
| stats count(id) AS "Total_Login" by Hour_Of_Day,Current_Day &lt;BR /&gt;
| eval DailyLogins=(Total_Login/4) &lt;BR /&gt;
| stats values(DailyLogins) AS "Current_Day_Average" by Hour_Of_Day,Current_Day &lt;BR /&gt;
| eval Current_Day_Average=ceil(Current_Day_Average) &lt;BR /&gt;
| join Hour_Of_Day &lt;BR /&gt;
    [ search index=*** eventType=*** &lt;BR /&gt;
        "target{}.alternateId"=**** earliest=@d &lt;BR /&gt;
    | rename target{}.alternateId AS "id" &lt;BR /&gt;
    | eval Hour_Of_Day = strftime(_time, "%H") &lt;BR /&gt;
    | eval time_date = strftime(_time,"%w") &lt;BR /&gt;
    | stats count(id) AS "Current_Day_Actual" by Hour_Of_Day, time_date &lt;BR /&gt;
    | chart values(Current_Day_Actual) AS Current_Day_Actual by Hour_Of_Day &lt;BR /&gt;
    | table Hour_Of_Day Current_Day_Actual] &lt;BR /&gt;
| eval DifferenceFromAverage=(Current_Day_Actual-Current_Day_Average) &lt;BR /&gt;
| table Hour_Of_Day,Current_Day,Current_Day_Actual,Current_Day_Average,DifferenceFromAverage&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:25:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Not-getting-proper-output-of-query/m-p/494288#M194512</guid>
      <dc:creator>punyanit</dc:creator>
      <dc:date>2020-09-30T02:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Not getting proper output of query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Not-getting-proper-output-of-query/m-p/494289#M194513</link>
      <description>&lt;P&gt;Hi punyanit,&lt;BR /&gt;
at first just some hints:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;you don't need of strftime to extract Hour_Of_Day and Week_Day because you can use some automaic fields: date_hour and date_wday;&lt;/LI&gt;
&lt;LI&gt;to compare values of today and values of four days ago, you can use the command wimewrap.&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Anyway, if you run separately your two searches, have you all the values you're waiting for?&lt;/P&gt;

&lt;P&gt;Then, explore a new approach, using stats command instead join that's very slow:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=auto_prod_okta eventType="user.authentication.sso" "target{}.alternateId"=SmartCash earliest=-4w) OR (index=auto_prod_okta eventType="user.authentication.sso" "target{}.alternateId"=SmartCash earliest=@d)
| rename target{}.alternateId AS "id" date_hour AS Hour_Of_Day date_wday AS Week_Day 
| eval Current_Day=if(strftime(_time,"%Y-%m-%d")=strftime(now(),"%Y-%m-%d"),"today","old_time")
| stats count(eval(Current_Day="today") AS Current_Day_Actual count(eval(Current_Day="old_time") AS Current_Day_Average BY Hour_Of_Day 
| eval Current_Day_Average=ceil(Current_Day_Average)
| eval DifferenceFromAverage=(Current_Day_Actual-Current_Day_Average)
| table Hour_Of_Day,Current_Day,Current_Day_Actual,Current_Day_Average,DifferenceFromAverage
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I cannot test it but it should be correct.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:25:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Not-getting-proper-output-of-query/m-p/494289#M194513</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-09-30T02:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: Not getting proper output of query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Not-getting-proper-output-of-query/m-p/494290#M194514</link>
      <description>&lt;P&gt;Hi Giuseppe,&lt;/P&gt;

&lt;P&gt;Thank you for your efforts but your query is not giving me expected results:&lt;BR /&gt;
1.It is giving me output of all 24hrs (From 00-23) , instead of this it should give me from 00 to 09 (in hour of day field) since we have passed only 9 hrs of my current time zone.&lt;BR /&gt;
2. I am not able use default fields (date_hour and date_wday) because this field is common for -4w and @d,&lt;BR /&gt;
so it will give me result of all 24hrs available in a day.&lt;/P&gt;

&lt;P&gt;Thanks in Advance ,&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:25:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Not-getting-proper-output-of-query/m-p/494290#M194514</guid>
      <dc:creator>punyanit</dc:creator>
      <dc:date>2020-09-30T02:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: Not getting proper output of query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Not-getting-proper-output-of-query/m-p/494291#M194515</link>
      <description>&lt;P&gt;The &lt;CODE&gt;date_*&lt;/CODE&gt; fields use the are pre-TZ-adjusted values and almost certainly incorrect.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 14:02:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Not-getting-proper-output-of-query/m-p/494291#M194515</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-10-09T14:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: Not getting proper output of query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Not-getting-proper-output-of-query/m-p/494292#M194516</link>
      <description>&lt;P&gt;We cannot help if you do not post sample event data for us to use, preferably with a mockup of the expected output for those events.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 14:03:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Not-getting-proper-output-of-query/m-p/494292#M194516</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-10-09T14:03:13Z</dc:date>
    </item>
  </channel>
</rss>

