Skip to content

Commit

Permalink
feat(mgmt): update metrics endpoints to serve new dashboard design (#435
Browse files Browse the repository at this point in the history
)

Because

- Pipeline and credit endpoints have different params and schemas.
- Some of the information served by the existing endpoints will be
handled by the pipeline run feature.

This commit

- Adds endpoints to serve the new dashboard design:
- `GetPipelineTriggerCount` path is updated to align with API
guidelines.
- `ListCreditConsumptionChartRecords` path is updated to align with API
guidelines (previous path will be kept in the gateway to keep the
current UX running).
  - `ListPipelineTriggerChartRecords` is added.
- A separate PR will take care of removing the deprecated endpoints once
the new dashboard is rolled out.

---------

Co-authored-by: droplet-bot <[email protected]>
  • Loading branch information
jvallesm and droplet-bot authored Nov 20, 2024
1 parent 67d3fb5 commit 0cfe99f
Show file tree
Hide file tree
Showing 3 changed files with 209 additions and 325 deletions.
233 changes: 102 additions & 131 deletions core/mgmt/v1beta/metric.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ enum Status {
STATUS_ERRORED = 2;
}

// ========== Pipeline endpoints

// TriggerCount represents a execution count with some
// aggregation params (e.g. trigger status).
message TriggerCount {
Expand All @@ -38,44 +36,11 @@ message TriggerCount {
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];
}
*/

// GetPipelineTriggerCountRequest represents a request to fetch the trigger
// count of a requester over a time period.
message GetPipelineTriggerCountRequest {
// The ID of the namespace that requested the pipeline triggers.
string namespace_id = 1 [(google.api.field_behavior) = REQUIRED];
string requester_id = 1 [(google.api.field_behavior) = REQUIRED];
// 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 = 2;
Expand All @@ -84,6 +49,13 @@ message GetPipelineTriggerCountRequest {
optional google.protobuf.Timestamp stop = 3;
}

// GetPipelineTriggerCountResponse contains the trigger count, grouped by
// trigger status.
message GetPipelineTriggerCountResponse {
// The trigger counts, grouped by status.
repeated TriggerCount pipeline_trigger_counts = 1;
}

// GetModelTriggerCountRequest represents a request to fetch the trigger
// count of a requester over a time period.
message GetModelTriggerCountRequest {
Expand All @@ -97,58 +69,97 @@ message GetModelTriggerCountRequest {
optional google.protobuf.Timestamp stop = 3;
}

// GetPipelineTriggerCountResponse contains the trigger count, grouped by
// trigger status.
message GetPipelineTriggerCountResponse {
// The trigger counts, grouped by status.
repeated TriggerCount pipeline_trigger_counts = 1;
}

// GetModelTriggerCountResponse contains the trigger count, grouped by
// trigger status.
message GetModelTriggerCountResponse {
// The trigger counts, grouped by status.
repeated TriggerCount model_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;
// 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];
// Time buckets.
repeated google.protobuf.Timestamp time_buckets = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
// Aggregated trigger count in each time bucket.
repeated int32 trigger_counts = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
// The ID of the namespace that requested the pipeline triggers.
string requester_id = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// 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;
}
// ListPipelineTriggerChartRecordsRequest represents a request to list pipeline
// trigger chart records for a given requester, grouped by time buckets.
message ListPipelineTriggerChartRecordsRequest {
// The ID of the namespace that requested the pipeline triggers.
string requester_id = 1 [(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 = 2;
// 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 = 3;
// End of the time range from which the records will be fetched.
// The default value is the current timestamp.
optional google.protobuf.Timestamp stop = 4;
}

// 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;
}

// ModelTriggerChartRecord represents a timeline of model triggers. It
// contains a collection of (timestamp, count) pairs that represent the total
// model triggers in a given time bucket.
message ModelTriggerChartRecord {
// This field will be present present when the information is grouped by model.
optional string model_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
// Time buckets.
repeated google.protobuf.Timestamp time_buckets = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
// Aggregated trigger count in each time bucket.
repeated int32 trigger_counts = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
// The ID of the namespace that requested the model triggers.
string requester_id = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// ListModelTriggerChartRecordsRequest represents a request to list model
// trigger metrics, aggregated by model ID and time frame.
message ListModelTriggerChartRecordsRequest {
// The ID of the namespace that requested the model triggers.
string requester_id = 1 [(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 = 2;
// 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 = 3;
// End of the time range from which the records will be fetched.
// The default value is the current timestamp.
optional google.protobuf.Timestamp stop = 4;
}

// 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;
}
*/
// ListModelTriggerChartRecordsResponse contains a list of model trigger
// chart records.
message ListModelTriggerChartRecordsResponse {
// Model trigger counts. Until we allow filtering or grouping by fields
// like model ID, this list will contain only one element with the
// timeline of trigger counts for a given requester, regardless the model
// ID, trigger mode, final status or other fields.
repeated ModelTriggerChartRecord model_trigger_chart_records = 1;
}

// CreditConsumptionChartRecord represents a timeline of Instill Credit
// consumption. It contains a collection of (timestamp, amount) pairs that
Expand Down Expand Up @@ -194,7 +205,9 @@ message ListCreditConsumptionChartRecordsResponse {
reserved 2;
}

// =============================================================================
// Deprecated messages, to be removed with the new dashboard implementation.
// =============================================================================

// PipelineTriggerTableRecord contains pipeline trigger metrics, aggregated by
// pipeline ID.
Expand Down Expand Up @@ -238,9 +251,9 @@ message ListPipelineTriggerTableRecordsResponse {
int32 total_size = 3;
}

// ListPipelineTriggerChartRecordsRequest represents a request to list pipeline
// trigger metrics, aggregated by pipeline ID and time frame.
message ListPipelineTriggerChartRecordsRequest {
// ListPipelineTriggerChartRecordsV0Request represents a request to list
// pipeline trigger metrics, aggregated by pipeline ID and time frame.
message ListPipelineTriggerChartRecordsV0Request {
// Aggregation window in nanoseconds.
int32 aggregation_window = 1;
// Filter can hold an [AIP-160](https://google.aip.dev/160)-compliant filter
Expand All @@ -249,44 +262,16 @@ message ListPipelineTriggerChartRecordsRequest {
optional string filter = 2 [(google.api.field_behavior) = OPTIONAL];
}

// ListModelTriggerChartRecordsRequest represents a request to list model
// trigger metrics, aggregated by model ID and time frame.
message ListModelTriggerChartRecordsRequest {
// The ID of the namespace that requested the model triggers.
string requester_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 {
// ListPipelineTriggerChartRecordsV0Response contains a list of pipeline
// trigger chart records.
message ListPipelineTriggerChartRecordsV0Response {
// A list of pipeline trigger records.
repeated PipelineTriggerChartRecord pipeline_trigger_chart_records = 1;
}

// ListModelTriggerChartRecordsResponse contains a list of model trigger
// chart records.
message ListModelTriggerChartRecordsResponse {
// Model trigger counts. Until we allow filtering or grouping by fields
// like model ID, this list will contain only one element with the
// timeline of trigger counts for a given requester, regardless the model
// ID, trigger mode, final status or other fields.
repeated ModelTriggerChartRecord model_trigger_chart_records = 1;
repeated PipelineTriggerChartRecordV0 pipeline_trigger_chart_records = 1;
}

// PipelineTriggerChartRecord contains pipeline trigger metrics, aggregated by
// pipeline ID and time frame.
message PipelineTriggerChartRecord {
// PipelineTriggerChartRecordV0 contains pipeline trigger metrics, aggregated
// by pipeline ID and time frame.
message PipelineTriggerChartRecordV0 {
// Pipeline ID.
string pipeline_id = 1;
// Pipeline UUID.
Expand Down Expand Up @@ -353,17 +338,3 @@ message ListPipelineTriggerRecordsResponse {
// Total number of pipeline triggers.
int32 total_size = 3;
}

// ModelTriggerChartRecord represents a timeline of model triggers. It
// contains a collection of (timestamp, count) pairs that represent the total
// model triggers in a given time bucket.
message ModelTriggerChartRecord {
// This field will be present present when the information is grouped by model.
optional string model_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
// Time buckets.
repeated google.protobuf.Timestamp time_buckets = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
// Aggregated trigger count in each time bucket.
repeated int32 trigger_counts = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
// The ID of the namespace that requested the model triggers.
string requester_id = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
}
Loading

0 comments on commit 0cfe99f

Please sign in to comment.