Skip to content

Commit

Permalink
✨ Add proto for metric expressions (#1279)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatiasFrank authored Oct 14, 2024
1 parent 6d8020d commit 48d28cb
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 1 deletion.
114 changes: 114 additions & 0 deletions docs/docs/api/platform-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
| ----------- | ------------ | ------------- | ------------|
| /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. |
| /api.v1.metrics.Service/GetMetricsExpression | [GetMetricsExpressionRequest](#api-v1-metrics-GetMetricsExpressionRequest) | [GetMetricsExpressionResponse](#api-v1-metrics-GetMetricsExpressionResponse) | |



Expand Down Expand Up @@ -8323,6 +8324,104 @@ A docker image tag.



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

### Expression



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| leaf | [Expression.Leaf](#api-v1-metrics-Expression-Leaf) | | |
| operation | [Expression.Operation](#api-v1-metrics-Expression-Operation) | | |
| constant | [Expression.Constant](#api-v1-metrics-Expression-Constant) | | |






<a name="api-v1-metrics-Expression-Constant"></a>

### Expression.Constant



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| constant | [double](#double) | | |






<a name="api-v1-metrics-Expression-Leaf"></a>

### Expression.Leaf



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| tags | [Tags](#api-v1-metrics-Tags) | | |
| aggregator | [Aggregator](#api-v1-metrics-Aggregator) | | |






<a name="api-v1-metrics-Expression-Operation"></a>

### Expression.Operation



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| left | [Expression](#api-v1-metrics-Expression) | | |
| right | [Expression](#api-v1-metrics-Expression) | | |
| operation | [BinOp](#api-v1-metrics-BinOp) | | |






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

### GetMetricsExpressionRequest



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| expression | [Expression](#api-v1-metrics-Expression) | | |
| from | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |
| to | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |
| bucket_size | [google.protobuf.Duration](#google-protobuf-Duration) | | |






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

### GetMetricsExpressionResponse



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






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

### GetMetricsManyRequest
Expand Down Expand Up @@ -8406,6 +8505,21 @@ A docker image tag.



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

### BinOp


| Name | Number | Description |
| ---- | ------ | ----------- |
| BINOP_UNSPECIFIED | 0 | |
| BINOP_ADD | 1 | |
| BINOP_SUB | 2 | |
| BINOP_MULT | 3 | |
| BINOP_DIV | 4 | |






Expand Down
46 changes: 45 additions & 1 deletion proto/rig/api/v1/metrics/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ service Service {
// 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) {}
rpc GetMetricsExpression(GetMetricsExpressionRequest)
returns (GetMetricsExpressionResponse) {}
}

message GetMetricsRequest {
Expand Down Expand Up @@ -49,4 +51,46 @@ enum Aggregator {
AGGREGATOR_MIN = 2;
AGGREGATOR_MAX = 3;
AGGREGATOR_SUM = 4;
}
}

message GetMetricsExpressionRequest {
Expression expression = 1;
google.protobuf.Timestamp from = 2;
google.protobuf.Timestamp to = 3;
google.protobuf.Duration bucket_size = 4;
}

message GetMetricsExpressionResponse {
repeated Metric metrics = 1;
}

message Expression {
message Leaf {
Tags tags = 1;
Aggregator aggregator = 2;
}

message Operation {
Expression left = 1;
Expression right = 2;
BinOp operation = 3;
}

message Constant {
double constant = 1;
}

oneof expression {
Leaf leaf = 1;
Operation operation = 2;
Constant constant = 3;
}
}

enum BinOp {
BINOP_UNSPECIFIED = 0;
BINOP_ADD = 1;
BINOP_SUB = 2;
BINOP_MULT = 3;
BINOP_DIV = 4;
}

0 comments on commit 48d28cb

Please sign in to comment.