OpenResty Edge 的内置动态指标
标准动态指标
每秒请求数
select count(*) /60.0 as qps
from http;
名称:qps_connections
描述:每秒请求数 QPS(Queries Per Second),统计服务器每秒查询的数量。
每分钟请求数
select count(*) as qpm
from http;
名称:qpm_connections
描述:统计服务器每分钟查询的数量。
状态码分布
select status, count(*)
from reqs
group by status;
名称:status_code_count
描述:统计状态码的分布情况。
连接数
select sum(writing_conns), sum(reading_conns), sum(waiting_conns), sum(active_conns)
from http;
名称:connections
描述:统计连接数,包括 writing,reading,reading 和 active 连接的数量。
流量 Top 10 的 URI
select uri, sum(total_size) as size
from reqs
group by uri
order by size desc
limit 10;
名称:uri_traffic_top_10
描述:统计流量排名前 10 的 URI。
访问量 Top 10 的 URI
select uri, count(*) as count
from reqs
group by uri
order by count desc
limit 10;
名称:uri_accesses_top_10
描述:统计访问量排名前 10 的 URI。
平均延时 Top 10 的 URI
select uri, avg(latency_ms) as latency
from reqs
group by uri
order by latency desc
limit 10;
名称:average_latency_uri
描述:统计平均延时排名前 10 的 URI。
HTTP 代理缓存命中率和丢失率
select sum(total_size) as bytes_total, upstream_cache_status, count(*)
from reqs
where upstream_cache_status != ''
group by upstream_cache_status;
名称:cache_hit_ratio
描述:统计 HTTP 代理缓存的命中率和丢失率,例如 hit, miss, bypass, updating, revalidated, stale, expired 等情况。
响应压缩
select resp_is_compressed, count(*)
from reqs
group by resp_is_compressed;
名称:response_compressed
描述:统计响应压缩情况,我们可以看到压缩和未压缩的数据。
HTTP 版本
select http_ver, count(*)
from reqs
group by http_ver;
名称:http_version
描述:HTTP 版本分布情况,如 HTTP/1.0, HTTP/1.1, HTTP/2, HTTP/3 等的数据。
SSL 加密连接
select is_ssl, count(*)
from reqs
group by is_ssl;
名称:ssl_encrypted_connections
描述:统计 SSL 加密连接的分布情况。
Keepalive 连接
select keepalive, count(*)
from reqs
group by keepalive;
名称:keepalive_distribution
描述:统计连接 keepalive 的分布情况。
流量 Top 10 的客户端城市
select client_city, count(*) as count
from reqs
group by client_city
order by count desc
limit 10;
名称:client_city_traffic_top_10
描述:统计流量排名前 10 的客户端城市。
流量 Top 10 的客户端 IP
select client_ip, sum(total_size) as size
from reqs
group by client_ip
order by size desc
limit 10;
名称:client_ip_traffic_top_10
描述:统计流量排名前 10 的客户端 IP。
请求量 Top 10 的客户端 IP
select client_ip, count(*) as count
from reqs
group by client_ip
order by count desc
limit 10;
名称:client_ip_accesses_top_10
描述:统计请求量排名前 10 的客户端 IP。
平均延时 Top 10 的客户端 IP
select client_ip, avg(latency_ms) as latency
from reqs
group by client_ip
order by latency desc
limit 10;
名称:average_latency_client_ip
描述:统计平均延时排名前 10 的客户端 IP。
请求数流量地图
select count(*), client_city, client_latitude, client_longtitude, server_city, server_latitude, server_longtitude
from reqs
group by client_city, client_latitude, client_longtitude, server_city, server_latitude, server_longtitude;
名称:req_cnt_traffic
描述:以地图的形式展示全球请求数。
请求大小流量地图
select sum(total_size), client_city, client_latitude, client_longtitude, server_city, server_latitude, server_longtitude
from reqs
group by client_city, client_latitude, client_longtitude, server_city, server_latitude, server_longtitude;
名称:total_sz_traffic
描述:以地图的形式展示全球的请求流量。
响应总大小流量地图
select sum(resp_size), client_city, client_latitude, client_longtitude, server_city, server_latitude, server_longtitude
from reqs
group by client_city, client_latitude, client_longtitude, server_city, server_latitude, server_longtitude;
名称:total_resp_sz_traffic
描述:以地图的形式展示全球的响应流量。
平均延时 Top 10 的上游地址
select upstream_addr, avg(upstream_total_time_ms) as latency
from reqs
group by upstream_addr
order by latency desc
limit 10;
名称:average_latency_upstream_addr
描述:统计平均延时排名前 10 的上游地址。
WAF 指标
攻击类型 Top 10
select unnest(hit_types) as hit_type, count(*) as count
from waf_hits
where hit_status is true
group by hit_type order by count desc limit 10;
名称:waf_attack_types_top_10
描述:统计排名前 10 的攻击类型。
攻击来源 Top 10 的客户端 IP
select client_ip, count(*) as count
from reqs left join waf_hits
where hit_status is true
group by client_ip order by count desc limit 10;
名称:waf_client_ips_attack_source_top_10
描述:统计攻击来源排名前 10 的客户端 IP。
攻击来源 Top 10 的客户端 ISP
select client_isp, count(*) as count
from reqs left join waf_hits
where hit_status is true
group by client_isp order by count desc limit 10;
名称:waf_client_isps_attack_source_top_10
描述:统计攻击来源排名前 10 的客户端 ISP(互联网服务提供商)。
攻击请求 Top 10 的 URI
select ngx_var('orig_uri') as uri, count(*) as count
from reqs left join waf_hits
where hit_status is true
group by uri order by count desc limit 10;
名称:waf_attack_requests_top_10
描述:统计攻击请求排名前 10 的 URI。
攻击请求 Top 10 的域名
select host, count(*) as count
from reqs left join waf_hits
where hit_status is true
group by host order by count desc limit 10;
名称:waf_attack_hosts_top_10
描述:统计攻击请求排名前 10 的域名。
CC 指标
延迟和拒绝的请求
select limit_traffic_status, count(*) as count
from reqs
where limit_traffic_status != ''
group by limit_traffic_status;
名称:cc_delayed_and_blocked_requests
描述:统计延迟和拒绝的请求。
被延迟或拒绝请求的 Top 10 URI
select ngx_var('orig_uri') as uri, count(*) as count
from reqs
where limit_traffic_status != ''
group by uri order by count desc limit 10;
名称:cc_top_10_uri_delayed_and_blocked_requests
描述:统计被延迟或拒绝请求排名前 10 URI。
被延迟请求的 Top 10 URI
select ngx_var('orig_uri') as uri, count(*) as count
from reqs
where limit_traffic_status = 'delay'
group by uri order by count desc limit 10;
名称:cc_top_10_uri_delayed_requests
描述:统计被延迟请求排名前 10 的 URI。
被拒绝请求的 Top 10 URI
select ngx_var('orig_uri') as uri, count(*) as count
from reqs
where limit_traffic_status = 'block'
group by uri order by count desc limit 10;
名称:cc_top_10_uri_blocked_requests
描述:统计被拒绝请求排名前 10 的 URI。
被延迟或拒绝请求的 Top 10 域名
select host, count(*) as count
from reqs
where limit_traffic_status != ''
group by host order by count desc limit 10;
名称:cc_top_10_host_delayed_and_blocked_requests
描述:统计被延迟或拒绝请求排名前 10 的域名。
被延迟请求的 Top 10 域名
select host, count(*) as count
from reqs
where limit_traffic_status = 'delay'
group by host order by count desc limit 10;
名称:cc_top_10_host_delayed_requests
描述:统计被延迟请求排名前 10 的域名。
被拒绝请求的 Top 10 域名
select host, count(*) as count
from reqs
where limit_traffic_status = 'block'
group by host order by count desc limit 10;
名称:cc_top_10_host_blocked_requests
描述:统计被拒绝请求排名前 10 的域名。
被延迟或拒绝请求的 Top 10 客户端 IP
select client_ip, count(*) as count
from reqs
where limit_traffic_status != ''
group by client_ip order by count desc limit 10;
名称:cc_top_10_client_ips_delayed_and_blocked_requests
描述:统计被延迟或拒绝请求排名前 10 的客户端 IP。
被延迟请求的 Top 10 客户端 IP
select client_ip, count(*) as count
from reqs
where limit_traffic_status = 'delay'
group by client_ip order by count desc limit 10;
名称:cc_top_10_client_ips_delayed_requests
描述:统计被延迟请求排名前 10 的客户端 IP。
被拒绝请求的 Top 10 客户端 IP
select client_ip, count(*) as count
from reqs
where limit_traffic_status = 'block'
group by client_ip order by count desc limit 10;
名称:cc_top_10_client_ips_blocked_requests
描述:统计被拒绝请求排名前 10 客户端 IP。
平均延时 Top 10 被延时的 URI
select ngx_var('orig_uri') as uri, avg(latency_ms) as count
from reqs
where limit_traffic_status = 'delay'
group by uri order by count desc limit 10;
名称:cc_top_10_delayed_uris_by_average_latency
描述:统计平均延时排名前 10 的被延时的 URI。