ts(<metricName> [and|or [not] <metricName2>] ... [,|and|or [not] source="<sourceName>"] ... [and|or [not] tag="<sourceTag>"] ... [and|or [not] <pointTagKey>="<pointTagValue>"] ...)
Returns the time series that match the specified metric name, optionally filtered by sources and point tags.
ts() to display the time series in a time-series chart, or to specify the series to other functions.
|<metricName>||Name of a metric that describes one or more time series. Specify multiple metric names by including wildcards or by combining multiple names with Boolean operators. |
|source="<sourceName>"||Source of the time series to be returned. Time series from any other sources are filtered out of the result set. Specify any number of sources by combining them with Boolean operators. Omit this parameter to return metricName series from all sources.
|tag="<sourceTagName>"||Source tag that designates the sources of the time series to be returned. Series from any sources without the source tag are filtered out of the result set. Specify any number of source tags by combining them with Boolean operators. Omit this parameter to ignore source tags.
|<pointTagKey>="<pointTagValue>"||Point tag key and value that are associated with the time series to be returned. Series without the specified key-value pair are filtered out of the result set. Specify any number of point tags by combining them with Boolean operators. Omit this parameter to ignore point tags.
ts() function returns one or more time series. A time series is a sequence of data points that each consists of a data value and a timestamp. Every time series is identified by a unique combination of metric name, source name, and point tag values.
You visualize a time series by running
ts() as a top-level query in Query Editor under a time-series chart.
You can also use
ts() as an input
tsExpression that you specify to another query function, for example,
msum(10m, ts(~sample.disk.bytes.written, source="app-14"))
ts() function uses the specified parameters to select the time series to return:
Specify just the metric name to return all time series that match the name. For example, the following function returns all time series for
~sample.disk.bytes.written, which might be reported from multiple sources and have any number of point tags associated with them:
Filter the matched time series by specifying a combination of source names, source tags, and/or point tags. For example, the following function returns only the time series that are from either of 2 specified sources and that have an
envpoint tag with the value
ts(~sample.disk.bytes.written, (source="app-1" or source="app-2") and env="dev")
Note: As you type a
ts() function in Query Editor, you are prompted with metric name components, Boolean operators, keywords, and possible values.
A time series described by a
ts() function may be discrete or continuous, depending on how frequently and regularly the data points are reported.
The following chart shows the results of running
ts() as a top-level query. Because we include just the metric name
~sample.disk.bytes.written, the query returns all time series reported with that metric name.
We can add filters to narrow down the results. The following chart shows that two time series match the specified sources and point tag: