Metrics

Overview

The Metrics monitor template applies statistical operations to analyze and understand the characteristics of datasets. It supports both dynamic and static thresholds (including relative thresholds) to trigger alerts based on aggregation results over specified time windows.

Previously known as Smart Metrics, this monitor detects anomalies using machine learning (ML) and seasonality-based thresholds. It also supports static thresholds, so you can monitor absolute or relative value deviations.

How To

Available Operations

Normalized Average

A value adjusted relative to a range of [0;1], often used to make data comparable across different sources or categories. It is also useful if you want to monitor trends while keeping actual values private.

Use Case: A large international retail enterprise uses normalized averages to compare sales data across different regions.

Sum

Calculates the total value by adding all individual values together. This operation gives a simple overview of the total magnitude of the values being monitored.

Distinct Count

Counts the number of unique values in a set, which helps in identifying the variety within the dataset.

Use Case: Counting unique customers or products sold.

Max (Maximum)

Identifies the largest value in a dataset, useful for spotting extreme occurrences.

Use Case: Displaying the maximum sales in a month.

Min (Minimum)

Identifies the smallest value, useful for finding the lower extremes in a dataset.

Use Case: Finding the lowest transaction amount in a day.

Average (Mean)

Calculates the central value by summing all values and dividing by the number of entries. It gives an idea of the typical value in the dataset.

Use Case: Calculating the average daily sales of a grocery store chain.

Variance

Measures how far each number in the dataset is from the mean, indicating the amount of spread in the data.

Use Case: Analyzing the variance of a restaurant bill per customer.

Standard Deviation

Quantifies the amount of variation or dispersion in a dataset.

Use Case: Assessing how far sales values deviate from the average.

Quantile

Divides a dataset into equal-sized subsets. Quantiles help in understanding the distribution and identifying median or percentile values.

Custom Aggregation

Lets you write a custom SQL aggregation. This query must return a unique numerical value. Use it to add an aggregate function that is not built-in inside Sifflet, or to compose several functions together.

⚠️

To insert fields inside this query, fields must use the special formatting: datasetId:fieldName.

In the UI, you can use the autocompletion to insert fields with this format. To trigger it, start typing the name of your table or field, and Sifflet lists your table's fields.

⚠️

Querying other tables is not allowed inside the SQL query. Use only the tables selected in the join clause defined earlier.

Examples

MEDIAN(datasetId:ColumnA)
SUM(datasetId1:field1) / SUM(datasetId2:field2)

Threshold Types

The Metrics monitor supports various types of thresholds to trigger alerts. You can configure the thresholds to be dynamic, static, or relative, depending on your monitoring needs.

Dynamic Threshold

Dynamic thresholds use machine learning (ML) to detect seasonality and anomalies in the data. These thresholds automatically adjust based on seasonal patterns, making them ideal for time-series data and anomaly detection.

Static Threshold

Static thresholds are predefined fixed limits. You set a minimum and/or maximum value, and Sifflet triggers an alert if the monitored data falls outside these boundaries. These are useful for straightforward, rule-based monitoring.

Relative Percentage Threshold

A relative threshold compares the current data with the previous time window's values using percentage-based changes. Sifflet triggers an alert when the value changes by a certain percentage beyond a defined range. This is useful for monitoring changes relative to previous performance.

Relative Threshold

A relative threshold compares the current data with the previous time window's values using the absolute difference, expressed in the same unit as the monitored value. Sifflet triggers an alert when the value changes by more than the amounts you define. This is useful when a fixed change, rather than a percentage, matters to you.


As Code

Threshold Examples

Dynamic Threshold

parameters:
  kind: Metrics
  field: COUNT_ITEMS
  aggregation:
    kind: Sum
  threshold:
    kind: Dynamic
    sensitivity: 26
  timeWindow:
    field: auto
    firstRun: P365D
    frequency: P1D

Explanation: This dynamic threshold monitor checks the COUNT_ITEMS field using a sum aggregation, with a sensitivity of 26. The threshold automatically adjusts based on seasonal patterns using machine learning and detects anomalies accordingly.

Static Threshold (Minimum)

parameters:
  kind: Metrics
  field: COUNT_ITEMS
  aggregation:
    kind: Sum
  threshold:
    kind: Static
    min: 0
  timeWindow:
    field: auto
    firstRun: P365D
    frequency: P1D

Explanation: This static threshold monitor checks the COUNT_ITEMS field using a sum aggregation and alerts if the value falls below 0.

Relative Percentage Threshold

parameters:
  kind: Metrics
  field: COUNT_ITEMS
  aggregation:
    kind: Sum
  threshold:
    kind: Static
    comparisonMode: RelativePercentage
    min: -5%
    isMinInclusive: false
    max: 5%
    isMaxInclusive: false
  timeWindow:
    field: auto
    firstRun: P365D
    frequency: P1D

Explanation: This monitor checks if the COUNT_ITEMS value increases by more than 5% or decreases by more than 5% relative to the previous period. Sifflet triggers an alert if the change exceeds this range.

Relative Threshold

parameters:
  kind: Metrics
  field: COUNT_ITEMS
  aggregation:
    kind: Sum
  threshold:
    kind: Static
    comparisonMode: Relative
    min: -100
    max: 100
  timeWindow:
    field: auto
    firstRun: P365D
    frequency: P1D

Explanation: This monitor checks if the COUNT_ITEMS value increases by more than 100 or decreases by more than 100 compared to the previous period. Sifflet triggers an alert if the change exceeds this range.


Time Window Configuration

You can configure Metrics monitors to operate over specific time windows. The timeWindow parameter is automatically set in the examples above with a frequency of P1D (daily), and the first run considers data from the past 365 days.

timeWindow:
  field: auto
  firstRun: P365D
  frequency: P1D

This configuration helps ensure that the thresholds are applied within a consistent time window, such as daily analysis or longer historical trends.


Did this page help you?