Documentation Index
Fetch the complete documentation index at: https://private-7c7dfe99-page-updates.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Time series functions
The functions below are designed to be used withtimeSeries*() aggregate functions like
timeSeriesInstantRateToGrid,
timeSeriesLastToGrid,
and so on.
seriesDecomposeSTL
Introduced in: v24.1.0 Decomposes a series data using STL (Seasonal-Trend Decomposition Procedure Based on Loess) into a season, a trend and a residual component. Syntaxseries— An array of numeric valuesArray((U)Int8/16/32/64)orArray(Float*)period— A positive integerUInt8/16/32/64
Array(Array(Float32), Array(Float32), Array(Float32), Array(Float32))
Examples
Decompose series data using STL
Query
Response
seriesOutliersDetectTukey
Introduced in: v24.2.0 Detects outliers in series data using Tukey Fences. Syntaxseries— An array of numeric values.Array((UInt8/16/32/64))orArray(Float*)min_percentile— Optional. The minimum percentile to be used to calculate inter-quantile range (IQR). The value must be in range [0.02,0.98]. The default is 0.25.Float*max_percentile— Optional. The maximum percentile to be used to calculate inter-quantile range (IQR). The value must be in range [0.02,0.98]. The default is 0.75.Float*K— Optional. Non-negative constant value to detect mild or stronger outliers. The default value is 1.5.Float*
Array(Float32)
Examples
Basic outlier detection
Query
Response
Query
Response
seriesPeriodDetectFFT
Introduced in: v23.12.0 Finds the period of the given series data using FFT - Fast Fourier transform Syntaxseries— An array of numeric values.Array((U)Int8/16/32/64)orArray(Float*)
Float64
Examples
Period detection with simple pattern
Query
Response
Query
Response
timeSeriesCopyTag
Introduced in: v26.1.0 Copies a specified tag from one group of tags (src_group) to another (dest_group).
The function replaces any previous values of the copied tag in dest_group.
If the copied tag is not present in src_group, then the function will remove it from dest_group as well.
The function mimics the copying logic of the prometheus
group left/group right modifiers.
Syntax
dest_group— The destination group of tags.UInt64src_group— The source group of tags.UInt64tag_to_copy— The name of a tag to copy.String
dest_group along with the copied tags from src_group. UInt64
Examples
Example
Query
Response
timeSeriesCopyTags
Introduced in: v26.1.0 Copies specified tags from one group of tags (src_group) to another (dest_group).
The function replaces any previous values of the copied tags in dest_group.
If some of the copied tags don’t present in src_group then the function will remove them in dest_group as well.
The function mimics the copying logic of the prometheus
group left/group right modifiers.
Syntax
dest_group— The destination group of tags.UInt64src_group— The source group of tags.UInt64tags_to_copy— The names of tags to copy.Array(String)
dest_group along with the copied tags from src_group. UInt64
Examples
Example
Query
Response
timeSeriesExtractTag
Introduced in: v26.1.0 Extracts the value of a specified tag from the group. Returns NULL if not found. See also function timeSeriesGroupToTags(). SyntaxNullable(String)
Examples
Example
Query
Response
timeSeriesFromGrid
Introduced in: v25.8.0 Converts an array of values[x1, x2, x3, ...] to an array of tuples
[(start_timestamp, x1), (start_timestamp + step, x2), (start_timestamp + 2 * step, x3), ...].
The current timestamp is increased by step until it becomes greater than end_timestamp
If the number of the values doesn’t match the number of the timestamps, the function throws an exception.
NULL values in [x1, x2, x3, ...] are skipped but the current timestamp is still incremented.
For example, for [value1, NULL, x2] the function returns [(start_timestamp, x1), (start_timestamp + 2 * step, x2)].
Syntax
start_timestamp— Start of the grid.DateTime64orDateTimeorUInt32end_timestamp— End of the grid.DateTime64orDateTimeorUInt32step— Step of the grid in secondsDecimal64orDecimal32orUInt32/64values— Array of valuesArray(Float*)orArray(Nullable(Float*))
start_timestamp and step. Array(Tuple(DateTime64, Float64))
Examples
Usage example
Query
Response
timeSeriesGroupToSamplingKey
Introduced in: v26.4.0 Returns a stableUInt64 sampling key derived from the tags of a specified group.
The value is deterministic: identical input tags always produce the same key.
It’s intended as a sort key for sampling operators like limitk and limit_ratio.
Syntax
group— A group of tags.UInt64
UInt64 hash derived from the tags associated with the group. UInt64
Examples
Example
Query
Response
timeSeriesGroupToTags
Introduced in: v26.1.0 Returns the names and values of the tags associated with a specified group. See also function timeSeriesTagsToGroup(). SyntaxtimeSeriesTagsGroupToTags
Arguments
group— A group of tags.UInt64
(tag_name, tag_value).
The returned array is always sorted by tag_name and never contains the same tag_name more than once.
Array(Tuple(String, String))
Examples
Example
Query
Response
timeSeriesIdToGroup
Introduced in: v26.1.0 Returns the names and values of the tags associated with a specified identifier of a time series. See also function timeSeriesStoreTags(). SyntaxtimeSeriesIdToTagsGroup
Arguments
id— Identifier of a time series.UInt64orUInt128orUUIDorFixedString(16)
id of a time series. UInt64
Examples
Example
Query
Response
timeSeriesIdToTags
Introduced in: v25.8.0 Returns tags associated with a specified identifier of a time series. See also function timeSeriesStoreTags(). Syntaxid— Identifier of a time series.UInt64orUInt128orUUIDorFixedString(16)
(tag_name, tag_value).
The returned array is always sorted by tag_name and never contains the same tag_name more than once.
Array(Tuple(String, String))
Examples
Example
Query
Response
timeSeriesJoinTags
Introduced in: v26.1.0 Joins the values of specified tags extracted from a group of tags. The function inserts a separator between joined values and returns a new group of tags with the tagdest_tag set to the joined value.
This function mimics the logic of the prometheus function
label_join().
Syntax
group— A group of tags.UInt64dest_tag— The name of a tag with the joined result which will be added to thegroup.Stringseparator— A separator to insert between joined values.Stringsrc_tags— The names of source tags with values which will be joined.Array(String)
dest_tag tag set to the joined result. UInt64
Examples
Example
Query
Response
timeSeriesRange
Introduced in: v25.8.0 Generates a range of timestamps [start_timestamp, start_timestamp + step, start_timestamp + 2 * step, …, end_timestamp]. Ifstart_timestamp is equal to end_timestamp, the function returns a 1-element array containing [start_timestamp].
Function timeSeriesRange() is similar to function range.
Syntax
start_timestamp— Start of the range.DateTime64orDateTimeorUInt32end_timestamp— End of the range.DateTime64orDateTimeorUInt32step— Step of the range in secondsUInt32/64orDecimal32/64
Array(DateTime64)
Examples
Usage example
Query
Response
timeSeriesRemoveAllTagsExcept
Introduced in: v26.1.0 Removes all tags except specified ones from a group of tags. See also function timeSeriesRemoveTag(), timeSeriesRemoveTags(). Syntaxgroup— A group of tags.UInt64tags_to_keep— The names of tags to keep in the group.Array(String)
UInt64
Examples
Example
Query
Response
timeSeriesRemoveTag
Introduced in: v26.1.0 Removes a specified tag from a group of tags. If there is no such tag in the group then the group is returned unchanged. See also function timeSeriesRemoveTags(), timeSeriesRemoveAllTagsExcept(). SyntaxUInt64
Examples
Example
Query
Response
timeSeriesRemoveTags
Introduced in: v26.1.0 Removes specified tags from a group of tags. If some of the specified tags are not in the group of tags the function ignores them. See also function timeSeriesRemoveTag(), timeSeriesRemoveAllTagsExcept(). Syntaxgroup— A group of tags.UInt64tags_to_remove— The names of tags to remove from the group.Array(String)
UInt64
Examples
Example
Query
Response
timeSeriesReplaceTag
Introduced in: v26.1.0 Matches the regular expressionregex against the value of the tag src_tag.
If it matches, the value of the tag dest_tag in the returned group will be the expansion of replacement,
together with the original tags in the input.
This function mimics the logic of the prometheus function
label_replace().
Syntax
group— A group of tags.UInt64dest_tag— The name of a destination tag to get the result group.Stringreplacement— A replacement pattern, can contain 2 or $name to refer capturing groups in the regular expression ‘regex’.Stringsrc_tag— The name of a tag which value is used to match the regular expression ‘regex’.Stringregex— A regular expression.String
dest_tag added. UInt64
Examples
Example
Query
Response
timeSeriesStoreTags
Introduced in: v25.8.0 Stores in the query context a mapping between a specified identifier of a time series and a set of tags. Functions timeSeriesIdToTags() and timeSeriesIdToGroup() can be used to access this mapping later during the query execution. Syntaxid— Identifier of a time series.UInt64orUInt128orUUIDorFixedString(16)tags_array— Array of pairs (tag_name, tag_value).Array(Tuple(String, String))orNULLseparate_tag_name_i— The name of a tag.StringorFixedStringseparate_tag_value_i— The value of a tag.StringorFixedStringorNullable(String)
Query
Response
timeSeriesTagsToGroup
Introduced in: v26.1.0 Returns a group of tags associated with specified tags. If the same group of tags is found multiple times during the query execution, the function returns the same group. For an empty set of tags the function always returns 0. See also function timeSeriesGroupToTags(). Syntaxtags_array— Array of pairs (tag_name, tag_value).Array(Tuple(String, String))orNULLtag_name_i— The name of a tag.StringorFixedStringtag_value_i— The value of a tag.StringorFixedStringorNullable(String)
UInt64
Examples
Example
Query
Response
timeSeriesThrowDuplicateSeriesIf
Introduced in: v26.2.0 Checks thecondition and if it’s true throws an exception with the following message
Multiple series have the same tags <tags>, duplicate series in the same result set are not allowed.
If the condition is false the function returns 0.
This function is similar to throwIf(),
but uses a different error code and formats the error message differently.
Syntax
condition— Condition to check, usually contains function count()UInt8group— Group of tags.UInt64
0. UInt8
Examples
Example
Query
Response