Skip to content

Commit ef4acb4

Browse files
committed
sql: add routine statement counters for tracking execution metrics
Informs #151173 This commit introduces the following metrics for statements got executed via calling a store procedure or executing a routine: - sql_routine_select_started_count - sql_routine_update_started_count - sql_routine_insert_started_count - sql_routine_delete_started_count - sql_routine_select_count - sql_routine_update_count - sql_routine_insert_count - sql_routine_delete_count The metrics with `started` are for statement that started execution, including those might error during execution. The ones without `started` are those successfully executed. Like the existing counters for sql statements (e.g. sql_select_count), it increments before the changes is committed or aborted in an explicit transaction. These counters are global, as in, calling different routines (i.e. UDF/SPs) will eventually aggregate to the same counter. The labeling of these metrics follows guidelines here: - https://cockroachlabs.slack.com/archives/C063CP41TG9/p1755202224602859 Release note (sql change): This commit introduces the following metrics for statements got executed via calling a store procedure: sql_routine_select_started_count, sql_routine_update_started_count,sql_routine_insert_started_count, sql_routine_delete_started_count,sql_routine_select_count,sql_routine_update_count,sql_routine_insert_count,sql_routine_delete_count.
1 parent 8fcfd5a commit ef4acb4

File tree

11 files changed

+870
-48
lines changed

11 files changed

+870
-48
lines changed

docs/generated/metrics/metrics.yaml

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,166 @@ layers:
533533
derivative: NON_NEGATIVE_DERIVATIVE
534534
how_to_use: The rate of this metric shows how frequently new connections are being established. This can be useful in determining if a high rate of incoming new connections is causing additional load on the server due to a misconfigured application.
535535
essential: true
536+
- name: sql.routine.delete.count
537+
exported_name: sql_routine_delete_count
538+
labeled_name: 'sql.count{query_type: routine-delete}'
539+
description: Number of SQL DELETE statements successfully executed within routine invocation
540+
y_axis_label: SQL Statements
541+
type: COUNTER
542+
unit: COUNT
543+
aggregation: AVG
544+
derivative: NON_NEGATIVE_DERIVATIVE
545+
how_to_use: This high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric's time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.
546+
essential: true
547+
- name: sql.routine.delete.count.internal
548+
exported_name: sql_routine_delete_count_internal
549+
labeled_name: 'sql.count{query_type: routine-delete, query_internal: true}'
550+
description: Number of SQL DELETE statements successfully executed within routine invocation (internal queries)
551+
y_axis_label: SQL Internal Statements
552+
type: COUNTER
553+
unit: COUNT
554+
aggregation: AVG
555+
derivative: NON_NEGATIVE_DERIVATIVE
556+
- name: sql.routine.delete.started.count
557+
exported_name: sql_routine_delete_started_count
558+
labeled_name: 'sql.count{query_type: routine-started-delete}'
559+
description: Number of SQL DELETE statements started within routine invocation
560+
y_axis_label: SQL Statements
561+
type: COUNTER
562+
unit: COUNT
563+
aggregation: AVG
564+
derivative: NON_NEGATIVE_DERIVATIVE
565+
how_to_use: This high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric's time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.
566+
essential: true
567+
- name: sql.routine.delete.started.count.internal
568+
exported_name: sql_routine_delete_started_count_internal
569+
labeled_name: 'sql.count{query_type: routine-started-delete, query_internal: true}'
570+
description: Number of SQL DELETE statements started within routine invocation (internal queries)
571+
y_axis_label: SQL Internal Statements
572+
type: COUNTER
573+
unit: COUNT
574+
aggregation: AVG
575+
derivative: NON_NEGATIVE_DERIVATIVE
576+
- name: sql.routine.insert.count
577+
exported_name: sql_routine_insert_count
578+
labeled_name: 'sql.count{query_type: routine-insert}'
579+
description: Number of SQL INSERT statements successfully executed within routine invocation
580+
y_axis_label: SQL Statements
581+
type: COUNTER
582+
unit: COUNT
583+
aggregation: AVG
584+
derivative: NON_NEGATIVE_DERIVATIVE
585+
how_to_use: This high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric's time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.
586+
essential: true
587+
- name: sql.routine.insert.count.internal
588+
exported_name: sql_routine_insert_count_internal
589+
labeled_name: 'sql.count{query_type: routine-insert, query_internal: true}'
590+
description: Number of SQL INSERT statements successfully executed within routine invocation (internal queries)
591+
y_axis_label: SQL Internal Statements
592+
type: COUNTER
593+
unit: COUNT
594+
aggregation: AVG
595+
derivative: NON_NEGATIVE_DERIVATIVE
596+
- name: sql.routine.insert.started.count
597+
exported_name: sql_routine_insert_started_count
598+
labeled_name: 'sql.count{query_type: routine-started-insert}'
599+
description: Number of SQL INSERT statements started within routine invocation
600+
y_axis_label: SQL Statements
601+
type: COUNTER
602+
unit: COUNT
603+
aggregation: AVG
604+
derivative: NON_NEGATIVE_DERIVATIVE
605+
how_to_use: This high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric's time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.
606+
essential: true
607+
- name: sql.routine.insert.started.count.internal
608+
exported_name: sql_routine_insert_started_count_internal
609+
labeled_name: 'sql.count{query_type: routine-started-insert, query_internal: true}'
610+
description: Number of SQL INSERT statements started within routine invocation (internal queries)
611+
y_axis_label: SQL Internal Statements
612+
type: COUNTER
613+
unit: COUNT
614+
aggregation: AVG
615+
derivative: NON_NEGATIVE_DERIVATIVE
616+
- name: sql.routine.select.count
617+
exported_name: sql_routine_select_count
618+
labeled_name: 'sql.count{query_type: routine-select}'
619+
description: Number of SQL SELECT statements successfully executed within routine invocation
620+
y_axis_label: SQL Statements
621+
type: COUNTER
622+
unit: COUNT
623+
aggregation: AVG
624+
derivative: NON_NEGATIVE_DERIVATIVE
625+
how_to_use: This high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric's time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.
626+
essential: true
627+
- name: sql.routine.select.count.internal
628+
exported_name: sql_routine_select_count_internal
629+
labeled_name: 'sql.count{query_type: routine-select, query_internal: true}'
630+
description: Number of SQL SELECT statements successfully executed within routine invocation (internal queries)
631+
y_axis_label: SQL Internal Statements
632+
type: COUNTER
633+
unit: COUNT
634+
aggregation: AVG
635+
derivative: NON_NEGATIVE_DERIVATIVE
636+
- name: sql.routine.select.started.count
637+
exported_name: sql_routine_select_started_count
638+
labeled_name: 'sql.count{query_type: routine-started-select}'
639+
description: Number of SQL SELECT statements started within routine invocation
640+
y_axis_label: SQL Statements
641+
type: COUNTER
642+
unit: COUNT
643+
aggregation: AVG
644+
derivative: NON_NEGATIVE_DERIVATIVE
645+
how_to_use: This high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric's time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.
646+
essential: true
647+
- name: sql.routine.select.started.count.internal
648+
exported_name: sql_routine_select_started_count_internal
649+
labeled_name: 'sql.count{query_type: routine-started-select, query_internal: true}'
650+
description: Number of SQL SELECT statements started within routine invocation (internal queries)
651+
y_axis_label: SQL Internal Statements
652+
type: COUNTER
653+
unit: COUNT
654+
aggregation: AVG
655+
derivative: NON_NEGATIVE_DERIVATIVE
656+
- name: sql.routine.update.count
657+
exported_name: sql_routine_update_count
658+
labeled_name: 'sql.count{query_type: routine-update}'
659+
description: Number of SQL UPDATE statements successfully executed within routine invocation
660+
y_axis_label: SQL Statements
661+
type: COUNTER
662+
unit: COUNT
663+
aggregation: AVG
664+
derivative: NON_NEGATIVE_DERIVATIVE
665+
how_to_use: This high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric's time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.
666+
essential: true
667+
- name: sql.routine.update.count.internal
668+
exported_name: sql_routine_update_count_internal
669+
labeled_name: 'sql.count{query_type: routine-update, query_internal: true}'
670+
description: Number of SQL UPDATE statements successfully executed within routine invocation (internal queries)
671+
y_axis_label: SQL Internal Statements
672+
type: COUNTER
673+
unit: COUNT
674+
aggregation: AVG
675+
derivative: NON_NEGATIVE_DERIVATIVE
676+
- name: sql.routine.update.started.count
677+
exported_name: sql_routine_update_started_count
678+
labeled_name: 'sql.count{query_type: routine-started-update}'
679+
description: Number of SQL UPDATE statements started within routine invocation
680+
y_axis_label: SQL Statements
681+
type: COUNTER
682+
unit: COUNT
683+
aggregation: AVG
684+
derivative: NON_NEGATIVE_DERIVATIVE
685+
how_to_use: This high-level metric reflects workload volume. Monitor this metric to identify abnormal application behavior or patterns over time. If abnormal patterns emerge, apply the metric's time range to the SQL Activity pages to investigate interesting outliers or patterns. For example, on the Transactions page and the Statements page, sort on the Execution Count column. To find problematic sessions, on the Sessions page, sort on the Transaction Count column. Find the sessions with high transaction counts and trace back to a user or application.
686+
essential: true
687+
- name: sql.routine.update.started.count.internal
688+
exported_name: sql_routine_update_started_count_internal
689+
labeled_name: 'sql.count{query_type: routine-started-update, query_internal: true}'
690+
description: Number of SQL UPDATE statements started within routine invocation (internal queries)
691+
y_axis_label: SQL Internal Statements
692+
type: COUNTER
693+
unit: COUNT
694+
aggregation: AVG
695+
derivative: NON_NEGATIVE_DERIVATIVE
536696
- name: sql.select.count
537697
exported_name: sql_select_count
538698
labeled_name: 'sql.count{query_type: select}'

0 commit comments

Comments
 (0)