From 2192aa336e25db2534b67d615cbe6659abbd396d Mon Sep 17 00:00:00 2001 From: Shotaro Kohama Date: Tue, 8 Nov 2022 14:14:57 -0800 Subject: [PATCH] feat(vertexai): Add fields to Vertex AI FeatureStore EntityType for Feature Value Monitoring (#6699) * feat: add fields for feature monitoring * fix: use default_value for the fixed default values * fix: update code based on feedback --- mmv1/products/vertexai/api.yaml | 53 ++++++++++++++++++- mmv1/products/vertexai/terraform.yaml | 2 + .../vertex_ai_featurestore_entitytype.tf.erb | 17 ++++++ ...entitytype_feature_with_beta_fields.tf.erb | 8 +++ ...restore_entitytype_with_beta_fields.tf.erb | 8 +++ 5 files changed, 87 insertions(+), 1 deletion(-) diff --git a/mmv1/products/vertexai/api.yaml b/mmv1/products/vertexai/api.yaml index 867633575ef1..740147d8755a 100644 --- a/mmv1/products/vertexai/api.yaml +++ b/mmv1/products/vertexai/api.yaml @@ -489,7 +489,7 @@ objects: - !ruby/object:Api::Type::NestedObject name: 'snapshotAnalysis' description: | - Configuration of how features in Featurestore are monitored. + The config for Snapshot Analysis Based Feature Monitoring. properties: - !ruby/object:Api::Type::Boolean name: 'disabled' @@ -504,6 +504,57 @@ objects: Configuration of the snapshot analysis based monitoring pipeline running interval. The value is rolled up to full day. A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s". + - !ruby/object:Api::Type::Integer + name: 'monitoringIntervalDays' + description: | + Configuration of the snapshot analysis based monitoring pipeline running interval. The value indicates number of days. The default value is 1. + If both FeaturestoreMonitoringConfig.SnapshotAnalysis.monitoring_interval_days and [FeaturestoreMonitoringConfig.SnapshotAnalysis.monitoring_interval][] are set when creating/updating EntityTypes/Features, FeaturestoreMonitoringConfig.SnapshotAnalysis.monitoring_interval_days will be used. + default_value: 1 + - !ruby/object:Api::Type::Integer + name: 'stalenessDays' + description: | + Customized export features time window for snapshot analysis. Unit is one day. The default value is 21 days. Minimum value is 1 day. Maximum value is 4000 days. + default_value: 21 + - !ruby/object:Api::Type::NestedObject + name: 'importFeaturesAnalysis' + description: | + The config for ImportFeatures Analysis Based Feature Monitoring. + properties: + - !ruby/object:Api::Type::String + name: state + description: | + Whether to enable / disable / inherite default hebavior for import features analysis. The value must be one of the values below: + * DEFAULT: The default behavior of whether to enable the monitoring. EntityType-level config: disabled. + * ENABLED: Explicitly enables import features analysis. EntityType-level config: by default enables import features analysis for all Features under it. + * DISABLED: Explicitly disables import features analysis. EntityType-level config: by default disables import features analysis for all Features under it. + - !ruby/object:Api::Type::String + name: 'anomalyDetectionBaseline' + description: | + Defines the baseline to do anomaly detection for feature values imported by each [entityTypes.importFeatureValues][] operation. The value must be one of the values below: + * LATEST_STATS: Choose the later one statistics generated by either most recent snapshot analysis or previous import features analysis. If non of them exists, skip anomaly detection and only generate a statistics. + * MOST_RECENT_SNAPSHOT_STATS: Use the statistics generated by the most recent snapshot analysis if exists. + * PREVIOUS_IMPORT_FEATURES_STATS: Use the statistics generated by the previous import features analysis if exists. + - !ruby/object:Api::Type::NestedObject + name: 'numericalThresholdConfig' + description: | + Threshold for numerical features of anomaly detection. This is shared by all objectives of Featurestore Monitoring for numerical features (i.e. Features with type (Feature.ValueType) DOUBLE or INT64). + properties: + - !ruby/object:Api::Type::Double + name: 'value' + description: | + Specify a threshold value that can trigger the alert. For numerical feature, the distribution distance is calculated by Jensen–Shannon divergence. Each feature must have a non-zero threshold if they need to be monitored. Otherwise no alert will be triggered for that feature. The default value is 0.3. + required: true + - !ruby/object:Api::Type::NestedObject + name: 'categoricalThresholdConfig' + description: | + Threshold for categorical features of anomaly detection. This is shared by all types of Featurestore Monitoring for categorical features (i.e. Features with type (Feature.ValueType) BOOL or STRING). + properties: + - !ruby/object:Api::Type::Double + name: 'value' + description: | + Specify a threshold value that can trigger the alert. For categorical feature, the distribution distance is calculated by L-inifinity norm. Each feature must have a non-zero threshold if they need to be monitored. Otherwise no alert will be triggered for that feature. The default value is 0.3. + required: true + # Vertex AI Featurestore Entity Type Feature - !ruby/object:Api::Resource diff --git a/mmv1/products/vertexai/terraform.yaml b/mmv1/products/vertexai/terraform.yaml index 75e4d1ff11d2..0460a85568a0 100644 --- a/mmv1/products/vertexai/terraform.yaml +++ b/mmv1/products/vertexai/terraform.yaml @@ -118,6 +118,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides ignore_read: true name: !ruby/object:Overrides::Terraform::PropertyOverride custom_flatten: templates/terraform/custom_flatten/name_from_self_link.erb + monitoringConfig.snapshotAnalysis.monitoringInterval: !ruby/object:Overrides::Terraform::PropertyOverride + default_from_api: true custom_code: !ruby/object:Provider::Terraform::CustomCode pre_create: templates/terraform/constants/vertex_ai_featurestore_entitytype.go.erb pre_delete: templates/terraform/constants/vertex_ai_featurestore_entitytype.go.erb diff --git a/mmv1/templates/terraform/examples/vertex_ai_featurestore_entitytype.tf.erb b/mmv1/templates/terraform/examples/vertex_ai_featurestore_entitytype.tf.erb index a6bb99e0894b..dac5ab615f76 100644 --- a/mmv1/templates/terraform/examples/vertex_ai_featurestore_entitytype.tf.erb +++ b/mmv1/templates/terraform/examples/vertex_ai_featurestore_entitytype.tf.erb @@ -18,4 +18,21 @@ resource "google_vertex_ai_featurestore_entitytype" "entity" { foo = "bar" } featurestore = google_vertex_ai_featurestore.featurestore.id + monitoring_config { + snapshot_analysis { + disabled = false + monitoring_interval_days = 1 + staleness_days = 21 + } + numerical_threshold_config { + value = 0.8 + } + categorical_threshold_config { + value = 10.0 + } + import_features_analysis { + state = "ENABLED" + anomaly_detection_baseline = "PREVIOUS_IMPORT_FEATURES_STATS" + } + } } diff --git a/mmv1/templates/terraform/examples/vertex_ai_featurestore_entitytype_feature_with_beta_fields.tf.erb b/mmv1/templates/terraform/examples/vertex_ai_featurestore_entitytype_feature_with_beta_fields.tf.erb index e3b6fad54842..8468f230ddd6 100644 --- a/mmv1/templates/terraform/examples/vertex_ai_featurestore_entitytype_feature_with_beta_fields.tf.erb +++ b/mmv1/templates/terraform/examples/vertex_ai_featurestore_entitytype_feature_with_beta_fields.tf.erb @@ -22,6 +22,14 @@ resource "google_vertex_ai_featurestore_entitytype" "entity" { disabled = false monitoring_interval = "86400s" } + + categorical_threshold_config { + value = 0.3 + } + + numerical_threshold_config { + value = 0.3 + } } } diff --git a/mmv1/templates/terraform/examples/vertex_ai_featurestore_entitytype_with_beta_fields.tf.erb b/mmv1/templates/terraform/examples/vertex_ai_featurestore_entitytype_with_beta_fields.tf.erb index c676aab0201c..a533113a92f9 100644 --- a/mmv1/templates/terraform/examples/vertex_ai_featurestore_entitytype_with_beta_fields.tf.erb +++ b/mmv1/templates/terraform/examples/vertex_ai_featurestore_entitytype_with_beta_fields.tf.erb @@ -25,5 +25,13 @@ resource "google_vertex_ai_featurestore_entitytype" "entity" { disabled = false monitoring_interval = "86400s" } + + categorical_threshold_config { + value = 0.3 + } + + numerical_threshold_config { + value = 0.3 + } } }