xref: /aosp_15_r20/external/googleapis/google/monitoring/dashboard/v1/metrics.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2023 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.monitoring.dashboard.v1;
18
19import "google/api/field_behavior.proto";
20import "google/monitoring/dashboard/v1/common.proto";
21
22option csharp_namespace = "Google.Cloud.Monitoring.Dashboard.V1";
23option go_package = "cloud.google.com/go/monitoring/dashboard/apiv1/dashboardpb;dashboardpb";
24option java_multiple_files = true;
25option java_outer_classname = "MetricsProto";
26option java_package = "com.google.monitoring.dashboard.v1";
27option php_namespace = "Google\\Cloud\\Monitoring\\Dashboard\\V1";
28option ruby_package = "Google::Cloud::Monitoring::Dashboard::V1";
29
30// TimeSeriesQuery collects the set of supported methods for querying time
31// series data from the Stackdriver metrics API.
32message TimeSeriesQuery {
33  // Parameters needed to obtain data for the chart.
34  oneof source {
35    // Filter parameters to fetch time series.
36    TimeSeriesFilter time_series_filter = 1;
37
38    // Parameters to fetch a ratio between two time series filters.
39    TimeSeriesFilterRatio time_series_filter_ratio = 2;
40
41    // A query used to fetch time series with MQL.
42    string time_series_query_language = 3;
43
44    // A query used to fetch time series with PromQL.
45    string prometheus_query = 6;
46  }
47
48  // The unit of data contained in fetched time series. If non-empty, this
49  // unit will override any unit that accompanies fetched data. The format is
50  // the same as the
51  // [`unit`](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.metricDescriptors)
52  // field in `MetricDescriptor`.
53  string unit_override = 5;
54
55  // Optional. If set, Cloud Monitoring will treat the full query duration as
56  // the alignment period so that there will be only 1 output value.
57  //
58  // *Note: This could override the configured alignment period except for
59  // the cases where a series of data points are expected, like
60  //   - XyChart
61  //   - Scorecard's spark chart
62  bool output_full_duration = 7 [(google.api.field_behavior) = OPTIONAL];
63}
64
65// A filter that defines a subset of time series data that is displayed in a
66// widget. Time series data is fetched using the
67// [`ListTimeSeries`](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list)
68// method.
69message TimeSeriesFilter {
70  // Required. The [monitoring
71  // filter](https://cloud.google.com/monitoring/api/v3/filters) that identifies
72  // the metric types, resources, and projects to query.
73  string filter = 1 [(google.api.field_behavior) = REQUIRED];
74
75  // By default, the raw time series data is returned.
76  // Use this field to combine multiple time series for different views of the
77  // data.
78  Aggregation aggregation = 2;
79
80  // Apply a second aggregation after `aggregation` is applied.
81  Aggregation secondary_aggregation = 3;
82
83  // Selects an optional time series filter.
84  oneof output_filter {
85    // Ranking based time series filter.
86    PickTimeSeriesFilter pick_time_series_filter = 4;
87
88    // Statistics based time series filter.
89    // Note: This field is deprecated and completely ignored by the API.
90    StatisticalTimeSeriesFilter statistical_time_series_filter = 5
91        [deprecated = true];
92  }
93}
94
95// A pair of time series filters that define a ratio computation. The output
96// time series is the pair-wise division of each aligned element from the
97// numerator and denominator time series.
98message TimeSeriesFilterRatio {
99  // Describes a query to build the numerator or denominator of a
100  // TimeSeriesFilterRatio.
101  message RatioPart {
102    // Required. The [monitoring
103    // filter](https://cloud.google.com/monitoring/api/v3/filters) that
104    // identifies the metric types, resources, and projects to query.
105    string filter = 1 [(google.api.field_behavior) = REQUIRED];
106
107    // By default, the raw time series data is returned.
108    // Use this field to combine multiple time series for different views of the
109    // data.
110    Aggregation aggregation = 2;
111  }
112
113  // The numerator of the ratio.
114  RatioPart numerator = 1;
115
116  // The denominator of the ratio.
117  RatioPart denominator = 2;
118
119  // Apply a second aggregation after the ratio is computed.
120  Aggregation secondary_aggregation = 3;
121
122  // Selects an optional filter that is applied to the time series after
123  // computing the ratio.
124  oneof output_filter {
125    // Ranking based time series filter.
126    PickTimeSeriesFilter pick_time_series_filter = 4;
127
128    // Statistics based time series filter.
129    // Note: This field is deprecated and completely ignored by the API.
130    StatisticalTimeSeriesFilter statistical_time_series_filter = 5
131        [deprecated = true];
132  }
133}
134
135// Defines a threshold for categorizing time series values.
136message Threshold {
137  // The color suggests an interpretation to the viewer when actual values cross
138  // the threshold. Comments on each color provide UX guidance on how users can
139  // be expected to interpret a given state color.
140  enum Color {
141    // Color is unspecified. Not allowed in well-formed requests.
142    COLOR_UNSPECIFIED = 0;
143
144    // Crossing the threshold is "concerning" behavior.
145    YELLOW = 4;
146
147    // Crossing the threshold is "emergency" behavior.
148    RED = 6;
149  }
150
151  // Whether the threshold is considered crossed by an actual value above or
152  // below its threshold value.
153  enum Direction {
154    // Not allowed in well-formed requests.
155    DIRECTION_UNSPECIFIED = 0;
156
157    // The threshold will be considered crossed if the actual value is above
158    // the threshold value.
159    ABOVE = 1;
160
161    // The threshold will be considered crossed if the actual value is below
162    // the threshold value.
163    BELOW = 2;
164  }
165
166  // An axis identifier.
167  enum TargetAxis {
168    // The target axis was not specified. Defaults to Y1.
169    TARGET_AXIS_UNSPECIFIED = 0;
170
171    // The y_axis (the right axis of chart).
172    Y1 = 1;
173
174    // The y2_axis (the left axis of chart).
175    Y2 = 2;
176  }
177
178  // A label for the threshold.
179  string label = 1;
180
181  // The value of the threshold. The value should be defined in the native scale
182  // of the metric.
183  double value = 2;
184
185  // The state color for this threshold. Color is not allowed in a XyChart.
186  Color color = 3;
187
188  // The direction for the current threshold. Direction is not allowed in a
189  // XyChart.
190  Direction direction = 4;
191
192  // The target axis to use for plotting the threshold. Target axis is not
193  // allowed in a Scorecard.
194  TargetAxis target_axis = 5;
195}
196
197// Defines the possible types of spark chart supported by the `Scorecard`.
198enum SparkChartType {
199  // Not allowed in well-formed requests.
200  SPARK_CHART_TYPE_UNSPECIFIED = 0;
201
202  // The sparkline will be rendered as a small line chart.
203  SPARK_LINE = 1;
204
205  // The sparkbar will be rendered as a small bar chart.
206  SPARK_BAR = 2;
207}
208