Global dynamic metrics can dynamically aggregate the data you want by writing metrics SQL, such as statistics on the percentage of current gateway cache hits, or the distribution of request status codes.
Here we provide a practical example of viewing the distribution of status codes.
After clicking the Save button, wait a few minutes for the data to show on the page.
Alternatively, we can also switch to a bar chart or pie chart.
If you want to count the city distribution according to the customer IP, you can write the following metric sql.
select client_city, count(*) as cnt from reqs group by client_city order by cnt desc limit 50
If you want to know which resource is hottest, you can write the following metric sql.
select uri, sum(total_size) as size from reqs group by uri order by size desc limit 10
Yon can also add a where clause to limit the resource you are really care about.
select uri, sum(total_size) as size from reqs where uri like /\bopenresty-\d+(?:\.\d+)+(?:rc\d+)?\.tar\.gz$/ group by uri order by size desc limit 10
limit Nhas a significant impact on performance, please ensure that
Nis less than 15.
More metrics SQL details can be found in this documentation. Metrics SQL
We also provide standard metric aggregates. If no metric has been created, we can click on
Add standard metric aggregates at once button to add these standard metric aggregates quickly.
Here are the introduction of these standard metric aggregates:
With this metric we can see the distribution of status codes.
select status, count(*) from reqs group by status;
With this metric we can see the inbound and outbound traffic.
select sum(upstream_byte_total) as upstream_bytes_total, sum(total_size) as downstream_bytes_total from reqs;
With this metric we can see the total QPS and the number of connections in different states.
select count(*) as qps, avg(writing_conns), avg(reading_conns), avg(waiting_conns), avg(active_conns) from http;
With this metric we can see the distribution of the different cache states.
select sum(total_size) as bytes_total, upstream_cache_status, count(*) from reqs where upstream_cache_status != '' group by upstream_cache_status;