@@ -19,12 +19,14 @@ package google.cloud.databasecenter.v1beta;
1919import "google/api/annotations.proto" ;
2020import "google/api/client.proto" ;
2121import "google/api/field_behavior.proto" ;
22+ import "google/api/resource.proto" ;
2223import "google/cloud/databasecenter/v1beta/affiliation.proto" ;
2324import "google/cloud/databasecenter/v1beta/machine_config.proto" ;
2425import "google/cloud/databasecenter/v1beta/maintenance.proto" ;
2526import "google/cloud/databasecenter/v1beta/metric_data.proto" ;
2627import "google/cloud/databasecenter/v1beta/product.proto" ;
2728import "google/cloud/databasecenter/v1beta/signals.proto" ;
29+ import "google/protobuf/duration.proto" ;
2830import "google/type/date.proto" ;
2931
3032option csharp_namespace = "Google.Cloud.DatabaseCenter.V1Beta" ;
@@ -75,6 +77,23 @@ service DatabaseCenter {
7577 };
7678 }
7779
80+ // AggregateQueryStats provides database resource query execution statistics.
81+ rpc AggregateQueryStats (AggregateQueryStatsRequest )
82+ returns (AggregateQueryStatsResponse ) {
83+ option (google.api.http ) = {
84+ post : "/v1beta/{parent=organizations/*}:aggregateQueryStats"
85+ body : "*"
86+ additional_bindings {
87+ post : "/v1beta/{parent=folders/*}:aggregateQueryStats"
88+ body : "*"
89+ }
90+ additional_bindings {
91+ post : "/v1beta/{parent=projects/*}:aggregateQueryStats"
92+ body : "*"
93+ }
94+ };
95+ }
96+
7897 // QueryIssues provides a list of issues and recommendations
7998 // that a user has access to and that are within the requested scope.
8099 rpc QueryIssues (QueryIssuesRequest ) returns (QueryIssuesResponse ) {
@@ -487,6 +506,80 @@ message AggregateIssueStatsRequest {
487506 [(google.api.field_behavior ) = OPTIONAL ];
488507}
489508
509+ // AggregateQueryStatsRequest represents the input to the AggregateQueryStats
510+ // method.
511+ message AggregateQueryStatsRequest {
512+ // Required. Parent can be a project, a folder, or an organization. The search
513+ // is limited to the resources within the `parent`.
514+ //
515+ // The allowed values are:
516+ //
517+ // * projects/{PROJECT_ID} (e.g., "projects/foo-bar")
518+ // * projects/{PROJECT_NUMBER} (e.g., "projects/12345678")
519+ // * folders/{FOLDER_NUMBER} (e.g., "folders/1234567")
520+ // * organizations/{ORGANIZATION_NUMBER} (e.g., "organizations/123456")
521+ string parent = 1 [(google.api.field_behavior ) = REQUIRED ];
522+
523+ // Optional. The expression to order the results by.
524+ // Example: `order_by="execution_count"`
525+ // Example: `order_by="execution_count desc"`
526+ // Supported order by fields are `execution_count`, `rows_processed`,
527+ // `total_cpu_time`, `avg_cpu_time`.
528+ string order_by = 2 [(google.api.field_behavior ) = OPTIONAL ];
529+
530+ // Optional. The expression to filter resources.
531+ //
532+ // Supported fields are: `full_resource_name`, `resource_type`, `container`,
533+ // `product.type`, `product.engine`, `product.version`, `location`,
534+ // `labels`, `issues`, fields of availability_info,
535+ // data_protection_info,'resource_name', etc.
536+ //
537+ // The expression is a list of zero or more restrictions combined via logical
538+ // operators `AND` and `OR`. When `AND` and `OR` are both used in the
539+ // expression, parentheses must be appropriately used to group the
540+ // combinations.
541+ //
542+ // Example: `location="us-east1"`
543+ // Example: `container="projects/123" OR container="projects/456"`
544+ // Example: `(container="projects/123" OR
545+ // container="projects/456") AND location="us-east1"`
546+ // Additional specific fields for query stats are: `metric_window`,
547+ // `query_hash`, `normalized_query`.
548+ // Example: `metric_window="LAST_ONE_DAY"`
549+ // (Possible values for `metric_window` are: `LAST_ONE_DAY`,
550+ // `LAST_ONE_WEEK`, `LAST_TWO_WEEKS`)
551+ // Example: `query_hash="12345678"`
552+ // Example: `normalized_query="SELECT * FROM table"`
553+ string filter = 3 [(google.api.field_behavior ) = OPTIONAL ];
554+
555+ // Optional. If unspecified, at most 100 query stats will be returned.
556+ // The maximum value is 1000; values above 1000 will be coerced to 1000.
557+ int32 page_size = 4 [(google.api.field_behavior ) = OPTIONAL ];
558+
559+ // Optional. A page token, received from a previous
560+ // `AggregateQueryStatsRequest` call. Provide this to retrieve the subsequent
561+ // page. All parameters except page_token should match the parameters in the
562+ // call that provided the page token.
563+ string page_token = 5 [(google.api.field_behavior ) = OPTIONAL ];
564+ }
565+
566+ // The response message containing relevant query stats
567+ // for database resources.
568+ message AggregateQueryStatsResponse {
569+ // List of query stats where each group contains stats for resources having a
570+ // particular combination of relevant query stats.
571+ repeated QueryStatsInfo query_stats = 1 ;
572+
573+ // A token that can be sent as `page_token` to retrieve the next page.
574+ // If this field is omitted, there are no subsequent pages.
575+ string next_page_token = 2 ;
576+
577+ // Unordered list. List of unreachable regions from where data could not be
578+ // retrieved.
579+ repeated string unreachable = 3
580+ [(google.api.field_behavior ) = UNORDERED_LIST ];
581+ }
582+
490583// The response message containing one of more group of relevant health issues
491584// for database resources.
492585message AggregateIssueStatsResponse {
@@ -652,6 +745,93 @@ message AggregateFleetRequest {
652745 [(google.api.field_behavior ) = OPTIONAL ];
653746}
654747
748+ // QueryStatsInfo contains the aggregated and detailed query stats for a
749+ // particular combination of relevant query stats for queries having same
750+ // normalized query.
751+ message QueryStatsInfo {
752+ // Aggregated query stats for the resources for same normalized query.
753+ QueryStats aggregated_query_stats = 1 ;
754+
755+ // List of query stats for the resources in the group.
756+ // This stats is stats at resource level for the resources having same
757+ // normalized query.
758+ repeated QueryStats query_stats = 2 ;
759+ }
760+
761+ // ResourceId contains the identifier for a database resource,
762+ // including the full resource name, resource type, and product.
763+ message ResourceId {
764+ // The full resource name of the resource.
765+ string full_resource_name = 1 ;
766+
767+ // The type of the resource.
768+ // sqladmin.googleapis.com/Instance
769+ // alloydb.googleapis.com/Cluster
770+ // alloydb.googleapis.com/Instance
771+ string resource_type = 2 ;
772+
773+ // The product of the resource, including the type, engine, and version.
774+ Product product = 3 ;
775+ }
776+
777+ // QueryStats contains the stats for a particular combination of query_hash,
778+ // query_string and resource_type.
779+ message QueryStats {
780+ // The query hash of the query.
781+ string query_hash = 1 ;
782+
783+ // The query string is normalized query without any PII data.
784+ string normalized_query = 2 ;
785+
786+ // The type of the resource.
787+ // sqladmin.googleapis.com/Instance
788+ // alloydb.googleapis.com/Cluster
789+ // alloydb.googleapis.com/Instance
790+ string resource_type = 4 [(google.api.resource_reference ) = { type : "*" }];
791+
792+ // The resource ids for which the query stats are collected.
793+ repeated ResourceId resource_ids = 5 ;
794+
795+ // Metrics related to the query performance.
796+ QueryMetrics query_metrics = 6 ;
797+
798+ // Information about inefficient query.
799+ InefficientQueryInfo inefficient_query_info = 7 ;
800+ }
801+
802+ // QueryMetrics contains the metrics related to the query execution.
803+ message QueryMetrics {
804+ // Enum to represent the window over which the metrics are aggregated.
805+ enum MetricsWindow {
806+ // Unspecified. Default value.
807+ METRICS_WINDOW_UNSPECIFIED = 0 ;
808+
809+ // Metrics are aggregated over the last 1 day.
810+ LAST_ONE_DAY = 1 ;
811+
812+ // Metrics are aggregated over the last 7 days.
813+ LAST_ONE_WEEK = 2 ;
814+
815+ // Metrics are aggregated over the last 14 days.
816+ LAST_TWO_WEEKS = 3 ;
817+ }
818+
819+ // The number of times the query was executed.
820+ int64 execution_count = 1 ;
821+
822+ // The average execution period of the query across all runs.
823+ google.protobuf.Duration avg_cpu_time = 2 ;
824+
825+ // The total CPU time consumed by the query across all runs.
826+ google.protobuf.Duration total_cpu_time = 3 ;
827+
828+ // The average number of rows processed by the query across all runs.
829+ int64 rows_processed = 4 ;
830+
831+ // The window over which the metrics are aggregated.
832+ MetricsWindow metrics_window = 5 ;
833+ }
834+
655835// The response message to aggregate a fleet by some group by
656836// fields.
657837message AggregateFleetResponse {
0 commit comments