@@ -6,8 +6,8 @@ use crate::{
66 config:: { Application , ReleaseChannel , TeamConfig } ,
77 schema:: {
88 CustomVariable , Dashboard , DashboardBuilder , DataLink , Datasource , FieldConfig ,
9- FieldConfigCustom , FieldConfigDefaults , GridPos , LogOptions , LogPanel , Panel ,
10- PieChartPanel , Target , TimeSeriesPanel , Transformation ,
9+ FieldConfigCustom , FieldConfigDefaults , GridPos , LogOptions , LogPanel , Panel , Target ,
10+ TimeSeriesPanel , Transformation ,
1111 } ,
1212 sql:: Query ,
1313 util:: { Join , UrlBuilder } ,
@@ -83,7 +83,7 @@ fn overview_count_panel(
8383 } ] ,
8484 custom : FieldConfigCustom {
8585 axis_label : "success rate" . into ( ) ,
86- axis_soft_min : 90 ,
86+ axis_soft_min : 99 ,
8787 axis_soft_max : 100 ,
8888 ..FieldConfigCustom :: default ( )
8989 } ,
@@ -110,36 +110,31 @@ fn overview_count_panel(
110110///
111111/// We use subqueries to smooth out the differences between desktop and mobile telemetry.
112112fn desktop_count_query ( channel_expr : String ) -> String {
113- // TODO: switch from `telemetry.sync` to the newer glean ping
114113 format ! (
115114 "\
116- SELECT
117- engine.name as engine_name,
118- $__timeGroup(submission_timestamp, $__interval) as time,
119- SAFE_DIVIDE(
120- -- 100 * success count
121- 100 * COUNTIF(
122- syncs.failure_reason IS NULL
123- AND engine.failure_reason IS NULL
124- AND (engine.incoming IS NOT NULL OR ARRAY_LENGTH(engine.outgoing) > 0)
125- ),
126- -- count success or failures
127- COUNTIF(
128- syncs.failure_reason IS NOT NULL
129- OR engine.failure_reason IS NOT NULL
130- OR (engine.incoming IS NOT NULL OR ARRAY_LENGTH(engine.outgoing) > 0)
131- )
132- ) AS success_rate,
133- FROM telemetry.sync
134- CROSS JOIN UNNEST(payload.syncs) as syncs
135- CROSS JOIN UNNEST(syncs.engines) as engine
136- WHERE normalized_channel = {channel_expr}
137- AND engine.name <> 'extension-storage'
138- AND engine.name <> 'bookmarks'
139- AND $__timeFilter(submission_timestamp)
140- GROUP BY 1, 2
141- ORDER BY engine_name, time"
142- )
115+ WITH counts AS
116+ (SELECT
117+ $__timeGroup(submission_timestamp, $__interval) as time,
118+ JSON_VALUE(engine.name) AS engine_name,
119+ COUNTIF(syncs.failureReason IS NOT NULL OR engine.failureReason IS NOT NULL) as count_total_errors,
120+ COUNTIF(syncs.failureReason IS NULL
121+ AND engine.failureReason IS NULL
122+ AND (engine.incoming IS NOT NULL
123+ OR engine.outgoing IS NOT NULL
124+ OR engine.took IS NOT NULL)) AS count_success,
125+ FROM firefox_desktop.sync
126+ CROSS JOIN UNNEST(JSON_QUERY_ARRAY(metrics.object.syncs_syncs)) as syncs
127+ CROSS JOIN UNNEST(JSON_QUERY_ARRAY(syncs,'$.engines')) AS engine
128+ WHERE metrics IS NOT NULL
129+ AND JSON_VALUE(engine.name) NOT IN ('bookmarks', 'extension-storage')
130+ AND normalized_channel = {channel_expr}
131+ AND $__timeFilter(submission_timestamp)
132+ GROUP BY time, engine_name)
133+ SELECT engine_name,
134+ time,
135+ count_success / (count_success + count_total_errors) * 100 AS success_rate,
136+ FROM counts
137+ ORDER BY time" )
143138}
144139
145140/// Subquery to fetch general sync info for mobile
@@ -184,39 +179,59 @@ GROUP BY 1, 2"
184179
185180fn error_list_count_panel ( config : & TeamConfig ) -> Panel {
186181 let query = Query {
187- select : vec ! [ "message" . into( ) , "COUNT(*) as count" . into( ) ] ,
182+ select : vec ! [
183+ "error" . into( ) ,
184+ "$__timeGroup(submission_timestamp, $__interval) as time" . into( ) ,
185+ "COUNT(*) as count" . into( ) ,
186+ ] ,
188187 where_ : vec ! [
188+ "application='${application}'" . into( ) ,
189189 "engine_name='${engine}'" . into( ) ,
190190 "normalized_channel = '${channel}'" . into( ) ,
191- "$__timeFilter(time )" . into( ) ,
191+ "$__timeFilter(submission_timestamp )" . into( ) ,
192192 ] ,
193193 from : format ! ( "(\n {}\n )" , error_subquery( config) ) ,
194- group_by : Some ( "1" . into ( ) ) ,
194+ group_by : Some ( "1, 2 " . into ( ) ) ,
195195 order_by : Some ( "count DESC" . into ( ) ) ,
196196 ..Query :: default ( )
197197 } ;
198198
199- PieChartPanel {
200- title : "" . into ( ) ,
199+ TimeSeriesPanel {
200+ title : "Error counts " . into ( ) ,
201201 grid_pos : GridPos :: height ( 10 ) ,
202202 datasource : Datasource :: bigquery ( ) ,
203- interval : "30m" . into ( ) ,
204- targets : vec ! [ Target :: timeseries( query. sql( ) ) ] ,
205- ..PieChartPanel :: default ( )
203+ // needs to be fairly large since the total sync count can be low on mobile/nightly
204+ interval : "1d" . into ( ) ,
205+ targets : vec ! [ Target :: table( query. sql( ) ) ] ,
206+ transformations : vec ! [
207+ Transformation :: PartitionByValues {
208+ fields: vec![ "error" . into( ) ] ,
209+ keep_fields: true ,
210+ } ,
211+ Transformation :: RenameByRegex {
212+ regex: "count (.*)" . into( ) ,
213+ rename_pattern: "$1" . into( ) ,
214+ } ,
215+ ] ,
216+ ..TimeSeriesPanel :: default ( )
206217 }
207218 . into ( )
208219}
209220
210221fn error_list_log_panel ( config : & TeamConfig ) -> Panel {
211222 let query = Query {
212- select : vec ! [ "message" . into( ) , "time" . into( ) ] ,
223+ select : vec ! [
224+ "CONCAT(IFNULL(error, 'unknown'), ': ', IFNULL(details, 'unknown')) as message" . into( ) ,
225+ "submission_timestamp" . into( ) ,
226+ ] ,
213227 from : format ! ( "(\n {}\n )" , error_subquery( config) ) ,
214228 where_ : vec ! [
215229 "engine_name='${engine}'" . into( ) ,
216230 "normalized_channel = '${channel}'" . into( ) ,
217- "$__timeFilter(time)" . into( ) ,
231+ "application='${application}'" . into( ) ,
232+ "$__timeFilter(submission_timestamp)" . into( ) ,
218233 ] ,
219- order_by : Some ( "time DESC" . into ( ) ) ,
234+ order_by : Some ( "submission_timestamp DESC" . into ( ) ) ,
220235 limit : Some ( 1000 ) ,
221236 ..Query :: default ( )
222237 } ;
@@ -239,33 +254,61 @@ fn error_list_log_panel(config: &TeamConfig) -> Panel {
239254fn error_subquery ( config : & TeamConfig ) -> String {
240255 let mut queries = vec ! [ ] ;
241256
242- // Desktop needs
243- queries. push ( "\
244- SELECT CONCAT(IFNULL(engine.failure_reason.name, 'unknown'), ': ', IFNULL(engine.failure_reason.error, '')) as message,
245- submission_timestamp as time,
246- engine.name as engine_name,
247- normalized_channel
248- FROM telemetry.sync
249- CROSS JOIN UNNEST(payload.syncs) as syncs
250- CROSS JOIN UNNEST(syncs.engines) as engine
251- WHERE engine.failure_reason IS NOT NULL
252- " . to_string ( ) ) ;
257+ // Desktop
258+ queries. push (
259+ "\
260+ SELECT
261+ 'firefox_desktop' as application,
262+ STRING(engine.name) AS engine_name,
263+ normalized_channel,
264+ JSON_VALUE(engine.failureReason, '$.name') AS error,
265+ JSON_VALUE(engine.failureReason, '$.error') AS details,
266+ submission_timestamp
267+ FROM
268+ firefox_desktop.sync
269+ CROSS JOIN
270+ UNNEST(JSON_QUERY_ARRAY(metrics.object.syncs_syncs)) AS syncs
271+ CROSS JOIN
272+ UNNEST(JSON_QUERY_ARRAY(syncs,'$.engines')) AS engine
273+ WHERE
274+ metrics IS NOT NULL
275+ AND engine.failureReason IS NOT NULL
276+ AND client_info.os NOT IN ('iOS', 'Android')"
277+ . to_string ( ) ,
278+ ) ;
253279
254280 queries. extend (
255281 config
256282 . components
257283 . iter ( )
258284 . flat_map ( |c| c. sync_engines ( ) )
259- . map ( |engine_name| {
260- format ! (
261- "\
262- SELECT CONCAT(failure_reason.key, ': ', failure_reason.value) as message,
263- submission_timestamp as time,
264- '{engine_name}' as engine_name,
265- normalized_channel
266- FROM mozdata.fenix.{engine_name}_sync
267- CROSS JOIN UNNEST(metrics.labeled_string.{engine_name}_sync_v2_failure_reason) as failure_reason"
268- )
285+ . flat_map ( |engine_name| {
286+ [
287+ format ! (
288+ "\
289+ SELECT
290+ 'firefox_android' as application,
291+ '{engine_name}' as engine_name,
292+ normalized_channel,
293+ failure_reason.key as error,
294+ failure_reason.value as details,
295+ submission_timestamp
296+ FROM mozdata.fenix.{engine_name}_sync
297+ CROSS JOIN UNNEST(metrics.labeled_string.{engine_name}_sync_v2_failure_reason) as failure_reason"
298+ ) ,
299+ format ! (
300+ "\
301+ SELECT
302+ 'firefox_ios' as application,
303+ '{engine_name}' as engine_name,
304+ normalized_channel,
305+ failure_reason.key as error,
306+ failure_reason.value as details,
307+ submission_timestamp
308+ FROM mozdata.firefox_ios.{engine_name}_sync
309+ CROSS JOIN UNNEST(metrics.labeled_string.{engine_name}_sync_v2_failure_reason) as failure_reason"
310+ ) ,
311+ ]
269312 } ) ,
270313 ) ;
271314
0 commit comments