xref: /aosp_15_r20/external/googleapis/google/cloud/aiplatform/v1beta1/model_monitoring_spec.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.cloud.aiplatform.v1beta1;
18
19import "google/api/resource.proto";
20import "google/cloud/aiplatform/v1beta1/explanation.proto";
21import "google/cloud/aiplatform/v1beta1/io.proto";
22import "google/cloud/aiplatform/v1beta1/machine_resources.proto";
23import "google/cloud/aiplatform/v1beta1/model_monitoring_alert.proto";
24import "google/type/interval.proto";
25
26option csharp_namespace = "Google.Cloud.AIPlatform.V1Beta1";
27option go_package = "cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb;aiplatformpb";
28option java_multiple_files = true;
29option java_outer_classname = "ModelMonitoringSpecProto";
30option java_package = "com.google.cloud.aiplatform.v1beta1";
31option php_namespace = "Google\\Cloud\\AIPlatform\\V1beta1";
32option ruby_package = "Google::Cloud::AIPlatform::V1beta1";
33
34// Monitoring monitoring job spec. It outlines the specifications for monitoring
35// objectives, notifications, and result exports.
36message ModelMonitoringSpec {
37  // The monitoring objective spec.
38  ModelMonitoringObjectiveSpec objective_spec = 1;
39
40  // The model monitoring notification spec.
41  ModelMonitoringNotificationSpec notification_spec = 2;
42
43  // The Output destination spec for metrics, error logs, etc.
44  ModelMonitoringOutputSpec output_spec = 3;
45}
46
47// Monitoring objectives spec.
48message ModelMonitoringObjectiveSpec {
49  // Data drift monitoring spec.
50  // Data drift measures the distribution distance between the current dataset
51  // and a baseline dataset. A typical use case is to detect data drift between
52  // the recent production serving dataset and the training dataset, or to
53  // compare the recent production dataset with a dataset from a previous
54  // period.
55  message DataDriftSpec {
56    // Feature names / Prediction output names interested in monitoring.
57    // These should be a subset of the input feature names or prediction output
58    // names specified in the monitoring schema.
59    // If the field is not specified all features / prediction outputs outlied
60    // in the monitoring schema will be used.
61    repeated string features = 1;
62
63    // Supported metrics type:
64    //  * l_infinity
65    //  * jensen_shannon_divergence
66    string categorical_metric_type = 2;
67
68    // Supported metrics type:
69    //  * jensen_shannon_divergence
70    string numeric_metric_type = 3;
71
72    // Default alert condition for all the categorical features.
73    ModelMonitoringAlertCondition default_categorical_alert_condition = 4;
74
75    // Default alert condition for all the numeric features.
76    ModelMonitoringAlertCondition default_numeric_alert_condition = 5;
77
78    // Per feature alert condition will override default alert condition.
79    map<string, ModelMonitoringAlertCondition> feature_alert_conditions = 6;
80  }
81
82  // Feature attribution monitoring spec.
83  message FeatureAttributionSpec {
84    // Feature names interested in monitoring.
85    // These should be a subset of the input feature names specified in the
86    // monitoring schema. If the field is not specified all features outlied in
87    // the monitoring schema will be used.
88    repeated string features = 1;
89
90    // Default alert condition for all the features.
91    ModelMonitoringAlertCondition default_alert_condition = 2;
92
93    // Per feature alert condition will override default alert condition.
94    map<string, ModelMonitoringAlertCondition> feature_alert_conditions = 3;
95
96    // The config of resources used by the Model Monitoring during the batch
97    // explanation for non-AutoML models. If not set, `n1-standard-2` machine
98    // type will be used by default.
99    BatchDedicatedResources batch_explanation_dedicated_resources = 4;
100  }
101
102  // Tabular monitoring objective.
103  message TabularObjective {
104    // Input feature distribution drift monitoring spec.
105    DataDriftSpec feature_drift_spec = 10;
106
107    // Prediction output distribution drift monitoring spec.
108    DataDriftSpec prediction_output_drift_spec = 11;
109
110    // Feature attribution monitoring spec.
111    FeatureAttributionSpec feature_attribution_spec = 12;
112  }
113
114  // The monitoring objective.
115  oneof objective {
116    // Tabular monitoring objective.
117    TabularObjective tabular_objective = 1;
118  }
119
120  // The explanation spec.
121  // This spec is required when the objectives spec includes feature attribution
122  // objectives.
123  ExplanationSpec explanation_spec = 3;
124
125  // Baseline dataset.
126  // It could be the training dataset or production serving dataset from a
127  // previous period.
128  ModelMonitoringInput baseline_dataset = 4;
129
130  // Target dataset.
131  ModelMonitoringInput target_dataset = 5;
132}
133
134// Specification for the export destination of monitoring results, including
135// metrics, logs, etc.
136message ModelMonitoringOutputSpec {
137  // Google Cloud Storage base folder path for metrics, error logs, etc.
138  GcsDestination gcs_base_directory = 1;
139}
140
141// Model monitoring data input spec.
142message ModelMonitoringInput {
143  // Input dataset spec.
144  message ModelMonitoringDataset {
145    // Dataset spec for data stored in Google Cloud Storage.
146    message ModelMonitoringGcsSource {
147      // Supported data format.
148      enum DataFormat {
149        // Data format unspecified, used when this field is unset.
150        DATA_FORMAT_UNSPECIFIED = 0;
151
152        // CSV files.
153        CSV = 1;
154
155        // TfRecord files
156        TF_RECORD = 2;
157
158        // JsonL files.
159        JSONL = 3;
160      }
161
162      // Google Cloud Storage URI to the input file(s). May contain
163      // wildcards. For more information on wildcards, see
164      // https://cloud.google.com/storage/docs/gsutil/addlhelp/WildcardNames.
165      string gcs_uri = 1;
166
167      // Data format of the dataset.
168      DataFormat format = 2;
169    }
170
171    // Dataset spec for data sotred in BigQuery.
172    message ModelMonitoringBigQuerySource {
173      oneof connection {
174        // BigQuery URI to a table, up to 2000 characters long. All the columns
175        // in the table will be selected. Accepted forms:
176        //
177        // *  BigQuery path. For example:
178        // `bq://projectId.bqDatasetId.bqTableId`.
179        string table_uri = 1;
180
181        // Standard SQL to be used instead of the `table_uri`.
182        string query = 2;
183      }
184    }
185
186    // Choose one of supported data location for columnized dataset.
187    oneof data_location {
188      // Resource name of the Vertex AI managed dataset.
189      string vertex_dataset = 1 [(google.api.resource_reference) = {
190        type: "aiplatform.googleapis.com/Dataset"
191      }];
192
193      // Google Cloud Storage data source.
194      ModelMonitoringGcsSource gcs_source = 2;
195
196      // BigQuery data source.
197      ModelMonitoringBigQuerySource bigquery_source = 6;
198    }
199
200    // The timestamp field. Usually for serving data.
201    string timestamp_field = 7;
202  }
203
204  // Data from Vertex AI Batch prediction job output.
205  message BatchPredictionOutput {
206    // Vertex AI Batch prediction job resource name. The job must match the
207    // model version specified in [ModelMonitor].[model_monitoring_target].
208    string batch_prediction_job = 1 [(google.api.resource_reference) = {
209      type: "aiplatform.googleapis.com/BatchPredictionJob"
210    }];
211  }
212
213  // Data from Vertex AI Endpoint request response logging.
214  message VertexEndpointLogs {
215    // List of endpoint resource names. The endpoints must enable the logging
216    // with the [Endpoint].[request_response_logging_config], and must contain
217    // the deployed model corresponding to the model version specified in
218    // [ModelMonitor].[model_monitoring_target].
219    repeated string endpoints = 1 [(google.api.resource_reference) = {
220      type: "aiplatform.googleapis.com/Endpoint"
221    }];
222  }
223
224  // Time offset setting.
225  message TimeOffset {
226    // [offset] is the time difference from the cut-off time.
227    // For scheduled jobs, the cut-off time is the scheduled time.
228    // For non-scheduled jobs, it's the time when the job was created.
229    // Currently we support the following format:
230    // 'w|W': Week, 'd|D': Day, 'h|H': Hour
231    // E.g. '1h' stands for 1 hour, '2d' stands for 2 days.
232    string offset = 1;
233
234    // [window] refers to the scope of data selected for analysis.
235    // It allows you to specify the quantity of data you wish to examine.
236    // Currently we support the following format:
237    // 'w|W': Week, 'd|D': Day, 'h|H': Hour
238    // E.g. '1h' stands for 1 hour, '2d' stands for 2 days.
239    string window = 2;
240  }
241
242  // Dataset source.
243  oneof dataset {
244    // Columnized dataset.
245    ModelMonitoringDataset columnized_dataset = 1;
246
247    // Vertex AI Batch prediction Job.
248    BatchPredictionOutput batch_prediction_output = 2;
249
250    // Vertex AI Endpoint request & response logging.
251    VertexEndpointLogs vertex_endpoint_logs = 3;
252  }
253
254  // Time specification for the dataset.
255  oneof time_spec {
256    // The time interval (pair of start_time and end_time) for which results
257    // should be returned.
258    google.type.Interval time_interval = 6;
259
260    // The time offset setting for which results should be returned.
261    TimeOffset time_offset = 7;
262  }
263}
264
265// Notification spec(email, notification channel) for model monitoring
266// statistics/alerts.
267message ModelMonitoringNotificationSpec {
268  // The config for email alerts.
269  message EmailConfig {
270    // The email addresses to send the alerts.
271    repeated string user_emails = 1;
272  }
273
274  // Google Cloud Notification Channel config.
275  message NotificationChannelConfig {
276    // Resource names of the NotificationChannels.
277    // Must be of the format
278    // `projects/<project_id_or_number>/notificationChannels/<channel_id>`
279    string notification_channel = 1;
280  }
281
282  // Email alert config.
283  EmailConfig email_config = 1;
284
285  // Dump the anomalies to Cloud Logging. The anomalies will be put to json
286  // payload encoded from proto
287  // [google.cloud.aiplatform.logging.ModelMonitoringAnomaliesLogEntry][].
288  // This can be further sinked to Pub/Sub or any other services supported
289  // by Cloud Logging.
290  bool enable_cloud_logging = 2;
291
292  // Notification channel config.
293  repeated NotificationChannelConfig notification_channel_configs = 3;
294}
295