Create Policy

Creates a new Policy

  • payload (PolicySchema): Required. The policy data to be created:
    • name (str): A descriptive name for this policy.
    • data_config: Configuration relevant to the retrieval of data for this policy:
      for compare distribution policy:
      • query_a (Query): Cube.js query.
      • query_b (Query): Cube.js query.
      • query_a_time_range_config: (TimeRangeConfig or None): Time range configuration for query A.
      • query_b_time_range_config: (TimeRangeConfig or None): Time range configuration for query B.
      • distance_function (DistanceFunction): Distance function to use.
        for statistics policy:
      • query (Query): Cube.js query.
      • time_range_config: (TimeRangeConfig): Time range configuration for the query.
    • cron_expression (str): Cron expression for policy evaluation.
    • condition_above_value (float or None): Condition above value.
    • condition_below_value (float or None): Condition below value.
    • destination_ids (list of UUID): List of communication channels to get notified through.
    • alert_on_status (AlertOnStatusDirection): Trigger policy action if the value is above/below.
    • alert_on_policy_level (bool): Trigger policy action on a single group/entire groups.
    • dataset_id (str): The dataset this policy is monitoring.
Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…

Creates a policy that monitors a dataset. A policy defines a metric, as a statistics query or a comparison of two distributions; a condition, as a static threshold or a moving average; how often it is evaluated; and where alerts are sent.

When to use it

Use it to detect issues automatically, such as a metric crossing a threshold or drifting from its history. To start from a predefined policy for an agent, use Create a policy from a template.

Required parameters

  • alert_on_policy_level (body): whether the policy action triggers on a single group or on the entire set of groups.
  • name (body): a descriptive name for the policy.
  • dataset_id (body): the ID of the dataset the policy monitors.
  • destination_ids (body): the IDs of the destinations to notify.
  • cron_expression (body): a cron expression that sets when the policy is evaluated.
  • threshold_settings (body): the condition: a static threshold with condition_above_value or condition_below_value, or a moving average with window_size and violation_deviation.
  • alert_on_status (body): when to alert: HEALTHY_TO_UNHEALTHY, UNHEALTHY_TO_HEALTHY, or BOTH.
  • data_config (body): the metric: a statistics query with a time range, or a comparison of two distribution queries with a distance function.

Optional body fields: dataset_b_id, description, initialize_with_historic_data.

Response

A successful call returns 201 Created with the PolicyResponse object, including id, name, status, data_config, threshold_settings, cron_expression, destination_ids, last_evaluation, and next_evaluation.

Related: Create a policy from a template, List policies, Trigger a policy, Create a destination

Body Params
boolean
required

Trigger policy action on a single group/entire groups

string
required

A descriptive name for this policy

string
required

The dataset this policy is monitoring

destination_ids
array of uuids
required

List of communication channels to get notified through

Destination Ids*
string
required

Cron expression for policy evaluation

threshold_settings
required
string
enum
required

Trigger policy action if the value is above/below

Allowed:
DataConfigStatistics | DataConfigDistributionCompare
required

The second dataset this policy is monitoring

A description for this policy

boolean
Defaults to false

If true, the policy will be initialized with historic data

Responses

422

Unprocessable Entity

500

Internal Server Error

Language
Credentials
OAuth2
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json