# Update a monitor

Launch stage: GA

`PATCH /api/data-quality/v1/monitors/{object_type}/{object_id}`

Update a data quality monitor on Unity Catalog object.

 For the `table` `object_type`, the caller must have either of the following sets of permissions:
 1. **MANAGE** and **USE_CATALOG** on the table's parent catalog.
 2. **USE_CATALOG** on the table's parent catalog, and **MANAGE** and **USE_SCHEMA** on the table's parent schema.
 3. **USE_CATALOG** on the table's parent catalog, **USE_SCHEMA** on the table's parent schema, and **MANAGE** on the table.

 For the `schema` `object_type`, the caller must have either of the following sets of permissions:
 1. **MANAGE** and **USE_CATALOG** on the schema's parent catalog.
 2. **USE_CATALOG** on the schema's parent catalog, and **MANAGE** and **USE_SCHEMA** on the schema.

API scopes: dataquality

## Path parameters

- `object_type` (string, required)
  The type of the monitored object. Can be one of the following: `schema` or `table`.
- `object_id` (string, required)
  The UUID of the request object. It is `schema_id` for `schema`, and `table_id` for `table`.
  
   Find the `schema_id` from either:
   1. The [schema_id](https://docs.databricks.com/api/workspace/schemas/get#schema_id) of the `Schemas` resource.
   2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `schema` > go to the `Details` tab > the `Schema ID` field.
  
   Find the `table_id` from either:
   1. The [table_id](https://docs.databricks.com/api/workspace/tables/get#table_id) of the `Tables` resource.
   2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `table` > go to the `Details` tab > the `Table ID` field.

## Query parameters

- `update_mask` (string, required)
  The field mask to specify which fields to update as a comma-separated list.
   Example value: `data_profiling_config.custom_metrics,data_profiling_config.schedule.quartz_cron_expression`

## Request body

The monitor to update.
- `object_type` (string, required)
  The type of the monitored object. Can be one of the following: `schema` or `table`.
  Example: `schema`
- `object_id` (string, required)
  The UUID of the request object. It is `schema_id` for `schema`, and `table_id` for `table`.
  
   Find the `schema_id` from either:
   1. The [schema_id](https://docs.databricks.com/api/workspace/schemas/get#schema_id) of the `Schemas` resource.
   2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `schema` > go to the `Details` tab > the `Schema ID` field.
  
   Find the `table_id` from either:
   1. The [table_id](https://docs.databricks.com/api/workspace/tables/get#table_id) of the `Tables` resource.
   2. In [Catalog Explorer](https://docs.databricks.com/aws/en/catalog-explorer/) > select the `table` > go to the `Details` tab > the `Table ID` field.
- `anomaly_detection_config` (object, optional)
  Anomaly Detection Configuration, applicable to `schema` object types.
  - `excluded_table_full_names` (array of string, optional, Beta)
    List of fully qualified table names to exclude from anomaly detection.
  - `notification_settings` (object, optional)
    Who to alert when anomaly detection finds unhealthy tables in this schema. Applicable to
     `schema` monitors only. This is the same schema alert you manage from **Manage alerts** in the
     Data Quality Monitoring UI, so a change made in either place shows in both.
    
     Set the recipients in `on_unhealthy_table`; `on_failure` is not supported here. Only
     `destination_ids` and `destination_user_ids` are supported.
    
     On update, an update mask of `*`, `anomaly_detection_config`, or
     `anomaly_detection_config.notification_settings` replaces the alert's recipients with the ones
     in the request; omitting the field, or leaving both recipient lists empty, removes the alert.
     Other masks leave the alert unchanged.
    - `on_failure` (object, optional)
      Destinations to send notifications on failure/timeout.
      - `email_addresses` (array of string, optional)
        The list of email addresses to send the notification to. A maximum of 5 email addresses is supported.
      - `destination_ids` (array of string, optional)
        The notification-destination IDs (Slack / Teams / webhook / Asana / ServiceNow / AWS
         EventBridge) to send the notification to. The destinations must already exist in the
         workspace; a workspace admin creates them. A maximum of 25 destination IDs is supported.
         Only supported on schema monitors, via `anomaly_detection_config`; rejected on table monitors.
      - `destination_user_ids` (array of int64, optional)
        The IDs of the workspace users to notify by email. A maximum of 25 user IDs is supported.
         Only supported on schema monitors, via `anomaly_detection_config`; rejected on table monitors.
    - `on_unhealthy_table` (object, optional)
      Recipients to notify when anomaly detection finds unhealthy tables in the schema. Each
       recipient gets one notification per important unhealthy table. Only supported on schema
       monitors, via `anomaly_detection_config`.
      - `email_addresses` (array of string, optional)
        The list of email addresses to send the notification to. A maximum of 5 email addresses is supported.
      - `destination_ids` (array of string, optional)
        The notification-destination IDs (Slack / Teams / webhook / Asana / ServiceNow / AWS
         EventBridge) to send the notification to. The destinations must already exist in the
         workspace; a workspace admin creates them. A maximum of 25 destination IDs is supported.
         Only supported on schema monitors, via `anomaly_detection_config`; rejected on table monitors.
      - `destination_user_ids` (array of int64, optional)
        The IDs of the workspace users to notify by email. A maximum of 25 user IDs is supported.
         Only supported on schema monitors, via `anomaly_detection_config`; rejected on table monitors.
- `data_profiling_config` (object, optional)
  Data Profiling Configuration, applicable to `table` object types. Exactly one `Analysis Configuration`
   must be present.
  - `output_schema_id` (string, required)
    ID of the schema where output tables are created.
  - `assets_dir` (string, optional, Immutable)
    Field for specifying the absolute path to a custom directory to store data-monitoring
     assets. Normally prepopulated to a default user location via UI and Python APIs.
  - `inference_log` (object, optional)
    `Analysis Configuration` for monitoring inference log tables.
    - `problem_type` (string, required)
      Problem type the model aims to solve.
      Possible values:
      - `INFERENCE_PROBLEM_TYPE_CLASSIFICATION`
      - `INFERENCE_PROBLEM_TYPE_REGRESSION`
    - `timestamp_column` (string, required)
      Column for the timestamp.
    - `granularities` (array of string, required)
      List of granularities to use when aggregating data into time windows based on their timestamp.
      Possible values:
      - `AGGREGATION_GRANULARITY_5_MINUTES`
      - `AGGREGATION_GRANULARITY_30_MINUTES`
      - `AGGREGATION_GRANULARITY_1_HOUR`
      - `AGGREGATION_GRANULARITY_1_DAY`
      - `AGGREGATION_GRANULARITY_1_WEEK`
      - `AGGREGATION_GRANULARITY_2_WEEKS`
      - `AGGREGATION_GRANULARITY_3_WEEKS`
      - `AGGREGATION_GRANULARITY_4_WEEKS`
      - `AGGREGATION_GRANULARITY_1_MONTH`
      - `AGGREGATION_GRANULARITY_1_YEAR`
    - `prediction_column` (string, required)
      Column for the prediction.
    - `label_column` (string, optional)
      Column for the label.
    - `model_id_column` (string, required)
      Column for the model identifier.
  - `time_series` (object, optional)
    `Analysis Configuration` for monitoring time series tables.
    - `timestamp_column` (string, required)
      Column for the timestamp.
    - `granularities` (array of string, required)
      List of granularities to use when aggregating data into time windows based on their timestamp.
      Possible values:
      - `AGGREGATION_GRANULARITY_5_MINUTES`
      - `AGGREGATION_GRANULARITY_30_MINUTES`
      - `AGGREGATION_GRANULARITY_1_HOUR`
      - `AGGREGATION_GRANULARITY_1_DAY`
      - `AGGREGATION_GRANULARITY_1_WEEK`
      - `AGGREGATION_GRANULARITY_2_WEEKS`
      - `AGGREGATION_GRANULARITY_3_WEEKS`
      - `AGGREGATION_GRANULARITY_4_WEEKS`
      - `AGGREGATION_GRANULARITY_1_MONTH`
      - `AGGREGATION_GRANULARITY_1_YEAR`
  - `snapshot` (object, optional)
    `Analysis Configuration` for monitoring snapshot tables.
  - `slicing_exprs` (array of string, optional)
    List of column expressions to slice data with for targeted analysis. The data is grouped by
     each expression independently, resulting in a separate slice for each predicate and its
     complements. For example `slicing_exprs=[“col_1”, “col_2 > 10”]` will generate the following
     slices: two slices for `col_2 > 10` (True and False), and one slice per unique value in
     `col1`. For high-cardinality columns, only the top 100 unique values by frequency will
     generate slices.
  - `custom_metrics` (array of object, optional)
    Custom metrics.
    - `name` (string, required)
      Name of the metric in the output tables.
    - `definition` (string, required)
      Jinja template for a SQL expression that specifies how to compute the metric. See [create metric definition](https://docs.databricks.com/en/lakehouse-monitoring/custom-metrics.html#create-definition).
    - `input_columns` (array of string, required)
      A list of column names in the input table the metric should be computed for.
       Can use ``":table"`` to indicate that the metric needs information from multiple columns.
    - `output_data_type` (string, required)
      The output type of the custom metric.
    - `type` (string, required)
      The type of the custom metric.
      Possible values:
      - `DATA_PROFILING_CUSTOM_METRIC_TYPE_AGGREGATE`
      - `DATA_PROFILING_CUSTOM_METRIC_TYPE_DERIVED`
      - `DATA_PROFILING_CUSTOM_METRIC_TYPE_DRIFT`
  - `baseline_table_name` (string, optional)
    Baseline table name.
     Baseline data is used to compute drift from the data in the monitored `table_name`.
     The baseline table and the monitored table shall have the same schema.
  - `schedule` (object, optional)
    The cron schedule.
    - `quartz_cron_expression` (string, required)
      The expression that determines when to run the monitor. See [examples](https://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html).
    - `timezone_id` (string, required)
      A Java timezone id. The schedule for a job will be resolved with respect to this timezone.
       See `Java TimeZone <http://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html>`_ for details.
       The timezone id (e.g., ``America/Los_Angeles``) in which to evaluate the quartz expression.
  - `notification_settings` (object, optional)
    Field for specifying notification settings.
    - `on_failure` (object, optional)
      Destinations to send notifications on failure/timeout.
      - `email_addresses` (array of string, optional)
        The list of email addresses to send the notification to. A maximum of 5 email addresses is supported.
      - `destination_ids` (array of string, optional)
        The notification-destination IDs (Slack / Teams / webhook / Asana / ServiceNow / AWS
         EventBridge) to send the notification to. The destinations must already exist in the
         workspace; a workspace admin creates them. A maximum of 25 destination IDs is supported.
         Only supported on schema monitors, via `anomaly_detection_config`; rejected on table monitors.
      - `destination_user_ids` (array of int64, optional)
        The IDs of the workspace users to notify by email. A maximum of 25 user IDs is supported.
         Only supported on schema monitors, via `anomaly_detection_config`; rejected on table monitors.
    - `on_unhealthy_table` (object, optional)
      Recipients to notify when anomaly detection finds unhealthy tables in the schema. Each
       recipient gets one notification per important unhealthy table. Only supported on schema
       monitors, via `anomaly_detection_config`.
      - `email_addresses` (array of string, optional)
        The list of email addresses to send the notification to. A maximum of 5 email addresses is supported.
      - `destination_ids` (array of string, optional)
        The notification-destination IDs (Slack / Teams / webhook / Asana / ServiceNow / AWS
         EventBridge) to send the notification to. The destinations must already exist in the
         workspace; a workspace admin creates them. A maximum of 25 destination IDs is supported.
         Only supported on schema monitors, via `anomaly_detection_config`; rejected on table monitors.
      - `destination_user_ids` (array of int64, optional)
        The IDs of the workspace users to notify by email. A maximum of 25 user IDs is supported.
         Only supported on schema monitors, via `anomaly_detection_config`; rejected on table monitors.
  - `skip_builtin_dashboard` (boolean, optional, Input only)
    Whether to skip creating a default dashboard summarizing data quality metrics.
  - `warehouse_id` (string, optional, Input only)
    Optional argument to specify the warehouse for dashboard creation. If not specified, the first running
     warehouse will be used.

## Returns

Returns the Monitor object.

## Response

```json
{
  "object_type": "schema",
  "object_id": "string",
  "anomaly_detection_config": {
    "excluded_table_full_names": [
      "string"
    ],
    "notification_settings": {}
  },
  "data_profiling_config": {
    "output_schema_id": "string",
    "assets_dir": "string",
    "inference_log": {},
    "time_series": {},
    "snapshot": {},
    "slicing_exprs": [
      "string"
    ],
    "custom_metrics": [
      {}
    ],
    "baseline_table_name": "string",
    "schedule": {},
    "notification_settings": {},
    "monitored_table_name": "string",
    "status": "DATA_PROFILING_STATUS_ACTIVE",
    "latest_monitor_failure_message": "string",
    "profile_metrics_table_name": "string",
    "drift_metrics_table_name": "string",
    "dashboard_id": "string",
    "monitor_version": 0,
    "effective_warehouse_id": "string"
  }
}
```

