You'll need mtail to count the events, and something else (like
http://prometheus.io) to do the aggregations.
As both timestamps are in the same log line, you can get your subtraction done pretty easily/
Once you have constructed the match pattern, you can answer the first two questions by incrementing a counter broken down by client, api, and status. You can record the latency of the requests by client, api, and status in a histogram.
Then you';ll need to have Prometheus or something like it scrape these metrics and do the aggregations.
If I can assume some things about your log lines, then a program like:
`
counter requests by client, api, status
histogram latency by client, api, status buckets 1, 2, 4, 8
/.* (<?Pclient>\w+) (<?Papi>\w+) (<?Purl>.+) (<?start>\w{3} \w{3} +\d?\d \d{2}:\d{2}:\d{2} \w+ \d+) (<?Pend>\w{3} \w{3} +\d?\d \d{2}:\d{2}:\d{2} \w+ \d+) (<?Pstatus>success|error)/ {
requests[$client][$api][$status]++
latency[$client][$api][$status] = $end - $start
}
`
I expect you'll have to tune the regular expression to match your actual log line syntax.
Good luck!