Skip to content

Commit

Permalink
Schema qualify job stats query
Browse files Browse the repository at this point in the history
  • Loading branch information
konskov committed Oct 19, 2022
1 parent fa41abe commit d25fb70
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/telemetry/telemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,24 +302,24 @@ add_errors_by_sqlerrcode(JsonbParseState *parse_state)
MemoryContext old_context = CurrentMemoryContext, spi_context;

const char *command_string = "SELECT "
"job_type, jsonb_object_agg(sqlerrcode, count) "
"job_type, pg_catalog.jsonb_object_agg(sqlerrcode, count) "
"FROM"
"("
" SELECT ("
" CASE "
" WHEN error_data->> \'proc_schema\' = "
"\'_timescaledb_internal\' AND error_data->> \'proc_name\' ~ "
" WHEN error_data OPERATOR(pg_catalog.->>) \'proc_schema\' OPERATOR(pg_catalog.=) "
"\'_timescaledb_internal\' AND error_data OPERATOR(pg_catalog.->>) \'proc_name\' OPERATOR(pg_catalog.~) "
"\'^policy_(retention|compression|reorder|refresh_continuous_"
"aggregate|telemetry|job_error_retention)$\' "
" THEN error_data->> \'proc_name\' "
" THEN error_data OPERATOR(pg_catalog.->>) \'proc_name\' "
" ELSE \'user_defined_action\'"
" END"
" ) as job_type, "
" error_data->> \'sqlerrcode\' as sqlerrcode, "
" COUNT(*) "
" error_data OPERATOR(pg_catalog.->>) \'sqlerrcode\' as sqlerrcode, "
" pg_catalog.COUNT(*) "
" FROM "
" _timescaledb_internal.job_errors "
" WHERE error_data->> \'sqlerrcode\' IS NOT NULL "
" WHERE error_data OPERATOR(pg_catalog.->>) \'sqlerrcode\' IS NOT NULL "
" GROUP BY job_type, error_data->> \'sqlerrcode\' "
" ORDER BY job_type"
") q "
Expand Down Expand Up @@ -402,24 +402,24 @@ add_job_stats_by_job_type(JsonbParseState *parse_state)
const char *command_string =
"SELECT ("
" CASE "
" WHEN j.proc_schema = \'_timescaledb_internal\' AND j.proc_name ~ "
" WHEN j.proc_schema OPERATOR(pg_catalog.=) \'_timescaledb_internal\' AND j.proc_name OPERATOR(pg_catalog.~) "
"\'^policy_(retention|compression|reorder|refresh_continuous_aggregate|telemetry|job_error_"
"retention)$\' "
" THEN j.proc_name::text "
" ELSE \'user_defined_action\'::text "
" end"
") as job_type, "
" sum(total_runs)::bigint as total_runs, "
" sum(total_successes)::bigint as total_successes, "
" sum(total_failures)::bigint as total_failures, "
" sum(total_crashes)::bigint as total_crashes, "
" sum(total_duration) as total_duration, "
" sum(total_duration_failures) as total_duration_failures, "
" max(consecutive_failures)::int as max_consecutive_failures, "
" max(consecutive_crashes)::int as max_consecutive_crashes "
" THEN CAST(j.proc_name AS pg_catalog.text) "
" ELSE \'user_defined_action\' "
" END"
") AS job_type, "
" CAST(pg_catalog.sum(total_runs) AS pg_catalog.int8) as total_runs, "
" CAST(pg_catalog.sum(total_successes) AS pg_catalog.int8) as total_successes, "
" CAST(pg_catalog.sum(total_failures) AS pg_catalog.int8) as total_failures, "
" CAST(pg_catalog.sum(total_crashes) AS pg_catalog.int8) as total_crashes, "
" pg_catalog.sum(total_duration) as total_duration, "
" pg_catalog.sum(total_duration_failures) as total_duration_failures, "
" pg_catalog.max(consecutive_failures) as max_consecutive_failures, "
" pg_catalog.max(consecutive_crashes) as max_consecutive_crashes "
"FROM "
" _timescaledb_internal.bgw_job_stat s "
" JOIN _timescaledb_config.bgw_job j on j.id = s.job_id "
" JOIN _timescaledb_config.bgw_job j on j.id OPERATOR(pg_catalog.=) s.job_id "
"GROUP BY "
"job_type";

Expand Down

0 comments on commit d25fb70

Please sign in to comment.