Extended Example (generate apache logs for a 24hr battle of 100k events):
steps=$(ruby normal.rb -s 2 -m 9 -n 25000 -- 0 24)
yes '12.154.191.10 - - [%d/%b/%Y:%H:%M:%S %z] "POST /battle/lasers?color=red HTTP/1.1" 200 -' |
ruby timeseries.rb -s '2011/11/11' -t '2011/11/12' $steps > thebattle.tmp
steps=$(ruby normal.rb -s 2 -m 15 -n 25000 -- 0 24)
yes '204.12.10.120 - - [%d/%b/%Y:%H:%M:%S %z] "POST /battle/lasers?color=blue HTTP/1.1" 200 -' |
ruby timeseries.rb -s '2011/11/11' -t '2011/11/12' $steps >> thebattle.tmp
steps=$(ruby normal.rb -s 3 -m 12 -n 50000 -- 0 24)
cat > events.tmp <<DOC
12.154.191.10 - - [%d/%b/%Y:%H:%M:%S %z] "GET /battle/knowing HTTP/1.1" 500 36
204.12.10.120 - - [%d/%b/%Y:%H:%M:%S %z] "GET /battle/knowing HTTP/1.1" 200 48
DOC
n=$(( 50000 / 2 ))
while [ $((n--)) -gt 0 ]; do cat events.tmp; done |
ruby timeseries.rb -s 2011/11/11 -t 2011/11/12 $steps >> thebattle.tmp
sort -k 3 thebattle.tmp > access_common.txt
rm events.tmp thebattle.tmp
Then in splunk:
index=thebattle | rex field=uri "/battle/(?<thing>[^?]+)(\?color=(?<color>\w+))?" | eval color=if(isnull(color), "", color) | eval strategy=color.thing | chart count by strategy
index=thebattle | rex field=uri "/battle/(?<thing>[^?]+)(\?color=(?<color>\w+))?" | eval color=if(isnull(color), "", color) | eval strategy=color.thing | chart count over date_hour by strategy
index=thebattle | rex field=uri "/battle/(?<thing>[^?]+)(\?color=(?<color>\w+))?" | eval color=if(isnull(color), "", color) | eval strategy=color.thing | stats avg(bytes) by strategy
index=thebattle | rex field=uri "/battle/(?<thing>[^?]+)(\?color=(?<color>\w+))?" | eval color=if(isnull(color), "", color) | eval strategy=color.thing | search strategy="knowing" | stats sum(bytes) by clientip
Try setting up summary indexing:
search: index=thebattle | sistats avg(bytes) by strategy
start: @h
stop: +1h@h
run: hourly
fields:
report: avg_bytes_by_strategy
index=summary report=avg_bytes_by_strategy | stats avg(bytes) by strategy
To backfill (notice the -1 second to ensure a backfill for the first summary period):
cd /opt/splunk/bin
sudo ./splunk cmd python fill_summary_index.py -app search -name "Summary Avg Bytes by Strategy" -et $((1320969600 - 1)) -lt 1321056000 -dedup true -owner OWNER -auth USER:PASSWORD