I have event logs in a Splunk index. I want to get the number of a) successful requests and b) failed requests based on statusCode over the last week. However, I want to show the number of each for each day.
From my understanding, I can execute a query for yesterday using something like this:
index="my_index"
sourcetype="*"
_raw="*execTime*"
earliest=-1d@d
latest=now
| fields _time requestUrl statusCode
| stats
count(eval(statusCode<200 OR statusCode>299)) as failures
count(eval(statusCode>199 AND statusCode<300)) as successes
by requestUrl
| table requestUrl failures successes
This will give me the total success and failures for each request url for yesterday. I could copy this query and change the earliest
field value for each day. However, it seems like there are two better ways:
- Save this query as a report and pass the
earliest
value in as a parameter. This would require seven separate search requests (one for each day) or - Run one query that gets all of the events for a week. Then, run queries against the results of that query. One query for each day. The thinking is that this would reduce the set of events that need to be evaluated.
The latter seems more efficient. However, I don't know if it's possible. My question is, is it possible, if so how? Is it actually more efficient?
Thank you