Application Insights 队列Application Insights cohorts

队列是具有某种共性的用户、会话、事件或操作集。A cohort is a set of users, sessions, events, or operations that have something in common. 在 Azure Application Insights 中,队列由 Analytics 查询定义。In Azure Application Insights, cohorts are defined by an analytics query. 如果你要反复分析特定的用户或事件集,队列可让你更灵活地准确表达所需的集。In cases where you have to analyze a specific set of users or events repeatedly, cohorts can give you more flexibility to express exactly the set you’re interested in.

队列窗格

队列与基本筛选器Cohorts versus basic filters

队列的使用方式与筛选器类似。Cohorts are used in ways similar to filters. 但是,队列的定义是从自定义分析查询生成的,因此它们的自适应性和复杂性要高得多。But cohorts' definitions are built from custom analytics queries, so they're much more adaptable and complex. 与筛选器不同,队列可以保存,因此可供其他团队成员重复使用。Unlike filters, you can save cohorts so other members of your team can reuse them.

对于尝试了应用中新功能的所有用户,可以定义一个队列。You might define a cohort of users who have all tried a new feature in your app. 可将此队列保存在 Application Insights 资源中。You can save this cohort in your Application Insights resource. 今后可以轻松分析这组保存的特定用户。It's easy to analyze this saved group of specific users in the future.

备注

创建队列后,可以通过“用户”、“会话”、“事件”和“用户流”工具访问队列。After they're created, cohorts are available from the Users, Sessions, Events, and User Flows tools.

示例:参与用户Example: Engaged users

团队将参与用户定义为在给定月份使用你的应用达到五次或五次以上的任何人。Your team defines an engaged user as anyone who uses your app five or more times in a given month. 本部分为这些参与用户定义一个队列。In this section, you define a cohort of these engaged users.

  1. 打开“队列”工具。Open the Cohorts tool.

  2. 选择“模板库”选项卡。 将会看到各种队列的模板集合。Select the Template Gallery tab. You see a collection of templates for various cohorts.

  3. 选择“参与用户 -- 按使用天数”。 Select Engaged Users -- by Days Used.

    此队列有三个参数:There are three parameters for this cohort:

    • Activities:选择要将哪些事件和页面视图计入“用法”。Activities, where you choose which events and page views count as “usage.”
    • Period:月份的定义。Period, the definition of a month.
    • UsedAtLeastCustom:用户需要在某个周期内使用某个对象多少次,才能将该用户算作参与用户。UsedAtLeastCustom, the number of times users need to use something within a period to count as engaged.
  4. 请将 UsedAtLeastCustom 更改为 5 天以上,并将 Period 保留为默认 28 天。Change UsedAtLeastCustom to 5+ days, and leave Period on the default of 28 days.

    参与用户

    现在,此队列代表在过去 28 天内 5 个独立的日期通过任何自定义事件或页面视图发送的所有用户 ID。Now this cohort represents all user IDs sent with any custom event or page view on 5 separate days in the past 28.

  5. 选择“保存” 。Select Save.

    提示

    为队列命名,例如“Engaged Users (5+ Days)”。Give your cohort a name, like “Engaged Users (5+ Days).” 根据是否希望对此 Application Insights 资源拥有访问权限的其他人查看此队列,将此队列保存到“我的报告”或“共享报告”中。Save it to “My reports” or “Shared reports,” depending on whether you want other people who have access to this Application Insights resource to see this cohort.

  6. 选择“返回库”。 Select Back to Gallery.

此队列有哪些作用?What can you do by using this cohort?

打开“用户”工具。Open the Users tool. 在“显示”下拉框中,选择在“用户属于...”下创建的队列。 In the Show drop-down box, choose the cohort you created under Users who belong to.

现已根据此用户队列筛选“用户”工具:Now the Users tool is filtered to this cohort of users:

根据特定的队列筛选“用户”窗格

需要注意几个要点:A few important things to notice:

  • 不能通过普通的筛选器创建此集。You can't create this set through normal filters. 日期逻辑更高级。The date logic is more advanced.
  • 可以使用“用户”工具中的正常筛选器进一步筛选此队列。You can further filter this cohort by using the normal filters in the Users tool. 因此,尽管该队列是基于 28 天期限定义的,但仍可以在“用户”工具中将时间范围调整为 30、60 或 90 天。So although the cohort is defined on 28-day windows, you can still adjust the time range in the Users tool to be 30, 60, or 90 days.

这些筛选器支持更复杂的问题,而通过查询生成器无法表达这样的问题。These filters support more sophisticated questions that are impossible to express through the query builder. 例如,对于在过去 28 天参与的人员, 他们在过去 60 天的行为如何?An example is people who were engaged in the past 28 days. How did those same people behave over the past 60 days?

示例:事件队列Example: Events cohort

还可以创建事件队列。You can also make cohorts of events. 在本部分,我们将定义一个事件队列和页面视图,In this section, you define a cohort of the events and page views. 然后了解如何从其他工具使用它们。Then you see how to use them from the other tools. 此队列可以定义一组被团队视为活动用法的事件,或者定义一组与特定新功能相关的事件。 This cohort might define a set of events that your team considers active usage or a set related to a certain new feature.

  1. 打开“队列”工具。Open the Cohorts tool.

  2. 选择“模板库”选项卡。 将会看到各种队列的模板集合。Select the Template Gallery tab. You’ll see a collection of templates for various cohorts.

  3. 选择“事件选取器”。 Select Events Picker.

    事件选取器的屏幕截图

  4. 在“活动”下拉框中,选择想要添加到队列中的事件。 In the Activities drop-down box, select the events you want to be in the cohort.

  5. 保存队列并为其命名。Save the cohort and give it a name.

示例:在其中修改查询的活动用户Example: Active users where you modify a query

前面两个队列是使用下拉框定义的。The previous two cohorts were defined by using drop-down boxes. 但是,我们也可以使用 Analytics 查询来定义队列,以获得全面灵活性。But you can also define cohorts by using analytics queries for total flexibility. 让我们探讨如何为中国的用户创建队列。To see how, create a cohort of users from the China.

演练“队列”工具用法的动画

  1. 打开“队列”工具,依次选择“模板库”选项卡、“空白用户队列”。 Open the Cohorts tool, select the Template Gallery tab, and select Blank Users cohort.

    空白用户队列

    有三个部分:There are three sections:

    • 一个 Markdown 文本部分,可在其中为其他团队成员更详细地描述该队列。A Markdown text section, where you describe the cohort in more detail for others on your team.

    • 一个参数部分,可在其中创建自己的参数,例如 Activities,以及前面两个示例中的其他下拉框。A parameters section, where you make your own parameters, like Activities and other drop-down boxes from the previous two examples.

    • 一个查询部分,可在其中使用分析查询定义队列。A query section, where you define the cohort by using an analytics query.

      在查询部分编写一个分析查询In the query section, you write an analytics query. 该查询选择描述所要定义的队列的行集。The query selects the certain set of rows that describe the cohort you want to define. 然后,“队列”工具将在查询中隐式添加一个“| summarize by user_Id”子句。The Cohorts tool then implicitly adds a “| summarize by user_Id” clause to the query. 表中查询的下面提供了此数据的预览,使你能够确保查询返回结果。This data is previewed below the query in a table, so you can make sure your query is returning results.

      备注

      如果看不到查询,请尝试调整部分的大小,以增加其高度并显示查询。If you don’t see the query, try resizing the section to make it taller and reveal the query. 本部分开头的 .gif 动画演示了大小调整行为。The animated .gif at the beginning of this section illustrates the resizing behavior.

  2. 将以下文本复制并粘贴到查询编辑器中:Copy and paste the following text into the query editor:

    union customEvents, pageViews
    | where client_CountryOrRegion == "China East"
    
  3. 选择“运行查询”。 Select Run Query. 如果表中未显示用户 ID,请更改为应用程序用户所在的国家/地区。If you don't see user IDs appear in the table, change to a country/region where your application has users.

  4. 保存并命名队列。Save and name the cohort.

常见问题Frequently asked questions

我已定义某些国家/地区的用户的队列。当我在“用户”工具中将此队列与仅基于该国家/地区设置筛选器进行比较时,看到了不同的结果。为什么?I’ve defined a cohort of users from a certain country/region. When I compare this cohort in the Users tool to just setting a filter on that country/region, I see different results. Why?

队列与筛选器有所不同。Cohorts and filters are different. 假设你为英国的用户创建了一个队列(类似于上述示例中的定义),并将结果与设置筛选器“国家或地区 = 中国东部”进行比较。Suppose you have a cohort of users from the China East (defined like the previous example), and you compare its results to setting the filter “Country or region = China East.”

  • 队列版本将显示在当前时间范围内从中国东部发送了一个或多个事件的用户的所有事件。The cohort version shows all events from users who sent one or more events from the China East in the current time range. 如果按国家或地区拆分,可能会看到许多国家和地区。If you split by country or region, you likely see many countries and regions.
  • 筛选器版本只显示来自中国的事件。The filters version only shows events from the China East. 不过,如果按国家或地区拆分,则只会看到“中国东部”。But if you split by country or region, you see only the China East.

了解详细信息Learn more