Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 Improve the metric proto structure #1247

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
🎨 Improve the metric proto structure
  • Loading branch information
Munklinde96 committed Sep 26, 2024
commit b380b811073118781b30056683279320763d5fce
77 changes: 62 additions & 15 deletions docs/docs/api/platform-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@

| Method Name | Request Type | Response Type | Description |
| ----------- | ------------ | ------------- | ------------|
| /api.v1.metrics.Service/GetMetrics | [GetMetricsRequest](#api-v1-metrics-GetMetricsRequest) | [GetMetricsResponse](#api-v1-metrics-GetMetricsResponse) | Retrieve metrics. metric_type is mandatory, while the rest of the fields are optional. If project, env or capsule is not specified, they will be treated as wildcards. |
| /api.v1.metrics.Service/GetMetrics | [GetMetricsRequest](#api-v1-metrics-GetMetricsRequest) | [GetMetricsResponse](#api-v1-metrics-GetMetricsResponse) | Retrieve metrics. metric_type is mandatory, while the rest of the fields in the tags are optional. If project, env or capsule is not specified, they will be treated as wildcards. |
| /api.v1.metrics.Service/GetMetricsMany | [GetMetricsManyRequest](#api-v1-metrics-GetMetricsManyRequest) | [GetMetricsManyResponse](#api-v1-metrics-GetMetricsManyResponse) | Retrive metrics for multiple sets of tags at a time. Metrics within the same set of tags will be in ascending order of timestamp. |



Expand Down Expand Up @@ -8055,34 +8056,50 @@ A docker image tag.



<a name="api-v1-metrics-Metadata"></a>
<a name="api-v1-metrics-Metric"></a>

### Metadata
### Metric



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| project | [string](#string) | | |
| environment | [string](#string) | | |
| capsule | [string](#string) | | |
| timestamp | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |
| value | [double](#double) | | |






<a name="api-v1-metrics-Metric"></a>
<a name="api-v1-metrics-MetricFull"></a>

### Metric
### MetricFull



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| timestamp | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |
| value | [double](#double) | | |
| metadata | [Metadata](#api-v1-metrics-Metadata) | | Metadata is only populated when metrics are aggregated. |
| metric | [Metric](#api-v1-metrics-Metric) | | |
| tags | [Tags](#api-v1-metrics-Tags) | | |






<a name="api-v1-metrics-Tags"></a>

### Tags



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| project | [string](#string) | | |
| environment | [string](#string) | | |
| capsule | [string](#string) | | |
| metric_type | [string](#string) | | |



Expand Down Expand Up @@ -8118,6 +8135,39 @@ A docker image tag.



<a name="api-v1-metrics-GetMetricsManyRequest"></a>

### GetMetricsManyRequest



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| tags | [Tags](#api-v1-metrics-Tags) | repeated | |
| from | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |
| to | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |
| aggregation | [Aggregation](#api-v1-metrics-Aggregation) | | |






<a name="api-v1-metrics-GetMetricsManyResponse"></a>

### GetMetricsManyResponse



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| metrics | [MetricFull](#api-v1-metrics-MetricFull) | repeated | |






<a name="api-v1-metrics-GetMetricsRequest"></a>

### GetMetricsRequest
Expand All @@ -8126,10 +8176,7 @@ A docker image tag.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| metric_type | [string](#string) | | |
| project | [string](#string) | | |
| environment | [string](#string) | | |
| capsule | [string](#string) | | |
| tags | [Tags](#api-v1-metrics-Tags) | | |
| from | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |
| to | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |
| aggregation | [Aggregation](#api-v1-metrics-Aggregation) | | |
Expand Down
10 changes: 7 additions & 3 deletions proto/rig/api/v1/metrics/metrics.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ import "google/protobuf/timestamp.proto";
message Metric {
google.protobuf.Timestamp timestamp = 1;
double value = 2;
// Metadata is only populated when metrics are aggregated.
Metadata metadata = 4;
}

message Metadata {
message MetricFull {
Metric metric = 1;
Tags tags = 2;
}

message Tags {
string project = 1;
string environment = 2;
string capsule = 3;
string metric_type = 4;
}
27 changes: 19 additions & 8 deletions proto/rig/api/v1/metrics/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,36 @@ import "api/v1/metrics/metrics.proto";

service Service {
// Retrieve metrics. metric_type is mandatory, while the rest of the fields
// are optional. If project, env or capsule is not
// in the tags are optional. If project, env or capsule is not
// specified, they will be treated as wildcards.
rpc GetMetrics(GetMetricsRequest) returns (GetMetricsResponse) {}
// Retrive metrics for multiple sets of tags at a time. Metrics within the
// same set of tags will be in ascending order of timestamp.
rpc GetMetricsMany(GetMetricsManyRequest) returns (GetMetricsManyResponse) {}
}

message GetMetricsRequest {
string metric_type = 1;
string project = 2;
string environment = 3;
string capsule = 4;
google.protobuf.Timestamp from = 5;
google.protobuf.Timestamp to = 6;
Aggregation aggregation = 7;
Tags tags = 1;
google.protobuf.Timestamp from = 2;
google.protobuf.Timestamp to = 3;
Aggregation aggregation = 4;
}

message GetMetricsResponse {
repeated Metric metrics = 1;
}

message GetMetricsManyRequest {
repeated Tags tags = 1;
google.protobuf.Timestamp from = 2;
google.protobuf.Timestamp to = 3;
Aggregation aggregation = 4;
}

message GetMetricsManyResponse {
repeated MetricFull metrics = 1;
}

message Aggregation {
Aggregator aggregator = 1;
google.protobuf.Duration bucket_size = 2;
Expand Down
Loading