@pgadhari
You should forward your search results in summary index and then just search it without tstats.
tstats needs to extract fields during indexing time. I am not sure if this works with a summary index.
However, storing calculation results in a summary index can provide significant benefits. Also, you don't have to do a lot of processing over and over, and you can search on a longer time range. And Summary Index does not consume daily license.
I'm still looking for a way to use tstats at the summary index or add a field extraction configuration that can use tstats later, but I haven't yet found a good way.
Here is the step to use summary index without using tstats command.
*Reference : https://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Usesummaryindexing *
Step 1) Create a new index to use as a summary index.
The method of creating a summary index is the same as creating a general index. The entity is just an index.
Note: When creating a summary index, your configuration may affect where you create the summary index. Only SearchHead can generate summary index data. And you can not access that summary index from other SearchHeads.
Option 1: Store summary index locally on SearchHead
If you are using standalone Splunk or single SearchHead, there is no problem creating an index locally.
Option 2: Save summary index in Indexer
If the amount of data in the summary index to create or the number of events is large, it is possible to hold the summary index in Indexer.
By doing so, you have the following benefits:
Aggregates data in Indexer
Summary index can be used from other SearchHead such as SearchHeadCluster
If you want to save the summary index in Indexer, you need to set up to transfer SearchHead data to Indexer, referring to the following page.
*Reference : Best practice: Forward search head data to the indexer layer
https://docs.splunk.com/Documentation/Splunk/latest/DistSearch/Forwardsearchheaddata *
Keep in mind the following points when making this setting:
- You will not be able to access the summary index already created in SearchHead (since all requests will be sent to Indexer)
- Before setting up, it is necessary to create a summary index used by SearchHead in Indexer. To create an index in Indexer, distribute indexes.conf from Cluster Master.
Step 2) Set the schedule search as the following settings.
Execution interval and time range specification are one example, please change according to your search frequency and requirements.
If you want to set the summary index from the schedule search setting screen on the WebUI, please delete the collect command line of the query because it is unnecessary.
Execution interval : per 1h
Search Timerange : Relative , earliest: -1h@h , latest: @h
Query1:
collect command line means , store search results in to summary index dcim_summary and add a strings tags=dcim_sum_v1 to record.
Please change the index name from dcim_summary to created in Step 1.
You should add a tag or label, if you use same summary index to other usage.
index=dcim
| fields value, source
| bin _time span=1m
| stats sum(value) as values by _time,source
| eval labels="source:"+source
| xyseries _time labels values
| addtotals
| collect index=dcim_summary marker="tags=dcim_sum_v1"
Step 3) Search statistical data from summary index.
Query2:
index=dcim_summary tags=dcim_sum_v1
| bin _time span=1m
| stats sum(source:*) sum(Total) by _time
Thanks for reading. I hope it helps you.
... View more