Retrieval of last known value of data before query start Time

Overview

It is possible to ask Skyminer to retrieve with the data set requested the last known value of metrics for the same query.

This is useful for points that have a very low sampling rate, so data might not appear within the query, or data that is recorded in change-only mode, so the data might not appear, or just the changes in the results.

Description

The fetch_previous_sample option is designed to retrieve the last known value of the query.

It can be adapted to fit the purpose of the query: aligning sample time to query start time, merging with the data group or as a distinct data group, and the relative duration skyminer is allowed to go backward in time to find this sample before query start time.

This feature is not usable in queries requested in descending order (order:desc).

On the Web UI: check fetch previous samples option to enable the feature. The detailed setting appear. Those detailed setting are explained in the subsequent API section.

../_images/fetch-previous.png

The Web UI allows to define basic options only, advanced options (fetch previous samples far in the past or ask for more than one sample) are not desirable in most use cases so they are only enabled in using the API.

Usage in API

The API is at query level.

  • fetch_previous_sample : Object. Optional. If this field is set previous data will be returned

    • merge_groups: Boolean. Specifies if groups need to be merged or kept distinct. If the groups are not merged, previous data is returned in a distinct group named query_extension, with the value previous_data. Default is true.

    • time_align: Boolean. Specifies if the previous data sampling time has to be aligned to query start time. Default is false.

    • for_empty_results_only: Boolean. Only applies for if merge_groups is requested. If this flag is set to false the results are merged always with the original query results. Otherwise they are only merged if there is no data in the original query results. Default is true.

    • limit: Integer number. Number of samples to retrieve before query start time. Default is 1. It is not recommended to change this setting.

    • duration_relative: Object. Relative time to search for the last data sample in the past. It is the same format as relative query time. Default is 3 weeks. It is not recommended to change this setting.

Example of query (last 10 minutes, groups are merged, time not aligned, fetch last 5 samples) :

{
    "metrics": [... list of query metrics ...],
    "cache_time": 0,
    "start_relative": {
        "value": "1",
        "unit": "hours"
    },
    "fetch_previous_sample":{
        "duration_relative":{
        "value":10,
        "unit":"minutes"
        },
        "merge_groups":true,
        "limit":5,
        "time_align": false
    }
}

Example of query (default settings) :

{
    "metrics": [... list of query metrics ...],
    "cache_time": 0,
    "start_relative": {
        "value": "1",
        "unit": "hours"
    },
    "fetch_previous_sample":{}
}