Hi Team,
I have a scenario to display dates of selected month in columns.
For Example , if i select August month in dropdown i need output as 1 2 3 4.......31 [should display all dates as columns] and if i select Feb, dates should be displayed as 1 2 3 ....28
Please help me how can i achieve this.
Hi,
You can autogenerate the monthly names as well, they would be ordered in reverse chronological order. Also, you can already calculate the end for the search as well in that search.
This is a working example, it should be rather close to what you are looking for:
<form>
<label></label>
<fieldset submitButton="false" autoRun="false">
<input type="dropdown" token="begin" searchWhenChanged="true">
<label>Month</label>
<fieldForLabel>month</fieldForLabel>
<fieldForValue>begin</fieldForValue>
<search>
<query>| makeresults | timechart span=1mon count | eval month=strftime(_time,"%B %Y")| eval begin=_time| eval end=relative_time(_time,"+1mon")</query>
<earliest>-12mon@mon</earliest>
<latest>@mon</latest>
</search>
<change>
<set token="end">$row.end$</set>
</change>
</input>
</fieldset>
<row>
<panel>
<chart>
<search>
<query>index=_internal | timechart span=1d count</query>
<earliest>$begin$</earliest>
<latest>$end$</latest>
</search>
</chart>
</panel>
</row>
</form>
Hth,
-Kai.
You would need to set Month values as per default Time field date_month
i.e. lower case full month name, similar to following:
<input type="dropdown" token="$tokMonth$" searchWhenChanged="true">
<label>Select Month</label>
<choice value="january">January</choice>
...
...
<choice value="november">November</choice>
<choice value="december">December</choice>
<change>
<eval token="$tokCurrentYear$">strftime(now(),"%Y")</eval>
</change>
</input>
Then your search query should have date_month="$tokMonth$"
in the base query and statistics should be with span=1d
There could be multiple options the way you are writing your current search following are couple
<YourBaseSearch> date_month="$tokMonth$" date_year="$tokCurrentYear$"
| stats count by date_mday
Or with span field using timechart
command:
<YourBaseSearch> date_month="$tokMonth$" date_year="$tokCurrentYear$"
| timechart span=1d count
PS: You can also code change event on Select Month dropdown using eval to set year as current year and pass on to the base search if your use case is to filter record only from current year as stated above.