11//
2- // Copyright 2023 The Chainloop Authors.
2+ // Copyright 2024 The Chainloop Authors.
33//
44// Licensed under the Apache License, Version 2.0 (the "License");
55// you may not use this file except in compliance with the License.
@@ -17,50 +17,87 @@ syntax = "proto3";
1717
1818package controlplane.v1 ;
1919
20- option go_package = "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1;v1" ;
21- import "validate/validate.proto" ;
2220import "controlplane/v1/response_messages.proto" ;
21+ import "validate/validate.proto" ;
22+ import "workflowcontract/v1/crafting_schema.proto" ;
23+
24+ option go_package = "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1;v1" ;
2325
2426service OrgMetricsService {
25- rpc Totals (OrgMetricsServiceTotalsRequest ) returns (OrgMetricsServiceTotalsResponse );
26- rpc TopWorkflowsByRunsCount (TopWorkflowsByRunsCountRequest ) returns (TopWorkflowsByRunsCountResponse );
27+ rpc Totals (OrgMetricsServiceTotalsRequest ) returns (OrgMetricsServiceTotalsResponse );
28+ rpc TopWorkflowsByRunsCount (TopWorkflowsByRunsCountRequest ) returns (TopWorkflowsByRunsCountResponse );
29+ rpc DailyRunsCount (DailyRunsCountRequest ) returns (DailyRunsCountResponse );
30+ }
31+
32+ // Get the dayly count of runs by status
33+ message DailyRunsCountRequest {
34+ optional string workflow_id = 1 [(validate.rules ) .string.uuid = true ];
35+
36+ MetricsTimeWindow time_window = 2 [(validate.rules ).enum = {
37+ not_in : [0 ]
38+ }];
39+ }
40+
41+ message DailyRunsCountResponse {
42+ repeated TotalByDay result = 1 ;
43+
44+ message TotalByDay {
45+ // string format: "YYYY-MM-DD"
46+ string date = 1 ;
47+ MetricsStatusCount metrics = 2 ;
48+ }
2749}
2850
2951message OrgMetricsServiceTotalsRequest {
30- MetricsTimeWindow time_window = 1 [(validate.rules ).enum = {not_in : [0 ]}];
52+ MetricsTimeWindow time_window = 1 [(validate.rules ).enum = {
53+ not_in : [0 ]
54+ }];
55+ }
56+
57+ message OrgMetricsServiceTotalsResponse {
58+ Result result = 1 ;
59+
60+ message Result {
61+ int32 runs_total = 1 ;
62+ repeated MetricsStatusCount runs_total_by_status = 2 ;
63+ repeated MetricsRunnerCount runs_total_by_runner_type = 3 ;
64+ }
65+ }
66+
67+ message MetricsStatusCount {
68+ int32 count = 1 ;
69+ RunStatus status = 2 ;
70+ }
71+
72+ message MetricsRunnerCount {
73+ int32 count = 1 ;
74+ workflowcontract.v1.CraftingSchema.Runner.RunnerType runner_type = 2 ;
3175}
3276
3377message TopWorkflowsByRunsCountRequest {
3478 // top x number of runs to return
35- int32 num_workflows = 1 [(validate.rules ).int32 = {gte : 1 , lte : 20 }];;
36- MetricsTimeWindow time_window = 2 [(validate.rules ).enum = {not_in : [0 ]}];
79+ int32 num_workflows = 1 [(validate.rules ).int32 = {
80+ gte : 1 ,
81+ lte : 20
82+ }];
83+ MetricsTimeWindow time_window = 2 [(validate.rules ).enum = {
84+ not_in : [0 ]
85+ }];
3786}
3887
3988message TopWorkflowsByRunsCountResponse {
4089 repeated TotalByStatus result = 1 ;
4190
4291 message TotalByStatus {
4392 WorkflowItem workflow = 1 ;
44- // Status -> [initialized, error, success]
45- map <string ,int32 > runs_total_by_status = 2 ;
46- }
47- }
48-
49- message OrgMetricsServiceTotalsResponse {
50- Result result = 1 ;
51-
52- message Result {
53- int32 runs_total = 1 ;
54- // Status -> [initialized, error, success]
55- map <string ,int32 > runs_total_by_status = 2 ;
56- // runner_type -> [generic, github_action, ...]
57- map <string ,int32 > runs_total_by_runner_type = 3 ;
93+ repeated MetricsStatusCount runs_total_by_status = 2 ;
5894 }
5995}
6096
6197enum MetricsTimeWindow {
62- METRICS_TIME_WINDOW_UNSPECIFIED = 0 ;
63- METRICS_TIME_WINDOW_LAST_30_DAYS = 1 ;
64- METRICS_TIME_WINDOW_LAST_7_DAYS = 2 ;
65- METRICS_TIME_WINDOW_LAST_DAY = 3 ;
66- }
98+ METRICS_TIME_WINDOW_UNSPECIFIED = 0 ;
99+ METRICS_TIME_WINDOW_LAST_DAY = 1 ;
100+ METRICS_TIME_WINDOW_LAST_7_DAYS = 2 ;
101+ METRICS_TIME_WINDOW_LAST_30_DAYS = 3 ;
102+ METRICS_TIME_WINDOW_LAST_90_DAYS = 4 ;
103+ }
0 commit comments