Skip to content

Analyze the trend of Tomcat request status

Keyword

Analyze the trend,request status

correlation function

date_format,date_trunc

Use the date_trunc function to truncate the log time to minutes, use the date_format function to extract the hours and minutes, and then use the group by clause to aggregate the data based on the formatted time and the HTTP status code to count the number of times that each HTTP status code appears per minute. The results are displayed in a flow chart, in which the x-axis represents the time, the y-axis represents the count, and the aggregated column represents the status.

SQL
* |
select
  date_format(date_trunc('minute', __time__), '%H:%i') as time,
  COUNT(1) as c,
  status
GROUP by
  time,
  status
ORDER by
  time
LIMIT
  1000