对数值型字段进行最大值(max),最小值(min),平均值(avg),求和(sum),事件数(count)。
定义:
action_type
: stats
action_body
:
"field": // String:用于计算的字段
action_result
:"count": // Integer:事件数
"min": // Number:最小值
"max": // Number:最大值
"avg": // Number:平均值
"sum": // Number:和
样例:
统计不同HTTP method请求的response length的统计值。
{
"query": {
"method_split_result": {
"terms": {
"field": "apache.method"
},
"group": {
"resp_len_stats_result": {
"stats": {
"field": "apache.resp_len"
}
}
}
}
}
}
{
"result": true,
"total": 9268,
"data": {
"method_split_result": {
"buckets": [
{
"key": "get",
"doc_count": 8723,
"resp_len_stats_result": {
"count": 8723,
"min": 0,
"max": 230979,
"avg": 18230.163131950016,
"sum": 159021713
}
},
{
"key": "post",
"doc_count": 545,
"resp_len_stats_result": {
"count": 545,
"min": 5,
"max": 908,
"avg": 80.67339449541285,
"sum": 43967
}
}
]
}
}
}
统计某个字段的值的去重计数,可用于数值型和非数值型字段。
定义:
action_type
: cardinality
action_body
:
"field": // String:字段名
action_result
:"value": // Integer:结果
样例:
{
"query": {
"referer_cardinality_count": {
"cardinality": {
"field": "apache.referer_domain"
}
},
"top_referer": {
"terms": {
"field": "apache.referer_domain",
"size": 3
}
}
}
}
{
"result": true,
"total": 4463,
"data": {
"referer_cardinality_count": {
"value": 3
},
"top_referer": {
"buckets": [
{
"key": "alltest.rizhiyi.com",
"doc_count": 4262
},
{
"key": "litest.rizhiyi.com",
"doc_count": 119
},
{
"key": "mail.yottabyte.cn",
"doc_count": 2
}
]
}
}
}
按照指定的一组百分比值,得出在值的区间内,在对应百分比位置的字段值,只用于数值型字段。
定义:
action_type
: percentiles
action_result
:
"field": // String:字段名
"percents": // Array[Number]:可选,指定需要的百分比,默认为[1,5,25,50,75,95,99]
action_result
:"values": // Array[{String: Number}]:对应percents的结果
样例:
{
"query": {
"percentiles_default_result": {
"percentiles": {
"field": "apache.resp_len"
}
},
"percentiles_result": {
"percentiles": {
"field": "apache.resp_len",
"percents" : [61.8, 80, 95, 99, 99.9, 100]
}
}
}
}
{
"result": true,
"total": 6020,
"data": {
"percentiles_result": {
"values": {
"61.8": 1576.7485966329975,
"80.0": 10858.026428571426,
"95.0": 132724.74625000003,
"99.0": 200552.81,
"99.9": 230907.54400000002,
"100.0": 253535
}
},
"percentiles_default_result": {
"values": {
"1.0": 0,
"5.0": 0,
"25.0": 25,
"50.0": 1132.7486486486484,
"75.0": 5907.452666666666,
"95.0": 132692.04090909095,
"99.0": 200552.81
}
}
}
}
是percentiles的反向操作,只用于数值型字段。
定义:
action_type
: percentile_ranks
action_body
:
"field": // String:字段名
"values": // Array[Number]:指定要求的字段值
action_result
:"values": // Array[{String: Number}]字段值对应的百分比数字
样例:
{
"query": {
"percentile_rank_result": {
"percentile_ranks": {
"field": "apache.resp_len",
"values": [2000]
}
}
}
}
{
"result": true,
"total": 5905,
"data": {
"percentile_rank_result": {
"values": {
"2000.0": 64.46713125983487
}
}
}
}
因为统计操作多数只针对某个字段进行,一般与其他统计操作相配合得出没被涵盖到的事件数量,可用于数值型和非数值型字段。
定义:
action_type
: missing
action_body
:
"field": // String:字段名
action_result
:"value": // Integer:事件数量
样例:
{
"query": {
"missing_result": {
"missing": {
"field": "apache.referer_domain"
}
},
"cardinality_domain": {
"cardinality": {
"field": "apache.referer_domain"
}
},
"all_domains": {
"terms": {
"field": "apache.referer_domain",
"size": 1
}
}
}
}
{
"result": true,
"total": 5786,
"data": {
"cardinality_domain": {
"value": 1
},
"all_domains": {
"buckets": [
{
"key": "alltest.rizhiyi.com",
"doc_count": 5715
}
]
},
"missing_result": {
"doc_count": 71
}
}
}