<?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 is there a command that can do the same work of span in a search like   ...|timechart spans=600s count   ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/is-there-a-command-that-can-do-the-same-work-of-span-in-a-search/m-p/192248#M55276</link>
    <description>&lt;P&gt;Hi Folks,&lt;BR /&gt;
I'm unable to pass a variable to span (e.i  span=duration s) where duration is an integer.&lt;BR /&gt;
Is there a command that can do what i want? or is there a way to do what i need with span.&lt;/P&gt;

&lt;P&gt;thanks.&lt;/P&gt;</description>
    <pubDate>Mon, 23 Mar 2015 12:40:40 GMT</pubDate>
    <dc:creator>stephane_cyrill</dc:creator>
    <dc:date>2015-03-23T12:40:40Z</dc:date>
    <item>
      <title>is there a command that can do the same work of span in a search like   ...|timechart spans=600s count   ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-there-a-command-that-can-do-the-same-work-of-span-in-a-search/m-p/192248#M55276</link>
      <description>&lt;P&gt;Hi Folks,&lt;BR /&gt;
I'm unable to pass a variable to span (e.i  span=duration s) where duration is an integer.&lt;BR /&gt;
Is there a command that can do what i want? or is there a way to do what i need with span.&lt;/P&gt;

&lt;P&gt;thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2015 12:40:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-there-a-command-that-can-do-the-same-work-of-span-in-a-search/m-p/192248#M55276</guid>
      <dc:creator>stephane_cyrill</dc:creator>
      <dc:date>2015-03-23T12:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: is there a command that can do the same work of span in a search like   ...|timechart spans=600s count   ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-there-a-command-that-can-do-the-same-work-of-span-in-a-search/m-p/192249#M55277</link>
      <description>&lt;P&gt;You can use a macro.&lt;/P&gt;

&lt;P&gt;Define the macro like this (I'll use config files since that is faster for me).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[timechartSpan(3)]
args = tcSpanField, tcSpanTime, args
definition = timechart span=$tcSpanField$$tcSpanTime$ $args$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then in your search, you can do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your_search&amp;gt; | `timechartSpan(duration,"s", "count by host")`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Assuming your "duration" is 600, this should expand to:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your_search&amp;gt; | timechart span=600s count by host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Mar 2015 14:26:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-there-a-command-that-can-do-the-same-work-of-span-in-a-search/m-p/192249#M55277</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2015-03-23T14:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: is there a command that can do the same work of span in a search like   ...|timechart spans=600s count   ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-there-a-command-that-can-do-the-same-work-of-span-in-a-search/m-p/192250#M55278</link>
      <description>&lt;P&gt;Depending on at least what and where you want to archive this another approach could be to use the &lt;CODE&gt;map&lt;/CODE&gt; command like this:&lt;BR /&gt;
&lt;CODE&gt;| stats count as param | eval param=600 | map search="search index=_internal | head 1000 | timechart span=$param$s count"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Note:&lt;/STRONG&gt; If you use this search within a dashboard you have to "escape" the &lt;CODE&gt;$&lt;/CODE&gt; with &lt;CODE&gt;$$&lt;/CODE&gt;, which would look like this &lt;CODE&gt; ... span=$$param$$s ...&lt;/CODE&gt;. This is because dashboard tokens look just the same: &lt;CODE&gt;$someDashboardToken$&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2015 21:25:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-there-a-command-that-can-do-the-same-work-of-span-in-a-search/m-p/192250#M55278</guid>
      <dc:creator>bjoernjensen</dc:creator>
      <dc:date>2015-03-23T21:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: is there a command that can do the same work of span in a search like   ...|timechart spans=600s count   ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-there-a-command-that-can-do-the-same-work-of-span-in-a-search/m-p/192251#M55279</link>
      <description>&lt;P&gt;Thanks for your help.&lt;BR /&gt;
I have define the maco in macro.conf in C:\Program Files\Splunk\etc\apps\search\default  and I've even restart splunk .But when i lunch my search that is :&lt;/P&gt;

&lt;P&gt;index=_internal| &lt;CODE&gt;timechartSpan(duration,"s", "count by host")&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;i have this error:&lt;/P&gt;

&lt;P&gt;Error in 'SearchParser': Missing a search command before '''. Error at position '23' of search query 'search index=_internal|'timechartSpan(duration,"s"'.&lt;/P&gt;

&lt;P&gt;I will like to do it through macro. can you please tell me what i missed?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2015 12:48:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-there-a-command-that-can-do-the-same-work-of-span-in-a-search/m-p/192251#M55279</guid>
      <dc:creator>stephane_cyrill</dc:creator>
      <dc:date>2015-03-24T12:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: is there a command that can do the same work of span in a search like   ...|timechart spans=600s count   ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-there-a-command-that-can-do-the-same-work-of-span-in-a-search/m-p/192252#M55280</link>
      <description>&lt;P&gt;Maybe you did this:&lt;BR /&gt;
In order to call a defined macro you have to use a certain type of quotation marks: &lt;CODE&gt;`&lt;/CODE&gt;&lt;BR /&gt;
&lt;A href="http://en.wikipedia.org/wiki/Grave_accent"&gt;http://en.wikipedia.org/wiki/Grave_accent&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Moreover you should use meaningful params. e.g.:&lt;BR /&gt;
&lt;CODE&gt;index=_internal| `timechartSpan(600,"s", "count by host")`&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;As for me, I would make the makro a bit slimmer:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[timechartSpan(2)]
args = timespanvalue, args
definition = timechart span=$timespanvalue$ $args$
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Mar 2015 19:40:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-there-a-command-that-can-do-the-same-work-of-span-in-a-search/m-p/192252#M55280</guid>
      <dc:creator>bjoernjensen</dc:creator>
      <dc:date>2015-03-24T19:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: is there a command that can do the same work of span in a search like   ...|timechart spans=600s count   ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/is-there-a-command-that-can-do-the-same-work-of-span-in-a-search/m-p/192253#M55281</link>
      <description>&lt;P&gt;Thanks for your help.&lt;/P&gt;

&lt;P&gt;I've use the grave accent as you did it works with the param 600.&lt;BR /&gt;
BUT my initial problem remain:&lt;BR /&gt;
At the place where you have 600 i want to have a variable(duration) that i compute earlier. So  i want a search like this to work:&lt;/P&gt;

&lt;P&gt;index=_internal|eval duration=600|&lt;CODE&gt;timechartSpan(duration,"s", "count by host")&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I'm using this macro definition:&lt;/P&gt;

&lt;P&gt;[timechartSpan(3)]&lt;BR /&gt;
 args = tcSpanField, tcSpanTime, args&lt;BR /&gt;
 definition = timechart span=$tcSpanField$$tcSpanTime$ $args$&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2015 08:39:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/is-there-a-command-that-can-do-the-same-work-of-span-in-a-search/m-p/192253#M55281</guid>
      <dc:creator>stephane_cyrill</dc:creator>
      <dc:date>2015-03-25T08:39:02Z</dc:date>
    </item>
  </channel>
</rss>

