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。