跳到主要内容

通用数据指标查询系统

1. 性能指标-通用查询

由于性能数据指标,经常要做多维度多指标交叉查询,所以提供一个指标查询方式,该方式采用JSON语言方式进行描述如下方式所示。

示例

一个指标趋势图的示例:

{
"timePeriod": 180,
"endTime":"2020-02-19 23:10"
"datasource": "APP_BASE_DATA",
"metrics": [
"loadDuration",
"viewDuration",
"slowLoadPercent",
"throughput"
],
"dimensions": [
"timeStr"
],
"orderByExprs": "slowLoadPercent desc",
"havingExprs": "viewDuration>10",
"render":"csv",
"top": {
"metric": "loadDuration",
"direction": "desc",
"dimensions": [
"mobileAppId"
],
"limit": 5
}
}

属性说明

propertydescription是否必选
timePeriod开始时间-结束时间 间隔分钟数yes
endTime截止时间,格式YYYY-MM-DD hh:mm,不指定为当前时间no
datasource指标数据源yes
metrics指标项yes
filters过滤条件,只支持filter1 and filter2yes
dimensions分组维度no
orderByExprs排序表达式,必须为metric中的项no
havingExprs分组过滤表达式,意义参考sql having,字段必须为metricno
render渲染器,支持list,csv,chartno
top二次查询,意为,先基于top进行查询,然后将返回值in,可以理解为in 子查询,常用在报表的topN趋势图中no

DSL->SQL

相当于转换为SQL的示例,非标准SQL模式:

SELECT 
[dimensions],
[metric]
FROM
[datasource]
WHERE
[time]<=[endtime] AND [time]>[endTime-timePeriod] AND [filters] AND [top.dimensions] IN (topQuery)
GROUP BY [dimensions]
HAVING [havingExprs]
ORDER BY [orderByExprs]

渲染器

渲染模型,目前支持以下:

  • list
  • csv
  • chart
  • object
list

简化的json格式:

[
{
"requestCount": "879",
"uriId": "1",
"requestType": "2",
"trafficConsumption": "3",
"responseTime": "3172",
"networkErrorCount": "83",
"requestTypeName": "CDN-自身服务",
"slowCount": "170",
"httpErrorRate": "8.3",
"networkErrorRate": "9.44",
"networkSpeed": "1",
"uriName": "/user",
"throughput": "14.65",
"httpErrorCount": "73"
}
]
csv

csv 表格格式:

timeStr,视图加载毫秒,慢加载占比%,慢展现占比%,视图展现毫秒
2019-4-23 8:00:00,1525,0,0,2430
2019-4-26 8:00:00,987,0,0,2460
2019-4-28 8:00:00,978,0,0,2521
2019-4-30 8:00:00,286,0,0,286
2019-5-5 8:00:00,835,0,0,892
2019-5-6 8:00:00,517,0,0,685
2019-5-10 8:00:00,111,0,0,292
2019-5-13 8:00:00,80,0,0,216
2019-5-14 8:00:00,589,0,0,652

object

和list不同的模式为,会将指标的单位和格式化字符串输出:

[
{
"loadDuration": {
"format": "987",
"label": "视图加载",
"unit": "毫秒",
"value": 987
},
"slowLoadPercent": {
"format": "0",
"label": "慢加载占比",
"unit": "%",
"value": 0
},
"timeStr": 1556236800000,
"throughput": {
"format": "0",
"label": "慢展现占比",
"unit": "%",
"value": 0
},
"viewDuration": {
"format": "2460",
"label": "视图展现",
"unit": "毫秒",
"value": 2460
}
}
]
chart

hightchart 格式的数据样式:

{
"series": [
{
"data": [
{
"x": 1556236800000,
"y": 987,
"tooltip": {
"data": [
{
"unit": "毫秒",
"title": "视图加载",
"value": 987
},
{
"unit": "%",
"title": "慢加载占比",
"value": 0
},
{
"unit": "%",
"title": "慢展现占比",
"value": 0
},
{
"unit": "毫秒",
"title": "视图展现",
"value": 2460
}
],
"title": "04-26 08:00--04-27 08:00"
}
}
],
"name": "视图加载",
"type": "line",
"yAxis": 0,
"zIndex": 1
}
],
"yAxis": [
{
"i18n": "app.unit.ms",
"opposite": false,
"tickUnit": "毫秒"
},
{
"i18n": "app.unit.percent",
"opposite": true,
"tickUnit": "%"
}
]
}

查询示例

时间趋势图
{
"timePeriod": 43200,
"datasource": "APP_BASE_DATA",
"metrics": [
"loadDuration",
"viewDuration",
"slowLoadPercent",
"throughput"
],
"dimensions": [
"timeStr"
],
"havingExprs": "viewDuration>10"
}

TOP5 时间趋势图
{
"timePeriod": 43200,
"datasource": "APP_BASE_DATA",
"filters": [
{
"name": "regionId",
"value": [4811,4812,4813,4814,4815],
"operator": "IN"
}
],
"metrics": [
"loadDuration",
"viewDuration",
"slowLoadPercent"
],
"dimensions": ["timeStr"]
}
TOP10 按慢加载率降序平均耗时>10
{
"timePeriod": 43200,
"datasource": "APP_BASE_DATA",
"metrics": [
"loadDuration",
"viewDuration",
"slowLoadPercent",
"throughput"
],
"dimensions": [
"mobileAppId"
],
"orderByExprs": "slowLoadPercent desc",
"havingExprs": "viewDuration>10",
"limit":10
}

Endpoint

Method: POST
Type: RAW
URL: {{host}}/adhoc/query

Headers

KeyValue
Acceptapplication/json, text/plain, /
Content-Typeapplication/json

Body

{
"timePeriod": {{timePeriod}},
"endTime": {{endTime}},
"datasource": "APP_NETWORK_DATA",
"metrics": [
"responseTime",
"successCount"
],
"dimensions": [
"timeStr",
"hostId"
],
"filters": [
{
"name": "mobileAppId",
"value": [
{{mobileAppId}}
],
"operator": "IN"
},
{
"name": "hostId",
"value": [
0
],
"operator": "!="
}
],
"top": {
"metric": "throughput",
"direction": "desc",
"dimensions": [
"hostId"
],
"limit": 5
},
"limit": -1,
"render": "object"
}

2. 用户体验(启动、页面、操作)

数据源名称

APP_UX_DATA

维度

列名扩展维度含义
timeStr
moduleType数据类型
mobileBusinessIdmobileBusinessName业务线
mobileAppIdmobileAppName应用
mobileAppVersionIdmobileAppVersionName应用版本
manufacturerIdmanufacturerName设备
manufacturerModelIdmanufacturerModelName设备型号
osIdosName系统
osVersionIdosVersionName系统版本
channelIdchannelName渠道
countryIdcountryName国家
regionIdregionName省份
cityIdcityName城市
carrierIdcarrierName运营商
connectTypeIdconnectTypeName接入方式
launchType启动类型
actionType操作类型
actionIdactionName操作名称
actionIdGetViewactionViewName所属页面
actionViewId所属页面
viewType页面类型
viewIdviewName视图名称
viewCompositeIdviewCompositeName页面名称
countyIdcountyName区县

指标

指标项含义
launchCount启动次数
launchInitCount启动初始化次数
launchCreateCount启动构建次数
launchLoadViewCount启动页面加载次数
launchSlowCount启动慢次数
abnormalLaunchCount异常启动
launchCrashRate启动崩溃率
launchNetErrorRate启动网络错误率
launchHttpErrorRate启动HTTP错误率
normalLaunchCount正常启动次数
launchCrashCount启动崩溃次数
launchRequestCount请求次数
launchRequestErrorCount启动错误次数
launchRequestHttpErrorCount启动http错误次数
launchRequestNetErrorCount启动网络错误次数
launchSlowPercent慢首次启动占比
launchStartupTime平均启动时间
launchInitTime平均启动初始化时间
launchCreateTime平均启动构建时间
launchLoadViewTime平均启动页面加载时间
launchStartupTime50启动时间50分位值
launchStartupTime75启动时间75分位值
launchStartupTime95启动时间95分位值
launchStartupTime99启动时间99分位值
viewCount页面次数
normalViewCount正常页面次数
viewSlowInteractiveCount页面慢可交互次数
viewSlowAppearCount页面慢首屏次数
viewInteractiveTime平均可交互时间
viewAppearTime平均首屏时间
viewInteractiveTimeSum可交互时间
viewAppearTimeSum首屏时间
slowInteractiveRate慢可交互占比
slowAppearRate慢首屏占比
viewInteractiveTime50可交互时间50分位值
viewInteractiveTime75可交互时间75分位值
viewInteractiveTime95可交互时间95分位值
viewInteractiveTime99可交互时间99分位值
viewAppearTime50首屏时间50分位值
viewAppearTime75首屏时间75分位值
viewAppearTime95首屏时间95分位值
viewAppearTime99首屏时间99分位值
viewInteractiveTimeHistogram页面可交互时间分布
viewAppearTimeHistogram首屏时间分布
actionCount操作次数
actionFluencyCount操作流畅次数
actionCrashCount操作崩溃次数
actionFailureCount操作失败次数
actionAnrCount操作卡顿次数
actionSlowCount操作慢次数
actionFluencyErrorCount操作流畅错误次数
actionAnrErrorCount操作卡顿错误次数
actionSlowErrorCount操作慢错误次数
actionAvailableCount操作可用次数
actionDurationTime平均操作时间
actionBlockTime平均操作阻塞时间
actionFluencyRate流畅操作占比
actionSlowRate慢操作占比
actionAnrRate卡顿占比
actionCrashRate崩溃操作占比
actionFailureRate失败操作占比
actionaAvailability操作可用性
actionDurationTimeHistogram操作耗时分布
actionBlockTimeHistogram阻塞耗时分布
actionDurationTime50操作时间50分位值
actionDurationTime75操作时间75分位值
actionDurationTime95操作时间95分位值
actionDurationTime99操作时间99分位值

Endpoint

Method: POST
Type: RAW
URL: {{host}}/adhoc/query

Headers

KeyValue
Acceptapplication/json, text/plain, /
Content-Typeapplication/json

Body

{
"timePeriod": {{timePeriod}},
"endTime": {{endTime}},
"datasource": "APP_UX_DATA",
"metrics": [
"launchStartupTime"
],
"dimensions": [

],
"filters": [
{
"name": "countryId",
"value": [
48
],
"groupType": "region"
},
{
"name": "mobileAppId",
"value": [
{{mobileAppId}}
],
"operator": "IN"
},
{
"name": "launchType",
"value": [
1
],
"operator": "IN"
},
{
"name": "moduleType",
"value": [
1
],
"operator": "="
}
],
"render": "list",
"orderByExprs": "launchStartupTime desc"
}

3. 网络请求-性能指标

数据源名称

APP_NETWORK_DATA

说明:扩展维度不可进行过滤和查询。

维度

列名扩展维度含义
timeStr
mobileAppIdmobileAppName应用
mobileAppVersionIdmobileAppVersionName应用版本
mobileBusinessIdmobileBusinessName业务线
manufacturerIdmanufacturerName设备
manufacturerModelIdmanufacturerModelName设备型号
osIdosName系统
osVersionIdosVersionName系统版本
countryIdcountryName国家
regionIdregionName省份
cityIdcityName城市
carrierIdcarrierName运营商
connectTypeIdconnectTypeName接入方式
hostIdhostName请求域名
uriIduriName请求地址
errorTypeerrorTypeName错误类型
errorCodeerrorCodeName错误码
cdnIdcdnNameCDN厂商
hostIp服务端IP
hostCountryIdhostCountryName服务端国家
hostRegionIdhostRegionName服务端省份
hostCityIdhostCityName服务端城市
hostCarrierIdhostCarrierName服务端运营商
bytesTypebytesTypeLabel包大小
protocolType协议类型
channelIdchannelName渠道
hostIpTypehostIpTypeName服务端IP类型
requestTyperequestTypeName服务类型
launchType启动类型
countyIdcountyName区县
hostCountyIdhostCountyName区县

指标

指标项含义
requestCount请求次数
successCount成功请求次数
passCount正常请求次数
slowCount慢请求次数
slowRequestRate慢请求占比
errorCount错误次数
httpErrorCountHTTP错误次数
networkErrorCount网络错误次数
dnsCountDNS次数
tcpCountTCP次数
sslCountSSL次数
responseTimeTotal总响应时间
networkTimeTotal总网络时间
responseTime平均响应时间
dnsTime平均DNS时间
connectTime平均TCP时间
sslTime平均SSL时间
firstPacketTime平均首包时间
remainPacketTime平均剩余包时间
localQueueTime平均客户端时间
networkTime平均网络时间
throughput吞吐率
networkSpeed传输速率
networkTrafficSpeed网络传输速率
totalTrafficConsumption总流量消耗
trafficConsumption平均传输数据量
bytesSend上行流量消耗
bytesReceived下行流量消耗
httpErrorRateHTTP错误率
networkErrorRate网络错误率
requestErrorRate请求错误率
pingSuccessCountping成功次数
pingTime网络延时
packetLossRate丢包率
reuseRate复用率
availability可用性

Endpoint

Method: POST
Type: RAW
URL: {{host}}/adhoc/query

Headers

KeyValueDescription
Acceptapplication/json, text/plain, /
Content-Typeapplication/json

Body

{
"timePeriod": {{timePeriod}},
"endTime": {{endTime}},
"datasource": "APP_NETWORK_DATA",
"metrics": [
"responseTime",
"successCount"
],
"dimensions": [
"timeStr",
"hostId"
],
"filters": [
{
"name": "mobileAppId",
"value": [
{{mobileAppId}}
],
"operator": "IN"
},
{
"name": "hostId",
"value": [
0
],
"operator": "!="
}
],
"top": {
"metric": "throughput",
"direction": "desc",
"dimensions": [
"hostId"
],
"limit": 5
},
"limit": -1,
"render": "list"
}