I want to count HTTP requests per path along with time. To do this, we use aliyun SLS (a log service) where all all nginx logs reside at, and granafa for display. The expected dashboard should be like:
- x-axis: time
- y-axis: number of requests for a path.
Multi-lines will be in the graph, and each line represents a path.
I follow flow graph
in https://github.com/aliyun/aliyun-log-grafana-datasource-plugin, and the query script is
select to_unixtime(time) as time,path,count from (select time_series(__time__, '1m', '%Y-%m-%d %H:%i', '0') as time,path,count(*) as count from log group by path,time order by time limit 10000)
This works and I can see data output.
But the issue is query string (substring after ? for GET requets)in a path, and paths with different querystrings should be treated the same and counted together instead of treated differently(all query string shold be removed). For example /getinfo?id=12
and /getinfo?id=13
should be treated as the same path, and I should see
/getinfo 2
I also found string
function in https://www.alibabacloud.com/help/en/maxcompute/latest/string-functions#section-ecy-k21-wdb and tried split_part
and rtrim
, something like
select to_unixtime(time) as time, split_part(path, '?', 1),count from (select time_series(__time__, '1m', '%Y-%m-%d %H:%i', '0') as time, split_part(path, '?', 1),count(*) as count from log group by split_part(path, '?', 1),time order by time limit 10000)
but aliyun sls reports .
Thanks if you have better suggestion.