I have two searches, both of which use the exact same dataset, but one uses bucket or bin command to bin into time groups and find the maximum requests in any second; the other counts the total requests, errors, etc.
The first search is something like:
sourcetype="sourcetype"
| stats count as requests, count(eval(http_code >= 400)) as errors by app_name
The second search is something like:
sourcetype="sourcetype"
| bucket span="1s" _time
| stats count by _time, app_name
| stats max(count) as max_tps by app_name
My first idea was to use appendpipe
like this but it was very slow.
sourcetype="sourcetype"
| appendpipe [bucket span="1s" _time | stats count by _time, app_name | stats max(count) as max_tps by app_name]
| stats count as requests, count(eval(http_code >= 400)) as errors, max(max_tps) by app_name
This worked as expected but it is extremely slow, like 5x slower than doing both searches separately one after the other, when I would expect it to be quicker since it is only retrieving the data once.
I also tried appendcols
but there is difficulty matching up the data correctly. Alternatively, I could use a join
.
However, apparently it is best to avoid subsearches completely and just use stats, but how can I do this when the bucket command changes the current dataset?
It seems like it should be possible to avoid subsearches since the primary dataset is exactly the same.