0

我正在尝试获取有关客户使用的浏览器类型的数据。我想要一个饼图,显示Chrome用户百分比、Firefox/Mozilla用户百分比、Safari用户百分比和Edge/IE用户百分比。

使用以下查询,我可以列出所有独特的浏览器类型:Chrome57、Chrome59 等...

customEvents
| where timestamp >= ago(7d)
| summarize Count=count(customDimensions.Type) by Browser=tostring(customDimensions.Type)
| project Browser,Count

如何聚合具有相同名称但不同版本的浏览器?例如,将所有 Chrome 浏览器添加到一个巨大的总数中。

4

1 回答 1

0

customDimension.Type最简单的方法是在数据收集步骤中不使用浏览器版本进行登录。如果这不是一个选项,第二个最简单的方法是使用reduce运算符来避免正则表达式字符串操作以仅提取浏览器名称。

如果在投影 customDimensions.Type 之后使用,那么它将自动对匹配字符串(浏览器名称)进行分组,并为它们提供计数以及与通配符匹配的示例浏览器字符串。

句法

T | reduce [kind = ReduceKind] by Expr [with [threshold = Threshold] [, characters = Characters] ]

论据

Expr: An expression that evaluates to a string value.
Threshold: A real literal in the range (0..1). Default is 0.1. For large inputs, threshold should be small.
Characters: A string literal containing a list of characters to add to the list of characters that don't break a term. (For example, if you want aaa=bbbb and aaa:bbb to each be a whole term, rather than break on = and :, use ":=" as the string literal.)
ReduceKind: Specifies the reduce flavor. The only valid value for the time being is source.

退货

此运算符返回一个包含三列(模式、计数和代表)的表,行数与组数一样多。Pattern 是组的模式值,其中 * 用作通配符(表示任意插入字符串),Count 计算操作符的输入中有多少行由该模式表示,而代表是输入中落下的一个值进这个组。

附言

或者,您可以尝试使用正则表达式提取名称(例如,提取任何数字之前的所有内容并将其用作浏览器名称)。

于 2018-09-21T00:16:30.347 回答