公告
{start_time}、{end_time}:通常通过 CLS 时间选择器设置;仅在确有需要时再补充显式时间戳过滤条件。{host} :域名{streamname}{client_ip}{interval}(例如 1 minute / 5 minute,请与您的 CLS SQL 语法保持一致。)type:"lvb"and host:"{host}"and streamname:"{streamname}"| selecthistogram(cast(__TIMESTAMP__ as timestamp), interval 1 minute) as analytic_time,sum(case when http_code = 200 then 1 else 0 end) as http_code200,sum(case when http_code >= 400 and http_code < 500 then 1 else 0 end) as http_code4XX,sum(case when http_code >= 500 then 1 else 0 end) as http_code5XXgroup by analytic_timeorder by analytic_timelimit 1000

type:"lvb"| SELECThost,COUNT(*) AS req_total,COUNT_IF(http_code >= 400 AND http_code < 500) AS req_4xx,COUNT_IF(http_code >= 500 AND http_code < 600) AS req_5xxGROUP BY hostORDER BY req_5xx DESC, req_4xx DESCLIMIT 200

process_time 平均值/最大值(秒)。type:"lvb" and host:"{host}" and http_code=200 and streamname:"{streamname}"| select histogram( cast(__TIMESTAMP__ as timestamp),interval 1 minute) as analytic_time,avg(process_time)/1000.0 as process_time_secgroup by analytic_timeorder by analytic_timelimit 1000

rttrtt 字段本身已是 ms)。type:"lvb" and host:"{host}" and http_code=200 and streamname:"{streamname}"| select histogram( cast(__TIMESTAMP__ as timestamp),interval 1 minute) as analytic_time,avg( if(rtt='-', NULL, cast(rtt as double)) )/1000.0 as avg_rtt_msgroup by analytic_timeorder by analytic_timelimit 1000
lost_ratetype:"lvb"| SELECThistogram(CAST(__TIMESTAMP__ AS timestamp), interval 1 minute) AS time,host,AVG(IF(lost_rate = '-', NULL, CAST(lost_rate AS double))) AS avg_lost_rateGROUP BY time, hostORDER BY timeLIMIT 1000
host + request_counttype:"lvb"| selecthistogram(CAST(__TIMESTAMP__ AS timestamp), interval 1 minute) AS time,host,count(*) as req_countgroup by time, hostorder by timelimit 1000

url,请替换为实际字段名(例如 request_url、uri、path)。type:"lvb"| selecthistogram(CAST(__TIMESTAMP__ AS timestamp), interval 1 minute) AS time,host,casewhen url like '%.flv%' then 'flv'when url like '%rtmp%' then 'rtmp'else 'other'end as protocol,count(*) as req_countgroup by time, host, protocolorder by timelimit 1000

avg/max process_time*| SELECThistogram(CAST(__TIMESTAMP__ AS timestamp), interval {interval}) AS time,host,AVG(process_time) AS avg_process_time,MAX(process_time) AS max_process_timeGROUP BY time, hostORDER BY timeLIMIT 1000

type:"lvb"| SELECThistogram(cast(__TIMESTAMP__ AS timestamp), interval 1 minute) AS time,host,SUM(IF(http_code >= 400 AND http_code < 600, 1, 0)) AS err_count,SUM(IF(http_code >= 400 AND http_code < 600, 1, 0)) * 1.0 / COUNT(*) AS err_rateGROUP BY time, hostORDER BY timeLIMIT 1000

type:"lvb"AND host:"{host}"AND streamname:"{streamname}"AND client_ip:"{client_ip}"| SELECThistogram(CAST(__TIMESTAMP__ AS timestamp), interval {interval}) AS time,client_ip,COUNT(*) AS req_count,ROUND(COUNT_IF(http_code = 200) * 100.0 / COUNT(*), 2) AS success_rate_pct,COUNT_IF(http_code >= 400 AND http_code < 500) AS err_4xx,COUNT_IF(http_code >= 500 AND http_code < 600) AS err_5xx,AVG(IF(rtt = '-', NULL, CAST(rtt AS DOUBLE))) / 1000.0 AS avg_rtt_ms,AVG(IF(lost_rate = '-', NULL, CAST(lost_rate AS DOUBLE))) AS avg_lost_rateGROUP BY time, client_ipORDER BY timeLIMIT 1000
{interval} = 1m(60 秒)。{interval} 改为 5m,请将除数从 60 调整为 300。*| SELECThistogram(CAST(__TIMESTAMP__ AS timestamp), interval 1 minute) AS time,CONCAT(host, ' | ', streamname) AS host_stream,ROUND(SUM(size) * 8 / 60.0 / 1000, 2) AS bitrate_kbpsGROUP BY time, host_streamORDER BY timeLIMIT 1000
*| SELECThistogram(CAST(__TIMESTAMP__ AS timestamp), interval 1 minute) AS time,host,ROUND(SUM(size) * 8 / 60.0 / 1000 / 1000, 3) AS avg_bandwidth_mbpsGROUP BY time, hostORDER BY timeLIMIT 1000
.flv / .m3u8)。.m3u8 还是 .ts 分片上。.m3u8 返回 404,大概率说明流不存在、未在直播中,或路径错误。.ts 返回 404,通常表示客户端请求了当前播放位置下不存在的分片(常见原因包括播放列表陈旧、代理缓存问题,或 seek 到可用分片窗口之外)。lost_rate 是主要异常指标,很可能是观众侧丢包或下行网络不稳定(lost_rate 仅在 type=leb 时有效)。type=leb,观察 lost_rate 和 rtt 的趋势。prov / isp / server_region 拆分,确认丢包是否集中在特定地域/运营商。client_ip 和精确时间范围筛选,重点查看 http_code。rtt 和 lost_rate(仅 LEB 有效字段;type=leb)。rtt / lost_rate 高,但大多数请求为 200,更可能是客户端网络质量问题(Wi-Fi / ISP / 路由)。client_ip 过滤条件)。文档反馈