FuseQL Compare Operators :: Kloudfuse Docs

FuseQL Compare Operators

The compare operator enables you to analyze data across different time periods by comparing current aggregated metrics with historical values. This is useful for identifying trends, detecting anomalies, and understanding how metrics change over time.

compare timeshift

Compare current aggregated data with time-shifted historical data.

The compare operator can only be used after an aggregation operator (such as count, sum, avg, etc.). It requires aggregated data to perform time-based comparisons.

Syntax

| compare timeshift <duration> (1)

| compare timeshift <duration> <count> (2)

| compare timeshift <duration> as <alias> (3)

| compare timeshift <duration> as <alias>, timeshift <duration2> as <alias2> (4)
1 duration: Required. The time duration to shift back. Supported units: m (minutes), h (hours), d (days), w (weeks).
2 count: Optional. Number of time periods to compare. Creates multiple columns, one for each period. Default is 1.
3 alias: Optional. Custom name for the comparison column(s). If not specified, uses format <metric>_<duration>_<index>.
4 Multiple timeshifts can be specified, separated by commas, each with its own duration and optional alias.

Behavior

Column Naming

The operator generates column names based on the following rules:

Examples

Compare current day with yesterday

* | timeslice 1h | count by (_timeslice) | compare timeshift 1d

This query creates a column count_1d_1 containing the count from 24 hours ago for each time slice.

Compare with multiple previous days

* | timeslice 1h | count by (_timeslice) | compare timeshift 1d 7

This creates 7 columns (count_1d_1 through count_7d_7), each containing data from 1, 2, 3…​ up to 7 days ago.

Compare with custom aliases

* | timeslice 1h | count by (_timeslice) | compare timeshift 1d as yesterday, timeshift 1w as last_week

Creates columns count_yesterday and count_last_week for easy identification.

Compare service metrics by region

source="api" | timeslice 1h | count by (_timeslice, service, region) | compare timeshift 1d

Compares current metrics with yesterday’s data, grouped by service and region.

Compare average response time

* | timeslice 1h | avg(@duration:number) by (_timeslice) | compare timeshift 1d as yesterday, timeshift 1w as last_week

Compares average response times with both yesterday and last week.

Common Use Cases