Telemetry - script API
StackState Self-hosted v5.1.x
Function: Telemetry.query(dataSourceName: String, query: String)
Telemetry.query(dataSourceName: String, query: String)
A telemetry query is a conjunction of equality conditions. For example, name = 'system.load.norm.15' and host='localhost'
. There are several builder methods available that help to refine the query time range, limit the number of points returned, or set a metric field.
Telemetry queries only support metric queries. If you need event queries, please enter a feature request at support.stackstate.com
Args
dataSourceName
- name of the data source.query
- set of equality conditions.
Returns
The output format of the Telemetry API changed in StackState v5.0. If you are running an earlier version of StackState, see the documentation for StackState v4.6 documentation (docs.stackstate.com/v/4.6).
StreamingScriptResult[MetricTimeSeriesResult]
Builder methods
.groupBy(fieldName: String)
- optional. Used to return grouped results from Elasticsearch. Requires.aggregation()
to be used. If there is no aggregation, a plain metric stream will be returned.aggregation(method: String, bucketSize: String)
- returns aggregated telemetry usingmethod
andbucketSize
. See the available aggregation methods.start(time: Instant)
- sets the start time of the query, for example-3h
.end(time: Instant)
- sets the end time of the query, for example-1h
.window(start: Instant, end: Instant)
- sets query time range. Use onlystart
to get all telemetry up to now or onlyend
to get all telemetry up to an instant in time.limit(points: Int)
- limits the number of points returned, applicable to non-aggregated queries.metricField(fieldName: String)
- optional, but may be required for some data sources. Sets a field that holds metric value.compileQuery()
- returns the telemetry query that was created with this function and the builder methods. After this builder method no more builder methods can be called.
Examples
Get metrics aggregated using Mean with bucket size 15 minutes and grouped by the field host
:
host
:Process the StreamingScriptResult result data, getting the ids of the resulting timeSeries
Get raw metric by query
Get metric aggregated using Mean with bucket size 1 minute
Query metrics starting 3 hours ago till now
Query metrics starting beginning of the data till last hour ago
Query metrics within time range starting 3 hours ago up to 1 hour ago
Query metrics from field "value" and limits points returned
See also
Last updated