<?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: query to get difference of data from current month and previous month in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/634371#M108560</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;Wow!!! this is exactly&amp;nbsp; what i needed.&lt;/P&gt;&lt;P&gt;Need one more help , both days count&amp;nbsp; are getting store in one variable i.e.&amp;nbsp; Hits, _time and in apiName like below :&lt;/P&gt;&lt;P&gt;_time apiName Hits&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;2023-02-14&lt;/TD&gt;&lt;TD&gt;apiName&lt;/TD&gt;&lt;TD&gt;15416&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2023-03-14&lt;/TD&gt;&lt;TD&gt;apiName&lt;/TD&gt;&lt;TD&gt;16441&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can i segregate in two separate variables? So that i can able to calculate %age increase in Hits.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know i am asking a lot , since i am very new in Splunk. Please help me out .&lt;/P&gt;</description>
    <pubDate>Tue, 14 Mar 2023 09:33:23 GMT</pubDate>
    <dc:creator>nicksrulz</dc:creator>
    <dc:date>2023-03-14T09:33:23Z</dc:date>
    <item>
      <title>Search to get difference of data from current month and previous month?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/633838#M108511</link>
      <description>&lt;P&gt;Hi Legends,&lt;/P&gt;
&lt;P&gt;I want to know is this type of splunk query possible to create?&lt;/P&gt;
&lt;P&gt;We want a query which will pull 2 types of data, for ex. I ran a query by selecting time-picker as last 4 hours, so it will pull the data of last 4 hours from current time i.e. 09/03/2023 11:30 AM to 09/03/2023 03:30 PM now along with this data it should also pull last month's data for similar timeframe i.e. 09/02/2023 11:30 AM to 09/02/2023 03:30 PM.&lt;/P&gt;
&lt;P&gt;The purpose of this query is to see the Month on Month growth .&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 13:25:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/633838#M108511</guid>
      <dc:creator>nicksrulz</dc:creator>
      <dc:date>2023-03-13T13:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: query to get difference of data from current month and previous month</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/633845#M108512</link>
      <description>&lt;P&gt;The way to calculate a second time range based on the first time range from the picker is to have a background search that will do that calculation and make a new token that can be used to search both current and previous range.&lt;/P&gt;&lt;P&gt;Here are two examples that show how it's done.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dynamic-label-based-on-time-input-change/m-p/629240" target="_blank"&gt;https://community.splunk.com/t5/Dashboards-Visualizations/How-to-create-dynamic-label-based-on-time-input-change/m-p/629240&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.splunk.com/t5/Getting-Data-In/How-to-count-events-for-specific-time-period-now-and-7-days/m-p/633506#M108455" target="_blank"&gt;https://community.splunk.com/t5/Getting-Data-In/How-to-count-events-for-specific-time-period-now-and-7-days/m-p/633506#M108455&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 07:54:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/633845#M108512</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-03-09T07:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: query to get difference of data from current month and previous month</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/633851#M108513</link>
      <description>&lt;P&gt;You can use the info times to modify your index search&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your index&amp;gt;     [| makeresults
    | fields - _time
    | addinfo
    | eval row=mvrange(0,2)
    | mvexpand row
    | eval earliest=relative_time(info_min_time, "-".row."mon")
    | eval latest=relative_time(info_max_time, "-".row."mon")
    | fields earliest latest]&lt;/LI-CODE&gt;&lt;P&gt;The subsearch is executed first to retrieve the earliest/latest (info_min_time/info_max_time) and create two rows with the times one month apart. Bear in mind that if the current month is longer than the previous month you could end up with two dates in the same month.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 08:52:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/633851#M108513</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-03-09T08:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: query to get difference of data from current month and previous month</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/633973#M108525</link>
      <description>&lt;P&gt;I'm just doing a dashboard on subsearches with "the good", "the bad" and "the ugly" uses of subsearches - I always tend to view them in the bad to ugly category, but this is a good example and it's a great use case for "macro-isation".&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 01:06:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/633973#M108525</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-03-10T01:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: query to get difference of data from current month and previous month</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/634186#M108548</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;Thanks for your response, I tried your query its giving me earliest and latest time frame. The Ask over here is that I need data i.e. Count of my request on these time frame, for e.g. below query give me total hits of my API :&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;index="index_name" AND apiName!="" AND apiName=API_NAME&lt;BR /&gt;| search responseCode!=NULL&lt;BR /&gt;| stats count as Hits by apiName&lt;BR /&gt;| rename apiName as "API Name"&lt;BR /&gt;| table Hits&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Now from time picker if i select 4Hrs , then&amp;nbsp;&lt;SPAN&gt;I want a query which will pull 2 types of data,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;a.) it will pull the data of last 4 hours from current time i.e. 13/03/2023 11:30 AM to 13/03/2023 03:30 PM &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;b.) it should also pull last month's data for similar timeframe i.e. 13/02/2023 11:30 AM to 13/02/2023 03:30 PM.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 06:12:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/634186#M108548</guid>
      <dc:creator>nicksrulz</dc:creator>
      <dc:date>2023-03-13T06:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: query to get difference of data from current month and previous month</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/634227#M108549</link>
      <description>&lt;LI-CODE lang="markup"&gt;index="index_name" AND apiName!="" AND apiName=API_NAME     [| makeresults
    | fields - _time
    | addinfo
    | eval row=mvrange(0,2)
    | mvexpand row
    | eval earliest=relative_time(info_min_time, "-".row."mon")
    | eval latest=relative_time(info_max_time, "-".row."mon")
    | fields earliest latest]
| bin _time span=1d
| search responseCode!=NULL
| stats count as Hits by _time apiName
| rename apiName as "API Name"&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 13 Mar 2023 09:00:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/634227#M108549</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-03-13T09:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: query to get difference of data from current month and previous month</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/634371#M108560</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;Wow!!! this is exactly&amp;nbsp; what i needed.&lt;/P&gt;&lt;P&gt;Need one more help , both days count&amp;nbsp; are getting store in one variable i.e.&amp;nbsp; Hits, _time and in apiName like below :&lt;/P&gt;&lt;P&gt;_time apiName Hits&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;2023-02-14&lt;/TD&gt;&lt;TD&gt;apiName&lt;/TD&gt;&lt;TD&gt;15416&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2023-03-14&lt;/TD&gt;&lt;TD&gt;apiName&lt;/TD&gt;&lt;TD&gt;16441&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can i segregate in two separate variables? So that i can able to calculate %age increase in Hits.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know i am asking a lot , since i am very new in Splunk. Please help me out .&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 09:33:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/634371#M108560</guid>
      <dc:creator>nicksrulz</dc:creator>
      <dc:date>2023-03-14T09:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: query to get difference of data from current month and previous month</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/634377#M108561</link>
      <description>&lt;LI-CODE lang="markup"&gt;index="index_name" AND apiName!="" AND apiName=API_NAME     [| makeresults
    | fields - _time
    | addinfo
    | eval row=mvrange(0,2)
    | mvexpand row
    | eval earliest=relative_time(info_min_time, "-".row."mon")
    | eval latest=relative_time(info_max_time, "-".row."mon")
    | fields earliest latest]
| bin _time span=1d
| search responseCode!=NULL
| stats count as Hits by _time apiName
| xyseries apiName _time Hits
| rename apiName as "API Name"&lt;/LI-CODE&gt;&lt;P&gt;The issue with this is that your column names will be epoch times i.e. seconds since 1st Jan 1970. To fix this you could do something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| foreach 1*
    [| eval newname=strftime(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,"%F")
    | eval {newname}='&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'
    | fields - &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; newname]&lt;/LI-CODE&gt;&lt;P&gt;This assumes that epoch times begin with 1, which they will for the next decade or so&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 10:25:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/634377#M108561</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-03-14T10:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: query to get difference of data from current month and previous month</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/634502#M108571</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;Thanks for your continuous support , i tried your query and got below output :&lt;/P&gt;&lt;P&gt;index="indexName" AND apiName!="" AND apiName=apiName[| makeresults&lt;BR /&gt;| fields - _time&lt;BR /&gt;| addinfo&lt;BR /&gt;| eval row=mvrange(0,2)&lt;BR /&gt;| mvexpand row&lt;BR /&gt;| eval earliest=relative_time(info_min_time, "-".row."mon")&lt;BR /&gt;| eval latest=relative_time(info_max_time, "-".row."mon")&lt;BR /&gt;| fields earliest latest]&lt;BR /&gt;| bin _time span=1d&lt;BR /&gt;| search responseCode!=NULL&lt;BR /&gt;| stats count as Hits by _time apiName&lt;BR /&gt;| xyseries apiName _time Hits&lt;BR /&gt;| rename apiName as "API Name"&lt;BR /&gt;| foreach 1*&lt;BR /&gt;[| eval newname=strftime(Hits,"%F")&lt;BR /&gt;| eval oldname='Hits'&lt;BR /&gt;| fields - oldname newname]&lt;/P&gt;&lt;P&gt;API Name 1676379600 1678798800&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;apiName&lt;/TD&gt;&lt;TD&gt;23302&lt;/TD&gt;&lt;TD&gt;22722&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can i set column names in human readable&amp;nbsp; Variable , instead of numbers ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 04:46:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/634502#M108571</guid>
      <dc:creator>nicksrulz</dc:creator>
      <dc:date>2023-03-15T04:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: query to get difference of data from current month and previous month</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/634539#M108580</link>
      <description>&lt;P&gt;Try using the code exactly as I showed with the &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; and braces around newname.&lt;/P&gt;&lt;P&gt;&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; is substituted by the foreach command for each field name in the list. Putting braces around the fieldname on the left hand side of the eval uses the contents of the field as the new field name.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 09:18:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-to-get-difference-of-data-from-current-month-and-previous/m-p/634539#M108580</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-03-15T09:18:59Z</dc:date>
    </item>
  </channel>
</rss>

