Rule templates

Updated at:

Data Quality rule templates reduce the effort of writing Specs. A set of commonly used templates is built in, and you can also create custom templates. Templates predefine most of the settings that a Spec requires, so when you create a rule from a template, you only need to configure the additional settings.

Use system rule templates

The following example creates a rule from the Average value, 1-, 7-, and 30-day volatility rate system rule template:

datasets:
  - type: Table
    tables:
      - tb_d_spec_demo
    filter: "dt='$[yyyymmdd]' AND hh='$[hh24-1/24]'"
    dataSource:
      name: odps_first
      envType: Dev
rules:
  - templateId: "SYSTEM:field:avg:flux:1_7_1m_bizdate"
    fields:
      - col_income
    warn: "when > 1%"
    fail: "when > 10%"

The preceding code snippet creates a Data Quality monitoring rule that references the Average value, 1-, 7-, and 30-day volatility rate system rule template. The settings are as follows:

  • templateId: The Id of the rule template that you want to use. For more rule template IDs, see System rule template list. You can also create a custom rule template and reference Use custom rule templates to create a rule.

  • templateParameters: The parameters that the rule template requires. Different rule templates require different parameters. A common parameter is fields, which specifies the list of fields that the rule monitors.

    For the parameters that each rule template requires, see System rule template list

  • warn/fail: The thresholds.

Use custom rule templates

If system rule templates cannot meet your requirements, or if many of your custom SQL rules contain the same SQL statement, you can create custom rule templates.

Define a custom template

The following example shows the Spec configuration of a custom rule template:

name: "id non-null row count check"
id: "1760d075-00bd-43c9-be8f-3c9a4bac35db"
assertion: "id_not_null_row_count = 0"
id_not_null_row_count:
  query: "SELECT COUNT(*) FROM ${table} WHERE dt = '$[yyyymmdd-1]';"
catalog: "ods_layer/timeliness_check"

The preceding code snippet defines a simple custom rule template that contains the following fields:

  • name: The name of the template.

  • id: The unique identifier of the template. Make sure that the identifier is globally unique. To reference the template, use this identifier.

  • assertion: The description of the rule. The syntax follows the Data Quality Spec configuration topic's assertion field.

    id_not_null_row_count: In this example, the assertion references the metric definition. In the query, you can use ${tableName} in place of the table name. When you create a rule from this rule template, the placeholder is replaced with the name of the table that the rule monitors. You can also reference system time parameters directly (for details about how to reference time parameters, see Configure data filtering).

  • catalog: The category of the rule template. You can manage rule templates by category. Separate multiple levels of categories with /.

Threshold settings in custom templates

Fixed and non-fixed thresholds

The following example shows the configuration of a non-fixed threshold:

name: "id non-null row count check"
id: "1760d075-00bd-43c9-be8f-3c9a4bac35db"
assertion: "id_not_null_row_count"
id_not_null_row_count:
  query: "SELECT COUNT(*) FROM ${table} WHERE dt = '$[yyyymmdd-1]';"

Volatility thresholds

name: "id non-null row count check"
id: "1760d075-00bd-43c9-be8f-3c9a4bac35db"
assertion: "change avg last 7 days percent for id_not_null_row_count"
id_not_null_row_count:
  query: "SELECT COUNT(*) FROM ${table} WHERE dt = '$[yyyymmdd-1]';"

Create a rule from a custom template

  • Example 1

    datasets:
      - type: Table
        tables:
          - tb_d_spec_demo
        filter: "dt='$[yyyymmdd]' AND hh='$[hh24-1/24]'"
        dataSource:
          name: odps_first
          envType: Dev
    rules:
      - templateId: "1760d075-00bd-43c9-be8f-3c9a4bac35db"
        # Use fail to define the failure threshold
        fail: "when != 0"
  • Example 2

    datasets:
      - type: Table
        tables:
          - tb_d_spec_demo
        filter: "dt='$[yyyymmdd]' AND hh='$[hh24-1/24]'"
        dataSource:
          name: odps_first
          envType: Dev
    rules:
      - templateId: "1760d075-00bd-43c9-be8f-3c9a4bac35db"
        warn: "when between 1 and 10)"
        fail: "when > 10"
  • Example 2

    datasets:
      - type: Table
        tables:
          - tb_d_spec_demo
        filter: "dt='$[yyyymmdd]' AND hh='$[hh24-1/24]'"
        dataSource:
          name: odps_first
          envType: Dev
    rules:
      - templateId: "1760d075-00bd-43c9-be8f-3c9a4bac35db"
        warn: "when not between -1% and 1%"
        fail: "when not between -10% and 10%"

System rule template list

Id

Template

Required fields

Example

SYSTEM:table:table_count:fixed

Table row count, fixed value

pass

templateId: "SYSTEM:table:table_count:fixed"
pass: "when > 0"

SYSTEM:table:table_count:fixed:0

Table row count greater than 0

-

templateId: "SYSTEM:table:table_count:fixed:0"

SYSTEM:table:table_count_delta:fixed:1_bizdate

Table row count, 1-day difference

pass

templateId: "SYSTEM:table:table_count_delta:fixed:1_bizdate"
pass: "when < 10"

SYSTEM:table:table_count_delta:fixed:latest_bizdate

Table row count, difference from the previous cycle

pass

templateId: "SYSTEM:table:table_count_delta:fixed:latest_bizdate"
pass: "when < 10"

SYSTEM:table:table_count:flux:1_7_1m_bizdate

Table row count, 1-, 7-, and 30-day volatility rate

  • warn

  • fail

templateId: "SYSTEM:table:table_count:flux:1_7_1m_bizdate"
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:table:table_count:flux:1_7_1m_1st_bizdate

Table row count, 1-, 7-, and 30-day volatility rate and volatility rate from the first day of the current month

  • warn

  • fail

templateId: "SYSTEM:table:table_count:flux:1_7_1m_1st_bizdate"
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:table:table_count:flux:1_bizdate

Table row count, 1-day volatility rate

  • warn

  • fail

templateId: "SYSTEM:table:table_count:flux:1_bizdate"
warn: "when < -1%"
fail: "when < -5%"

SYSTEM:table:table_count:flux:1m_bizdate

Table row count, 30-day volatility rate

  • warn

  • fail

templateId: "SYSTEM:table:table_count:flux:1m_bizdate"
warn: "when < -1%"
fail: "when < -5%"

SYSTEM:table:table_count:flux:7_bizdate

Table row count, 7-day volatility rate

  • warn

  • fail

templateId: "SYSTEM:table:table_count:flux:7_bizdate"
warn: "when < -1%"
fail: "when < -5%"

SYSTEM:table:table_count:dynamic_threshold

Table row count, dynamic threshold

-

templateId: "SYSTEM:table:table_count:dynamic_threshold"

SYSTEM:table:table_count:avg:7_bizdate

Table row count, 7-day average volatility rate

  • warn

  • fail

templateId: "SYSTEM:table:table_count:avg:7_bizdate"
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:table:table_count:avg:1m_bizdate

Table row count, 30-day average volatility rate

  • warn

  • fail

templateId: "SYSTEM:table:table_count:avg:1m_bizdate"
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:table:table_count:cycle:latest_bizdate

Table row count, volatility rate from the previous cycle

  • warn

  • fail

templateId: "SYSTEM:table:table_count:cycle:latest_bizdate"
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:table:table_size:fixed

Table size, fixed value

pass

templateId: "SYSTEM:table:table_size:fixed"
pass: "when > 0"

SYSTEM:table:table_size_delta:fixed:1_bizdate

Table size, difference from 1 day ago (bytes)

pass

templateId: "SYSTEM:table:table_size_delta:fixed:1_bizdate"
pass: "when > 0"

SYSTEM:table:table_size_delta:fixed:latest_bizdate

Table size, difference from the previous cycle

pass

templateId: "SYSTEM:table:table_size_delta:fixed:latest_bizdate"
pass: "when > 0"

SYSTEM:table:table_size:flux:1_bizdate

Table size, 1-day volatility rate

  • warn

  • fail

templateId: "SYSTEM:table:table_size:flux:1_bizdate"
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:table:table_size:flux:1m_bizdate

Table size, 30-day volatility rate

  • warn

  • fail

templateId: "SYSTEM:table:table_size:flux:1m_bizdate"
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:table:table_size:flux:7_bizdate

Table size, 7-day volatility rate

  • warn

  • fail

templateId: "SYSTEM:table:table_size:flux:7_bizdate"
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:table:table_size:dynamic_threshold

Table size, dynamic threshold

-

templateId: "SYSTEM:table:table_size:dynamic_threshold"

SYSTEM:table:schema:any_changes

Table schema evolution - any change

-

templateId: "SYSTEM:table:schema:any_changes"

SYSTEM:table:schema:column_delete

Table schema evolution - column deleted

-

templateId: "SYSTEM:table:schema:column_delete"

SYSTEM:table:schema:column_add

Table schema evolution - column added

-

templateId: "SYSTEM:table:schema:column_add"

SYSTEM:table:schema:column_index_change

Table schema evolution - column order changed

-

templateId: "SYSTEM:table:schema:column_index_change"

SYSTEM:table:schema:column_type_change

Table schema evolution - column data type changed

-

templateId: "SYSTEM:table:schema:column_type_change"

SYSTEM:field:null_value:fixed

Null value count, fixed value

  • fields

  • pass

templateId: "SYSTEM:field:null_value:fixed"
fields:
  - id
pass: "when > 0"

SYSTEM:field:null_value:fixed:0

Null value record count is 0

fields

templateId: "SYSTEM:field:null_value:fixed:0"
fields:
  - id

SYSTEM:field:null_value_percent:fixed

Null value count/total row count, fixed value

  • fields

  • pass

templateId: "SYSTEM:field:null_value_percent:fixed"
fields:
  - id
pass: "when > 0"

SYSTEM:field:pattern_match:fixed

Regular expression check

  • fields

  • valid

    • regex

  • templateParameters

    • metric

  • pass

templateId: "SYSTEM:field:pattern_match:fixed"
templateParameters:
  metric: invalid_distinct_count
fields:
  - id
valid:
  regex: "[0-9]+"
pass: "when > 0"

SYSTEM:field:pattern_match_date:fixed

Date format check

  • fields

  • valid

    • format

  • templateParameters

    • metric

  • pass

templateId: "SYSTEM:field:pattern_match_date:fixed"
templateParameters:
  metric: invalid_count
fields:
  - id
valid:
  format: date_yyyymmdd
pass: "when > 0"

SYSTEM:field:pattern_match_email:fixed

Email address format check

  • fields

  • templateParameters

    • metric

  • pass

templateId: "SYSTEM:field:pattern_match_email:fixed"
templateParameters:
  metric: invalid_count
fields:
  - id
pass: "when > 0"

SYSTEM:field:pattern_match_idcard:fixed

ID card number format check

  • fields

  • templateParameters

    • metric

  • pass

templateId: "SYSTEM:field:pattern_match_idcard:fixed"
templateParameters:
  metric: invalid_count
fields:
  - id
pass: "when > 0"

SYSTEM:field:pattern_match_mobile_number:fixed

Mobile phone number format check

  • fields

  • templateParameters

    • metric

  • pass

templateId: "SYSTEM:field:pattern_match_mobile_number:fixed"
templateParameters:
  metric: invalid_count
fields:
  - id
pass: "when > 0"

SYSTEM:field:pattern_match_money:fixed

Currency format check

  • fields

  • valid

    • format

  • templateParameters

    • metric

  • pass

templateId: "SYSTEM:field:pattern_match_money:fixed"
templateParameters:
  metric: invalid_count
fields:
  - id
valid:
  format: CNY
pass: "when > 0"

SYSTEM:field:pattern_match_number:fixed

Numeric format check

  • fields

  • templateParameters

    • metric

  • pass

templateId: "SYSTEM:field:pattern_match_number:fixed"
templateParameters:
  metric: invalid_count
fields:
  - id
pass: "when > 0"

SYSTEM:field:pattern_match_phone_number:fixed

Phone number format check

  • fields

  • templateParameters

    • metric

  • pass

templateId: "SYSTEM:field:pattern_match_phone_number:fixed"
templateParameters:
  metric: invalid_count
fields:
  - id
pass: "when > 0"

SYSTEM:field:duplicated_count:fixed

Duplicate value count, fixed value

  • fields

  • pass

templateId: "SYSTEM:field:duplicated_count:fixed"
fields:
  - id
pass: "when > 0"

SYSTEM:field:duplicated_count:fixed:0

Duplicate value count for the field is 0

fields

templateId: "SYSTEM:field:duplicated_count:fixed:0"
fields:
  - id

SYSTEM:fields:duplicated_count:fixed:0

Duplicate value count for multiple fields is 0

fields

templateId: "SYSTEM:fields:duplicated_count:fixed:0"
fields:
  - id
  - name

SYSTEM:field:duplicated_percent:fixed

Duplicate value count/total row count, fixed value

  • fields

  • pass

templateId: "SYSTEM:field:duplicated_percent:fixed"
fields:
  - id
pass: "when > 0"

SYSTEM:field:count_distinct:fixed

Unique value count, fixed value

  • fields

  • pass

templateId: "SYSTEM:field:count_distinct:fixed"
fields:
  - id
pass: "when > 0"

SYSTEM:field:count_distinct:flux:1_7_1m_bizdate

Unique value count, 1-, 7-, and 30-day volatility rate

  • fields

  • warn

  • fail

templateId: "SYSTEM:field:count_distinct:flux:1_7_1m_bizdate"
fields:
  - id
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:table:distinct_count:dynamic_threshold

Unique value count, dynamic threshold

  • fields

  • pass

templateId: "SYSTEM:table:distinct_count:dynamic_threshold"
fields:
  - id

SYSTEM:field:count_distinct_percent:fixed

Unique value count/total row count, fixed value

  • fields

  • pass

templateId: "SYSTEM:field:count_distinct_percent:fixed"
fields:
  - id
pass: "when > 0"

SYSTEM:field:min:flux:1_7_1m_bizdate

Minimum value, 1-, 7-, and 30-day volatility rate

  • fields

  • warn

  • fail

templateId: "SYSTEM:field:min:flux:1_7_1m_bizdate"
fields:
  - id
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:field:min:dynamic_threshold

Minimum value, dynamic threshold

fields

templateId: "SYSTEM:field:min:dynamic_threshold"
fields:
  - id

SYSTEM:field:min:cycle:1_bizdate

Minimum value, 1-day volatility rate

  • fields

  • warn

  • fail

templateId: "SYSTEM:field:min:cycle:1_bizdate"
fields:
  - id
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:field:min:cycle:latest_bizdate

Minimum value, volatility rate from the previous cycle

  • fields

  • warn

  • fail

templateId: "SYSTEM:field:min:cycle:latest_bizdate"
fields:
  - id
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:field:min:flux:1_7_1m_bizdate

Maximum value, 1-, 7-, and 30-day volatility rate

  • fields

  • warn

  • fail

templateId: "SYSTEM:field:min:flux:1_7_1m_bizdate"
fields:
  - id
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:field:max:dynamic_threshold

Maximum value, dynamic threshold

fields

templateId: "SYSTEM:field:max:dynamic_threshold"
fields:
  - id

SYSTEM:field:max:cycle:1_bizdate

Maximum value, 1-day volatility rate

  • fields

  • warn

  • fail

templateId: "SYSTEM:field:max:cycle:1_bizdate"
fields:
  - id
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:field:max:cycle:latest_bizdate

Maximum value, volatility rate from the previous cycle

  • fields

  • warn

  • fail

templateId: "SYSTEM:field:max:cycle:latest_bizdate"
fields:
  - id
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:field:avg:flux:1_7_1m_bizdate

Average value, 1-, 7-, and 30-day volatility rate

  • fields

  • warn

  • fail

templateId: "SYSTEM:field:avg:flux:1_7_1m_bizdate"
fields:
  - id
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:field:avg:dynamic_threshold

Average value, dynamic threshold

fields

templateId: "SYSTEM:field:avg:dynamic_threshold"
fields:
  - id

SYSTEM:field:avg:cycle:1_bizdate

Average value, 1-day volatility rate

  • fields

  • warn

  • fail

templateId: "SYSTEM:field:avg:cycle:1_bizdate"
fields:
  - id
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:field:sum:flux:1_7_1m_bizdate

Sum, 1-, 7-, and 30-day volatility rate

  • fields

  • warn

  • fail

templateId: "SYSTEM:field:sum:flux:1_7_1m_bizdate"
fields:
  - id
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:field:sum:dynamic_threshold

Sum, dynamic threshold

fields

templateId: "SYSTEM:field:avg:dynamic_threshold"
fields:
  - id

SYSTEM:field:sum:cycle:1_bizdate

Sum, 1-day volatility rate

  • fields

  • warn

  • fail

templateId: "SYSTEM:field:sum:cycle:1_bizdate"
fields:
  - id
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:field:sum:cycle:latest_bizdate

Sum, volatility rate from the previous cycle

  • fields

  • warn

  • fail

templateId: "SYSTEM:field:sum:cycle:latest_bizdate"
fields:
  - id
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:field:count_distinct_not_in:fixed

Count of unique values that do not match the enumeration, fixed value

  • fields

  • valid

    • values

  • pass

templateId: "SYSTEM:field:count_distinct_not_in:fixed"
fields:
  - gender
valid:
  values:
    - male
    - female
pass: "when = 0"

SYSTEM:field:count_not_in:fixed

Count of rows that do not match the enumeration, fixed value

  • fields

  • valid

    • values

  • pass

templateId: "SYSTEM:field:count_not_in:fixed"
fields:
  - gender
valid:
  values:
    - male
    - female
pass: "when = 0"

SYSTEM:field:count_not_in:fixed:0

Count of rows that do not match the enumeration is 0

  • fields

  • valid

    • values

templateId: "SYSTEM:field:count_not_in:fixed"
fields:
  - gender
valid:
  values:
    - male
    - female

SYSTEM:field:field_enum:fixed

Enumeration values, custom, fixed value

  • fields

  • valid

    • values

  • templateParameters

    • metirc

  • pass

templateId: "SYSTEM:field:count_not_in:fixed"
templateParameters:
  metric: invalid_count
fields:
  - gender
valid:
  values:
    - male
    - female
pass: "when > 0"

SYSTEM:field:all_discrete_count:fixed

Discrete values (status values), fixed value

  • fields

  • pass

templateId: "SYSTEM:field:all_discrete_count:fixed"
fields:
  - gender
pass: "when > 0"

SYSTEM:field:discrete_group_count:fixed

Discrete values (group count), fixed value

  • fields

  • pass

templateId: "SYSTEM:field:discrete_group_count:fixed"
fields:
  - gender
pass: "when > 0"

SYSTEM:field:discrete_group_count:dynamic_threshold

Discrete values (group count), dynamic threshold

fields

templateId: "SYSTEM:field:discrete_group_count:dynamic_threshold"
fields:
  - gender

SYSTEM:field:discrete_value_count:dynamic_threshold

Discrete values (status values), dynamic threshold

fields

templateId: "SYSTEM:field:discrete_value_count:dynamic_threshold"
fields:
  - gender

SYSTEM:field:discrete_group_count:cycle:latest_bizdate

Discrete values (group count), 1-day volatility rate

  • fields

  • warn

  • fail

templateId: "SYSTEM:field:discrete_group_count:cycle:latest_bizdate"
fields:
  - gender
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:field:all_discrete_metrics:fluxdiscrete:1_7_1m_bizdate

Discrete values (group count and status values), 1-, 7-, and 30-day volatility rate

  • fields

  • warn

  • fail

templateId: "SYSTEM:field:all_discrete_metrics:fluxdiscrete:1_7_1m_bizdate"
fields:
  - gender
warn: "when not between -5% and 5%"
fail: "when not between -10% and 10%"

SYSTEM:table:table_count:flux

Table row count, custom-period volatility

  • templateParameters.timeOffset

  • warn

  • fail

timeOffset is a historical sample offset string, such as 7 days ago. Configure the target datasets and provide comparable historical run records.

templateId: SYSTEM:table:table_count:flux
templateParameters:
  timeOffset: 7 days ago
warn:
  - when not between -1% and 1%
fail:
  - when not between -10% and 10%

SYSTEM:table:table_count_delta:fixed

Table row count, custom-period difference

  • templateParameters.timeOffset

  • pass

timeOffset is a historical sample offset string, such as 7 days ago. Configure the target datasets and provide comparable historical run records.

templateId: SYSTEM:table:table_count_delta:fixed
templateParameters:
  timeOffset: 7 days ago
pass:
  - when = 0

SYSTEM:fields:mapping_consistency_count:fixed

Field mapping consistency

  • templateParameters.fieldMap

  • templateParameters.valueMap

  • pass

templateId: SYSTEM:fields:mapping_consistency_count:fixed
templateParameters:
  fieldMap:
    - user_code: user_name
  valueMap:
    - '100': Alice
    - '101': Tony
pass:
  - when = 0
name: Field mapping consistency

SYSTEM:field:json_key_missing_count:fixed

JSON key presence check

  • templateParameters.jsonPath

  • fields

  • pass

templateId: SYSTEM:field:json_key_missing_count:fixed
templateParameters:
  jsonPath: $.user.id
fields:
  - payload
pass:
  - when = 0
name: JSON key presence check

SYSTEM:field:json_value_invalid_count:fixed

JSON value format check

  • templateParameters.jsonPath

  • valid.regex

  • fields

  • pass

templateId: SYSTEM:field:json_value_invalid_count:fixed
templateParameters:
  jsonPath: $.user.id
valid:
  regex: "^[a-zA-Z0-9_]+$"
fields:
  - payload
pass:
  - when = 0
name: JSON value format check

SYSTEM:field:delay_count:fixed

Data delay, time difference check between adjacent rows

  • templateParameters.orderBy

  • fields

  • filter

  • delay.maxInterval

  • pass

templateId: SYSTEM:field:delay_count:fixed
templateParameters:
  orderBy: event_id
fields:
  - event_time
filter: event_time IS NOT NULL
delay:
  maxInterval: 10 minutes
  fieldFormat: yyyy-MM-dd HH:mm:ss
pass:
  - when = 0
name: Data delay, time difference check between adjacent rows

SYSTEM:field:group_by_metric_check:fixed

Grouped metric check, fixed value

  • templateParameters.metric

  • fields

  • pass

templateId: SYSTEM:field:group_by_metric_check:fixed
templateParameters:
  metric: sum(amount)
fields:
  - category
pass:
  - when = 0
name: Grouped metric check, fixed value

SYSTEM:field:group_by_metric_check:flux

Grouped metric check, historical volatility

  • templateParameters.metric

  • templateParameters.timeOffset

  • fields

  • warn

  • fail

templateId: SYSTEM:field:group_by_metric_check:flux
templateParameters:
  metric: sum(amount)
  timeOffset: 7 day ago
fields:
  - category
warn:
  - when > 1%
fail:
  - when > 10%
name: Grouped metric check, historical volatility

Appendix: Configure custom-range system templates

The following custom-range system templates are configured differently from standard system templates and must be configured separately.

  • Conditional match percentage, custom range

    rules:
      - assertion: "matched_row_percent = 0"
        filter: "id IS NULL"
  • Field minimum value, custom range

    rules:
      - assertion: "anomal detection for min(income)"
  • Field maximum value, custom range

    rules:
      - assertion: "change avg last 7 days percent for max(income)"
        warn: "when > 0.1%"
        fail: "when > 0.5%"
  • Field average value, custom range

    rules:
      - assertion: "change var last 30 days percent for avg(income)"
        warn: "when < -0.1%"
        fail: "when < -0.5%"
  • Field sum, custom range

    rules:
      - assertion: "change 1 days ago percent for sum(income)"
        warn: "when not between -0.1% and 0.1%"
        fail: "when not between -0.5% and 0.5%"
  • Custom SQL

    assertion is configured in the same way as described in Define a custom metric rule.
    rules:
      - assertion: "change percent for id_not_null_count"
        id_not_null_count:
          query: "SELECT COUNT(*) AS cnt FROM tb_spec_demo WHERE dt = '$[yyyymmdd]'"
        warn: "when not between -0.1% and 0.1%"
        fail: "when not between -0.5% and 0.5%"