From d1807cfaf67518246456cbdb464deb99d3bece20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Vall=C3=A9s?= Date: Thu, 22 Aug 2024 10:20:44 +0200 Subject: [PATCH 1/2] feat(mgmt): update metrics endpoints to serve new dashboard design --- core/mgmt/v1beta/metric.proto | 217 ++++++--------------- core/mgmt/v1beta/mgmt_public_service.proto | 20 +- 2 files changed, 67 insertions(+), 170 deletions(-) diff --git a/core/mgmt/v1beta/metric.proto b/core/mgmt/v1beta/metric.proto index d06e776c..8c6a55eb 100644 --- a/core/mgmt/v1beta/metric.proto +++ b/core/mgmt/v1beta/metric.proto @@ -38,38 +38,36 @@ message PipelineTriggerCount { optional Status status = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; } -/* - // PipelineTriggerChartRecord represents a timeline of pipeline triggers. It - // contains a collection of (timestamp, count) pairs that represent the total - // pipeline triggers in a given time bucket. - // pipeline ID and time frame. - message PipelineTriggerChartRecord { - // This field will be present present when the information is grouped by pipeline. - optional string pipeline_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - // 2 is reserved for the pipeline UUID. - reserved 2; - // 3 is reserved for the trigger mode. The server wasn't grouping results by this - // field. - reserved 3; - // 4 is reserved for the trigger status. The server wasn't grouping results - // by this field. - reserved 4; - // Time buckets. - repeated google.protobuf.Timestamp time_buckets = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - // Aggregated trigger count in each time bucket. - repeated int32 trigger_counts = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - // 7 is reserved for the trigger execution duration. - reserved 7; - // 8 is reserved for the pipeline release ID. The server wasn't grouping - // results by this field. - reserved 8; - // 9 is reserved for the pipeline release UUID. The server wasn't grouping - // results by this field. - reserved 9; - // The ID of the namespace that requested the pipeline triggers. - string namespace_id = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; - } -*/ +// PipelineTriggerChartRecord represents a timeline of pipeline triggers. It +// contains a collection of (timestamp, count) pairs that represent the total +// pipeline triggers in a given time bucket. +// pipeline ID and time frame. +message PipelineTriggerChartRecord { + // This field will be present present when the information is grouped by pipeline. + optional string pipeline_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + // 2 is reserved for the pipeline UUID. + reserved 2; + // 3 is reserved for the trigger mode. The server wasn't grouping results by this + // field. + reserved 3; + // 4 is reserved for the trigger status. The server wasn't grouping results + // by this field. + reserved 4; + // Time buckets. + repeated google.protobuf.Timestamp time_buckets = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + // Aggregated trigger count in each time bucket. + repeated int32 trigger_counts = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + // 7 is reserved for the trigger execution duration. + reserved 7; + // 8 is reserved for the pipeline release ID. The server wasn't grouping + // results by this field. + reserved 8; + // 9 is reserved for the pipeline release UUID. The server wasn't grouping + // results by this field. + reserved 9; + // The ID of the namespace that requested the pipeline triggers. + string namespace_id = 10 [(google.api.field_behavior) = OUTPUT_ONLY]; +} // GetPipelineTriggerCountRequest represents a request to fetch the trigger // count of a requester over a time period. @@ -91,44 +89,42 @@ message GetPipelineTriggerCountResponse { repeated PipelineTriggerCount pipeline_trigger_counts = 1; } -/* - // ListPipelineTriggerChartRecordsRequest represents a request to list pipeline - // trigger chart records for a given requester, grouped by time buckets. - message ListPipelineTriggerChartRecordsRequest { - // 1 is reserved for the aggregation window in nanoseconds. This is - // deprecated in favour of an aggregation window string that represents a - // duration. - reserved 1; - // 2 is reserved for the filter. For now, this endpoint won't allow filtering - // but in the future we might implement a filter to show the trigger count of - // only certain pipelines and to group by the pipeline ID. - reserved 2; +// ListPipelineTriggerChartRecordsRequest represents a request to list pipeline +// trigger chart records for a given requester, grouped by time buckets. +message ListPipelineTriggerChartRecordsRequest { + // 1 is reserved for the aggregation window in nanoseconds. This is + // deprecated in favour of an aggregation window string that represents a + // duration. + reserved 1; + // 2 is reserved for the filter. For now, this endpoint won't allow filtering + // but in the future we might implement a filter to show the trigger count of + // only certain pipelines and to group by the pipeline ID. + reserved 2; - // The ID of the namespace that requested the pipeline triggers. - string namespace_id = 3 [(google.api.field_behavior) = REQUIRED]; - // Aggregation window. The value is a positive duration string, i.e. a - // sequence of decimal numbers, each with optional fraction and a unit - // suffix, such as "300ms", "1.5h" or "2h45m". - // The minimum (and default) window is 1h. - optional string aggregation_window = 4; - // Beginning of the time range from which the records will be fetched. - // The default value is the beginning of the current day, in UTC. - optional google.protobuf.Timestamp start = 5; - // End of the time range from which the records will be fetched. - // The default value is the current timestamp. - optional google.protobuf.Timestamp stop = 6; - } + // The ID of the namespace that requested the pipeline triggers. + string namespace_id = 3 [(google.api.field_behavior) = REQUIRED]; + // Aggregation window. The value is a positive duration string, i.e. a + // sequence of decimal numbers, each with optional fraction and a unit + // suffix, such as "300ms", "1.5h" or "2h45m". + // The minimum (and default) window is 1h. + optional string aggregation_window = 4; + // Beginning of the time range from which the records will be fetched. + // The default value is the beginning of the current day, in UTC. + optional google.protobuf.Timestamp start = 5; + // End of the time range from which the records will be fetched. + // The default value is the current timestamp. + optional google.protobuf.Timestamp stop = 6; +} - // ListPipelineTriggerChartRecordsResponse contains a list of pipeline trigger - // chart records. - message ListPipelineTriggerChartRecordsResponse { - // Pipeline trigger counts. Until we allow filtering or grouping by fields - // like pipeline ID, this list will contain only one element with the - // timeline of trigger counts for a given requester, regardless the pipeline - // ID, trigger mode, final status or other fields. - repeated PipelineTriggerChartRecord pipeline_trigger_chart_records = 1; - } -*/ +// ListPipelineTriggerChartRecordsResponse contains a list of pipeline trigger +// chart records. +message ListPipelineTriggerChartRecordsResponse { + // Pipeline trigger counts. Until we allow filtering or grouping by fields + // like pipeline ID, this list will contain only one element with the + // timeline of trigger counts for a given requester, regardless the pipeline + // ID, trigger mode, final status or other fields. + repeated PipelineTriggerChartRecord pipeline_trigger_chart_records = 1; +} // CreditConsumptionChartRecord represents a timeline of Instill Credit // consumption. It contains a collection of (timestamp, amount) pairs that @@ -173,88 +169,3 @@ message ListCreditConsumptionChartRecordsResponse { // consumption by source. reserved 2; } - -// Deprecated messages, to be removed with the new dashboard implementation. - -// PipelineTriggerTableRecord contains pipeline trigger metrics, aggregated by -// pipeline ID. -message PipelineTriggerTableRecord { - // Pipeline ID. - string pipeline_id = 1; - // Pipeline UUID. - string pipeline_uid = 2; - // Number of triggers with `STATUS_COMPLETED`. - int32 trigger_count_completed = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; - // Number of triggers with `STATUS_ERRORED`. - int32 trigger_count_errored = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - // Version for the triggered pipeline if it is a release pipeline. - string pipeline_release_id = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - // Release UUID for the triggered pipeline if it is a release pipeline. - string pipeline_release_uid = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; -} - -// ListPipelineTriggerTableRecordsRequest represents a request to list the -// pipeline triggers metrics, aggregated by pipeline ID. -message ListPipelineTriggerTableRecordsRequest { - // The maximum number of results to return. If this parameter is unspecified, - // at most 100 pipelines will be returned. The cap value for this parameter - // is 1000 (i.e. any value above that will be coerced to 1000). - optional int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL]; - // Page token. - optional string page_token = 2 [(google.api.field_behavior) = OPTIONAL]; - // Filter can hold an [AIP-160](https://google.aip.dev/160)-compliant filter - // expression. - // - Example: `create_time>timestamp("2000-06-19T23:31:08.657Z")`. - optional string filter = 3 [(google.api.field_behavior) = OPTIONAL]; -} - -// ListPipelineTriggerTableRecordsResponse contains the pipeline metrics. -message ListPipelineTriggerTableRecordsResponse { - // A list of pipeline trigger tables. - repeated PipelineTriggerTableRecord pipeline_trigger_table_records = 1; - // Next page token. - string next_page_token = 2; - // Total number of pipeline trigger records - int32 total_size = 3; -} - -// ListPipelineTriggerChartRecordsRequest represents a request to list pipeline -// trigger metrics, aggregated by pipeline ID and time frame. -message ListPipelineTriggerChartRecordsRequest { - // Aggregation window in nanoseconds. - int32 aggregation_window = 1; - // Filter can hold an [AIP-160](https://google.aip.dev/160)-compliant filter - // expression. - // - Example: `create_time>timestamp("2000-06-19T23:31:08.657Z")`. - optional string filter = 2 [(google.api.field_behavior) = OPTIONAL]; -} - -// ListPipelineTriggerChartRecordsResponse contains a list of pipeline trigger -// chart records. -message ListPipelineTriggerChartRecordsResponse { - // A list of pipeline trigger records. - repeated PipelineTriggerChartRecord pipeline_trigger_chart_records = 1; -} - -// PipelineTriggerChartRecord contains pipeline trigger metrics, aggregated by -// pipeline ID and time frame. -message PipelineTriggerChartRecord { - // Pipeline ID. - string pipeline_id = 1; - // Pipeline UUID. - string pipeline_uid = 2; - // Trigger mode. - Mode trigger_mode = 3; - // Final status. - Status status = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; - // Time buckets. - repeated google.protobuf.Timestamp time_buckets = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; - // Aggregated trigger count in each time bucket. - repeated int32 trigger_counts = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; - // Total computation time duration in each time bucket. - repeated float compute_time_duration = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; - // Version for the triggered pipeline if it is a release pipeline. - string pipeline_release_id = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; - // Release UUID for the triggered pipeline if it is a release pipeline. - string pipeline_release_uid = 9 [(google.api.field_behavior) = OUTPUT_ONLY]; -} diff --git a/core/mgmt/v1beta/mgmt_public_service.proto b/core/mgmt/v1beta/mgmt_public_service.proto index 8e013ce4..222b308e 100644 --- a/core/mgmt/v1beta/mgmt_public_service.proto +++ b/core/mgmt/v1beta/mgmt_public_service.proto @@ -290,27 +290,13 @@ service MgmtPublicService { rpc GetPipelineTriggerCount(GetPipelineTriggerCountRequest) returns (GetPipelineTriggerCountResponse) { option (google.api.http) = {get: "/v1beta/metrics/vdp/pipeline/trigger-count"}; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "Metric"}; - // This endpoint will remain hidden until the new dashboard is implemented - // in the frontend. Until then, the server might return empty data. - option (google.api.method_visibility).restriction = "INTERNAL"; - } - - // List pipeline trigger metrics - // - // Returns a paginated list of pipeline executions aggregated by pipeline ID. - // NOTE: This method is deprecated and will be retired soon. - rpc ListPipelineTriggerTableRecords(ListPipelineTriggerTableRecordsRequest) returns (ListPipelineTriggerTableRecordsResponse) { - option (google.api.http) = {get: "/v1beta/metrics/vdp/pipeline/tables"}; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "Metric"}; - option deprecated = true; - option (google.api.method_visibility).restriction = "INTERNAL"; } // List pipeline trigger time charts // - // Returns a timeline of pipline trigger counts for the pipelines of a given - // owner. - // NOTE: This method will soon return the trigger counts of a given requester. + // Returns a timeline of pipline trigger counts for a given requester. The + // response will contain one set of records (datapoints), representing the + // amount of triggers in a time bucket. rpc ListPipelineTriggerChartRecords(ListPipelineTriggerChartRecordsRequest) returns (ListPipelineTriggerChartRecordsResponse) { option (google.api.http) = {get: "/v1beta/metrics/vdp/pipeline/charts"}; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {tags: "Metric"}; From d7d4b49baccf45feab03a5a3963f3ccfcb09dbcf Mon Sep 17 00:00:00 2001 From: droplet-bot Date: Fri, 4 Oct 2024 11:00:02 +0000 Subject: [PATCH 2/2] chore: auto-gen by protobufs triggered by commit: https://github.com/instill-ai/protobufs/commit/7369e37cf80b2bea3aa58fc1b282c1e39afacdb6 --- openapiv2/core/service.swagger.yaml | 155 +++++++++++++++++++--------- 1 file changed, 108 insertions(+), 47 deletions(-) diff --git a/openapiv2/core/service.swagger.yaml b/openapiv2/core/service.swagger.yaml index 93ca6a89..735a0ba2 100644 --- a/openapiv2/core/service.swagger.yaml +++ b/openapiv2/core/service.swagger.yaml @@ -868,13 +868,56 @@ paths: $ref: '#/definitions/v1betaCheckNamespaceRequest' tags: - Utils + /v1beta/metrics/vdp/pipeline/trigger-count: + get: + summary: Get pipeline trigger count + description: |- + Returns the pipeline trigger count of a given requester within a timespan. + Results are grouped by trigger status. + operationId: MgmtPublicService_GetPipelineTriggerCount + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/v1betaGetPipelineTriggerCountResponse' + "401": + description: Returned when the client credentials are not valid. + schema: {} + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/googlerpcStatus' + parameters: + - name: namespaceId + description: The ID of the namespace that requested the pipeline triggers. + in: query + required: true + type: string + - name: start + description: |- + Beginning of the time range from which the records will be fetched. + The default value is the beginning of the current day, in UTC. + in: query + required: false + type: string + format: date-time + - name: stop + description: |- + End of the time range from which the records will be fetched. + The default value is the current timestamp. + in: query + required: false + type: string + format: date-time + tags: + - Metric /v1beta/metrics/vdp/pipeline/charts: get: summary: List pipeline trigger time charts description: |- - Returns a timeline of pipline trigger counts for the pipelines of a given - owner. - NOTE: This method will soon return the trigger counts of a given requester. + Returns a timeline of pipline trigger counts for a given requester. The + response will contain one set of records (datapoints), representing the + amount of triggers in a time bucket. operationId: MgmtPublicService_ListPipelineTriggerChartRecords responses: "200": @@ -889,20 +932,36 @@ paths: schema: $ref: '#/definitions/googlerpcStatus' parameters: + - name: namespaceId + description: The ID of the namespace that requested the pipeline triggers. + in: query + required: true + type: string - name: aggregationWindow - description: Aggregation window in nanoseconds. + description: |- + Aggregation window. The value is a positive duration string, i.e. a + sequence of decimal numbers, each with optional fraction and a unit + suffix, such as "300ms", "1.5h" or "2h45m". + The minimum (and default) window is 1h. in: query required: false - type: integer - format: int32 - - name: filter + type: string + - name: start description: |- - Filter can hold an [AIP-160](https://google.aip.dev/160)-compliant filter - expression. - - Example: `create_time>timestamp("2000-06-19T23:31:08.657Z")`. + Beginning of the time range from which the records will be fetched. + The default value is the beginning of the current day, in UTC. in: query required: false type: string + format: date-time + - name: stop + description: |- + End of the time range from which the records will be fetched. + The default value is the current timestamp. + in: query + required: false + type: string + format: date-time tags: - Metric /v1beta/metrics/credit/charts: @@ -1368,6 +1427,18 @@ definitions: allOf: - $ref: '#/definitions/v1betaOrganizationSubscription' description: GetOrganizationSubscriptionResponse contains the requested subscription. + v1betaGetPipelineTriggerCountResponse: + type: object + properties: + pipelineTriggerCounts: + type: array + items: + type: object + $ref: '#/definitions/v1betaPipelineTriggerCount' + description: The trigger counts, grouped by status. + description: |- + GetPipelineTriggerCountResponse contains the trigger count, grouped by + trigger status. v1betaGetRemainingCreditAdminResponse: type: object properties: @@ -1514,7 +1585,11 @@ definitions: items: type: object $ref: '#/definitions/v1betaPipelineTriggerChartRecord' - description: A list of pipeline trigger records. + description: |- + Pipeline trigger counts. Until we allow filtering or grouping by fields + like pipeline ID, this list will contain only one element with the + timeline of trigger counts for a given requester, regardless the pipeline + ID, trigger mode, final status or other fields. description: |- ListPipelineTriggerChartRecordsResponse contains a list of pipeline trigger chart records. @@ -1610,16 +1685,6 @@ definitions: - MEMBERSHIP_STATE_ACTIVE: Active. - MEMBERSHIP_STATE_PENDING: Pending, i.e., a request has been sent to the user to join an organization. - v1betaMode: - type: string - enum: - - MODE_SYNC - - MODE_ASYNC - description: |- - Mode describes the execution mode of the pipeline (sync or async). - - - MODE_SYNC: Synchronous (result is returned in the response). - - MODE_ASYNC: Asynchronous (response only contains acknowledgement). v1betaOnboardingStatus: type: string enum: @@ -1793,19 +1858,8 @@ definitions: properties: pipelineId: type: string - description: Pipeline ID. - pipelineUid: - type: string - description: Pipeline UUID. - triggerMode: - description: Trigger mode. - allOf: - - $ref: '#/definitions/v1betaMode' - status: - description: Final status. + description: This field will be present present when the information is grouped by pipeline. readOnly: true - allOf: - - $ref: '#/definitions/mgmtv1betaStatus' timeBuckets: type: array items: @@ -1820,24 +1874,31 @@ definitions: format: int32 description: Aggregated trigger count in each time bucket. readOnly: true - computeTimeDuration: - type: array - items: - type: number - format: float - description: Total computation time duration in each time bucket. - readOnly: true - pipelineReleaseId: - type: string - description: Version for the triggered pipeline if it is a release pipeline. - readOnly: true - pipelineReleaseUid: + namespaceId: type: string - description: Release UUID for the triggered pipeline if it is a release pipeline. + description: The ID of the namespace that requested the pipeline triggers. readOnly: true description: |- - PipelineTriggerChartRecord contains pipeline trigger metrics, aggregated by + PipelineTriggerChartRecord represents a timeline of pipeline triggers. It + contains a collection of (timestamp, count) pairs that represent the total + pipeline triggers in a given time bucket. pipeline ID and time frame. + v1betaPipelineTriggerCount: + type: object + properties: + triggerCount: + type: integer + format: int32 + description: Number of triggers. + readOnly: true + status: + description: This field will be present when results are grouped by trigger status. + readOnly: true + allOf: + - $ref: '#/definitions/mgmtv1betaStatus' + description: |- + PipelineTriggerCount represents a pipeline execution count with some + aggregation params (e.g. trigger status). v1betaStripeSubscriptionDetail: type: object properties: