You are here:
Define Relative Time-Window Metrics
Get real-time Data Cloud insights with metrics based on rolling time windows. Determine metrics using relative timeframes, such as a specified number of past seconds, minutes, or days.
Calculated Insights Time-Window Metrics
For calculated insights, use the NOW function to establish dynamic or
relative time windows. The SECOND_ADD and SECOND_SUB
functions provide more precise control to define the exact time window for your metrics.
- Availability:
- The
NOW,SECOND_ADD, andSECOND_SUBfunctions are available in the transform node for Visual Insight Builder. - These functions are included in the SQL Functions for Insights.
- The
- Filtering: You can define a relative time filter with the Visual Builder filter node "Relative DateTime operator" option.
- Flexibility: You can define and calculate dynamic metrics over configurable time intervals, from seconds to years (365+ days).
Real-Time Time-Window Metrics
Use dynamic time-window metrics for real-time calculation of metrics over specific time frames. Use these metrics for personalized product recommendations informed by recent activity. For instance, you can:
- Count website interactions for the last 10 minutes to recommend products similar to recent views.
- Remove products that weren’t viewed in the last 10 minutes.
How Real-Time Insights Update Metrics
Real-time insights update metrics when a data event is processed.
- Calculation at query time: The value for this metric is calculated at graph query time.
- Handling no events: When no events are processed, the metric value is calculated based on the defined relative time window. For example, if your metric is "count of product clicks for the last ten minutes," and no clicks occur during this time, the metric is 0.
- Client-side processing: Real-time graph clients must process the real-time insight data from the client side to get the true metric at graph query time.
Streamlining Data Aggregation with Submetrics and Time Buckets
To streamline data aggregation and minimize storage within the real-time graph, the time-window process employs submetrics and time buckets within the user-defined time interval. This process eliminates the need to store every event in the real-time graph.
- How it works: When processing a real-time event, the
NOWfunction compares the event time of each event within a 5-minute sub-time window to determine the appropriate window size. The function applies five different window types in a hierarchical order, with each type covering a specific time range relative to the compute time. - Automatic dimension creation: When a dynamic time window is defined, the function
creates the dimensions
window_start__candwindow_end__cas real-time insight dimensions. - Improved storage cost: The time window process can result in an approximate metric rather than an exact count of events. The process is optimized to store the most recent data in smaller, precise buckets, grouping older data into larger buckets, to balance accuracy with storage cost.
Window Types and Logic:
- Five-Minute Windows (Most Recent Data)
- Covers: Last 1 hour from compute time
- Maximum Buckets: 12 (ensures at least 1 hour of coverage)
- One-Hour Windows (Recent Data)
- Covers: From 1 hour ago to 1 day ago
- Maximum Buckets: 23
- Daily Windows (Medium-Term Historical Data)
- Covers: From 1 day ago to 1 month ago
- Bucket Examples: [2025-03-19 00:00 - 23:59], [2025-03-20 00:00 - 23:59]
- Maximum Buckets: ~30 (varies by length of month)
- Monthly Windows (Long-Term Historical Data)
- Covers: From 1 month ago to 1 year ago
- Bucket Examples: [2025-02-01 00:00 - 2025-02-28 23:59], [2025-03-01 00:00 - 2025-03-31 23:59]
- Maximum Buckets: 11
- Yearly Windows (Oldest Data)
- Covers: All data older than 1 year from compute time
- Bucket Examples: [2024-01-01 00:00 - 2024-12-31 23:59], [2023-01-01 00:00 - 2023-12-31 23:59]
- Maximum Buckets: Unlimited (depends on data age)
Example: Processing 25 Months of Minute-Level Data
- Dataset: Records every minute from April 1, 2023, to May 1, 2025
- Compute Time: May 1, 2025, 10:30 AM
- Total Records: ~1,081,440 records
| Window Type | Time Range | DMO Event Count | Real Time Graph Aggregate Count |
|---|---|---|---|
| 5-minute | May 1, 2025 09:30-10:30 | 60 records | 12 records |
| 1-hour | April 30, 2025 10:30 to May 1, 2025 09:30 | 1380 records | 23 records |
| Daily | March 31 to April 30, 2025 | 44,640 records | 31 records |
| Monthly | May 1, 2024 to March 31, 2025 | 525,600 records | 11 records |
| Yearly | April 1, 2023 May 1, 2024 | 525,600 records | 2 records |

