From e10a69468c60b1c449e3ba8dd73c89ef6295c101 Mon Sep 17 00:00:00 2001 From: Jennifer Q <66472237+latin-panda@users.noreply.github.com> Date: Fri, 29 Mar 2024 11:37:33 +0700 Subject: [PATCH] chore(#63): documents query to count apdex in a date range (#1332) --- .../database/querying_apdex_telemetry.md | 59 ++++++++++++++++++- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/content/en/apps/guides/database/querying_apdex_telemetry.md b/content/en/apps/guides/database/querying_apdex_telemetry.md index bf286e08c..4079660fd 100644 --- a/content/en/apps/guides/database/querying_apdex_telemetry.md +++ b/content/en/apps/guides/database/querying_apdex_telemetry.md @@ -12,9 +12,9 @@ relatedContent: > Added in `4.7.0`, CHT now records the Apdex (Application Performance Index) that is an open standard for measuring performance of software applications. -Since apdex is part of the [telemetry]({{< ref "apps/guides/performance/telemetry" >}}) system, it is possible to view apdex data directly from CouchDB. However, it is more useful when aggregated across many users, interactions, and/or days. With this in mind, it is typically easier to query the data using SQL from an [analytics database]({{< ref "core/overview/data-flows-for-analytics" >}}). +Since Apdex is part of the [telemetry]({{< ref "apps/guides/performance/telemetry" >}}) system, it is possible to view Apdex data directly from CouchDB. However, it is more useful when aggregated across many users, interactions, and/or days. With this in mind, it is typically easier to query the data using SQL from an [analytics database]({{< ref "core/overview/data-flows-for-analytics" >}}). -An example of an SQL to view the apdex score: +An example of an SQL to view the Apdex score: ``` WITH apdex_telemetry_data AS ( @@ -51,6 +51,59 @@ FROM apdex_scores ORDER BY apdex_score asc; ``` -The SQL query above calculates the Apdex scores for various events recorded in the `useview_telemetry_metrics` table, providing insights into the performance of different aspects of the CHT. +The SQL query above calculates the Apdex scores for various events recorded in the `useview_telemetry_metrics` table, providing insights into the performance of different aspects of the CHT. In some cases, it is helpful to visualize the number of occurrences of each metric in a date range: + +``` +WITH + constants (days, start_date, end_date) AS (VALUES (, , )), + apdex_metrics AS( + SELECT + substring(metric FROM '^(.*):apdex:') AS metric, + SUM(COUNT) AS COUNT + FROM useview_telemetry_metrics, constants + WHERE + metric LIKE '%:apdex:%' + AND period_start BETWEEN constants.start_date::DATE AND constants.end_date::DATE + GROUP BY metric + ), + apdex_result as ( + SELECT + metric, + CASE + WHEN apdex_metrics.metric = 'contact_list:load' THEN * constants.days + WHEN apdex_metrics.metric = 'contact_list:query' THEN * constants.days + WHEN apdex_metrics.metric = 'contact_detail::load' THEN * constants.days + WHEN apdex_metrics.metric = 'contact_detail::load' THEN * constants.days + WHEN apdex_metrics.metric = 'contact_detail::load' THEN * constants.days + WHEN apdex_metrics.metric = 'enketo:contacts::add:render' THEN * constants.days + WHEN apdex_metrics.metric = 'enketo:contacts::add:save' THEN * constants.days + WHEN apdex_metrics.metric = 'enketo:reports::add:render' THEN * constants.days + WHEN apdex_metrics.metric = 'enketo:reports::add:save' THEN * constants.days + WHEN apdex_metrics.metric = 'report_list:load' THEN * constants.days + WHEN apdex_metrics.metric = 'report_list:query' THEN * constants.days + WHEN apdex_metrics.metric = 'report_detail::load' THEN * constants.days + WHEN apdex_metrics.metric = 'tasks:load' THEN * constants.days + WHEN apdex_metrics.metric = 'tasks:refresh' THEN * constants.days + WHEN apdex_metrics.metric = 'enketo:tasks::add:render' THEN * constants.days + WHEN apdex_metrics.metric = 'enketo:tasks::add:save' THEN * constants.days + WHEN apdex_metrics.metric = 'message_list:load' THEN * constants.days + WHEN apdex_metrics.metric = 'messages_detail:load' THEN * constants.days + WHEN apdex_metrics.metric = 'analytics:targets:load' THEN * constants.days + WHEN apdex_metrics.metric = 'boot_time' THEN * constants.days + END AS expected_count, + SUM(apdex_metrics.count) AS actual_count + FROM apdex_metrics, constants + GROUP BY apdex_metrics.metric, constants.days + ) +SELECT + apdex_result.metric, + apdex_result.expected_count, + apdex_result.actual_count, + CASE + WHEN apdex_result.actual_count >= apdex_result.expected_count THEN 'TRUE' ELSE 'FALSE' + END AS meet_expectation +FROM apdex_result +ORDER BY apdex_result.metric ASC +``` Such queries are instrumental in identifying areas of the CHT that may require performance improvements by highlighting how different parts of the application meet user expectations in terms of load times and Apdex score.