Series: query
Description
Retrieves time series objects for the specified metric, entity, tags, and date range. Applies common time series transformations including aggregation, interpolation, downsampling etc.
Quick Start
Basic query:
[{
  "metric":    "mpstat.cpu_busy",
  "entity":    "nurswgvml007",
  "startDate": "2018-05-20T00:00:00Z",
  "endDate":   "2018-05-20T01:00:00Z"
}]
Query response:
[{
  "metric":    "mpstat.cpu_busy",
  "entity":    "nurswgvml007",
  "data": [
    {"d":"2018-05-20T00:01:30Z", "v":24.2},
    {"d":"2018-05-20T00:03:15Z", "v":39.8},
    {"d":"2018-05-20T00:05:00Z", "v":39.1}
  ]
}]
Request
| Method | Path | Content-TypeHeader | 
|---|---|---|
| POST | /api/v1/series/query | application/json | 
The request payload is a JSON array containing query objects.
[{
  /* query 1: filter, transform, control */
},{
  /* query 2: filter, transform, control */
}]
The query contains filter fields to find time series in the database, transform fields to modify the matched series, and control fields to order and format the results.
Filters
Base Filter
| Field | Type | Description | 
|---|---|---|
| metric | string | [Required] Metric name. | 
| type | string | Data type: HISTORY,FORECAST,FORECAST_DEVIATION.Default: HISTORY | 
Entity Filter
- [Required]
- Refer to entity filter.
"entity": "nurswgvml007"
"entityGroup": "nur-prod-servers"
"entityExpression": "tags.location LIKE 'SVL*'"
Queries of
FORECASTandFORECAST_DEVIATIONtype do not support wildcards in the entity name and tag values. Tag value*matches all tags.
Tag Filter
| Field | Type | Description | 
|---|---|---|
| tags | object | Object with name:valuefields.Matches series that contain the specified series tags. Tag values support ?and*wildcards. | 
| exactMatch | boolean | tagsmatch operator. Exact match iftrue, partial match iffalse.Default: false(partial match).Exact match selects series with exactly the same tagsas requested.Partial match selects series with tags that contain requested tags but can also include additional tags. | 
| tagExpression | string | An expression to include series with tags that satisfy the specified condition. | 
"tags": { "mount_point": "/", "file_system": "/dev/sda1" }
Tag Expression
- The tagExpressioncan refer to series tags by name usingtags.{name}syntax.
- The series record must satisfy both the tagsobject and thetagExpressioncondition to be included in the results.
- Supported operators: LIKE,NOT LIKE,IN,NOT IN,=,!=,>=,>,<=,<.
- Supported functions: LOWER.
- Wildcards ?and*are supported byLIKEandNOT LIKEoperators. Symbols?and*are treated as regular characters when used with comparison operators=,!=,>=,>,<=,<.
"tagExpression": "tags.file_system LIKE '/dev/sda*'"
"tagExpression": "tags.file_system NOT IN ('/dev/sda1', '/dev/sda2')"
Date Filter
- [Required]
- Refer to date filter.
"startDate": "2018-05-30T14:00:00Z",
"endDate":   "2018-05-30T15:00:00Z"
Last Insert Filter
The filter selects entire series based on the timestamp of the most recent sample.
| Field | Type | Description | 
|---|---|---|
| minInsertDate | string | Include series if the timestamp of the latest sample is equal or greater than minInsertDate.ISO format date or a calendar keyword. Examples: 2017-10-01T00:00:00Z,current_day. | 
| maxInsertDate | string | Include series if the timestamp of the latest sample is less than maxInsertDate.ISO format date or a calendar expression. Examples: 2017-10-01T00:00:00Z,now - 1*DAY. | 
If both fields are specified, the series is included if it satisfies both conditions.
"minInsertDate": "2019-01-01T00:00:00Z",
"maxInsertDate": "current_day"
Forecast Filter
| Name | Type | Description | 
|---|---|---|
| forecastName | string | Unique forecast name. Identifies a custom forecast by name. If forecastNameis not set, then the default forecast computed by the database is returned.forecastNameis applicable only whentypeis set toFORECASTorFORECAST_DEVIATION. | 
Versioning Filter
| Name | Type | Description | 
|---|---|---|
| versioned | boolean | Returns version status, source, and change date if the metric is versioned. Default: false. | 
| versionFilter | string | Expression to filter value history (versions) by version status, source or time, for example: version_status = 'Deleted'orversion_source LIKE '*user*'. To filter by versiontime, usedate()function, for example,version_time > date('2018-08-11T16:00:00Z')orversion_time > date('current_day'). Thedate()function accepts calendar keywords. | 
Sample Filter
| Name | Type | Description | 
|---|---|---|
| sampleFilter | string | Boolean expression applied to each time:valuesample. Samples that satisfy the condition are included in the result.Available fields: valueanddate.The valuefield in the expression refers to the numeric value of the sample.The datefield represents sample timestamp as an instance of theDateTimeobject. | 
Sample Filter Processing Rules:
- The filter is applied before series transformations (interpolation, aggregation, etc).
- In case of a versioned metric in versioned=truemode, the filter checks only the last sample recorded for the given time. If the last sample satisfies the filter, all versions for that time are included.
- The datefield is an instance of theDateTimeobject and can be tested with various date functions.
Examples:
- value > 0: Retrieves samples which are positive numbers.
- value > 2 && value <= 3: Retrieves samples within the specified range.
- Math.sin(value) < 0.5: Math functions are supported.
- Double.isNaN(value): Only- NaNvalues and deleted values pass this check.
- date.is_weekday(): Retrieves samples recorded on week days within the selection interval.
- !date.is_exceptionday(): Retrieves samples recorded on regular calendar days.
- date.hourOfDay >= 14: Retrieves samples recorded at- 14:00or later each day.
- date.timeOfDay BETWEEN '14:00' AND '15:00': Retrieves samples recorded between- 14:00and- 15:00(inclusive) each day.
- filter_by_time_of_day('14:00', '15:00'): Retrieves samples recorded between- 14:00and- 15:00(inclusive) each day using a filter function.
- date.to_timezone('US/Eastern') BETWEEN '09:30' AND '16:00' && date.to_timezone('US/Eastern').is_weekday('nyse')
Transformations
| Name | Description | 
|---|---|
| interpolate | Fill missing values in the detailed data using a linear or step-like interpolation functions. | 
| group | Merge multiple series into one series. | 
| rate | Compute difference between consecutive samples per unit of time (rate period). | 
| aggregate | Group detailed values into periods and calculate statistics for each period. | 
| smooth | Smooth time series. | 
| downsample | Reduce time series cardinality by filtering out some samples. | 
| forecast | Predict future values based on trends and recurring patterns. | 
The default transformation sequence is as follows:
The interpolate transformation, if requested, is applied to detailed data before the values are passed to subsequent stages.
The default sequence can be modified by adding an transformationOrder field.
"transformationOrder": ["group", "forecast"]
Control Fields
| Name | Type | Description | 
|---|---|---|
| limit | integer | Maximum number of time:valuesamples returned for each series. Default: 0 (no limit).The limit is applied from the beginning of the selection interval if the direction is ASCand from the end if the direction isDESC.For example, limit=1withdirection=DESCreturns the most recent last value.Limit is not applied if the parameter value <= 0. | 
| direction | string | Order for applying the limitparameter:ASC: ascending,DESC: descending. Default:DESC.The returned data values are sorted in ascending order regardless of direction. limit=10means the most recent 10 values. | 
| seriesLimit | integer | Maximum number of series returned. Default: 0 (no limit). The database raises a processing error if series count exceeds 10000 for queries that fetch data for an non-versioned metric without limit. | 
| cache | boolean | If true, execute the query against the Last Insert table, which is the fastest way to retrieve the last value for a query. Default:false.Values in the Last Insert table can be delayed up to 15 seconds , controlled with last.insert.write.period.secondssetting. Only 1 value is returned for each series. | 
| requestId | string | Optional identifier used to associate queryobject in request with one or multipleseriesobjects in response. | 
| timeFormat | string | Time format for a data array. isoormilliseconds. Default:iso. | 
| addMeta | boolean | Include metric and entity metadata (fields and tags) under the metaobject in the response. Default:false. | 
| transformationOrder | array | List of transformation names such as interpolate,aggregateto control the order in which the transformations are applied to data.Example: "transformationOrder": ["group", "forecast"] | 
| timezone | string | Time zone ID applied in transformations for calendar alignment and keyword evaluation. | 
Response
The response contains an array of series objects, each containing series identifiers and request fields and an array of timestamped value objects.
| Name | Type | Description | 
|---|---|---|
| entity | string | Entity name | 
| metric | string | Metric name | 
| tags | object | Object containing series tags. | 
| type | string | Type of inserted data: HISTORY,FORECAST. | 
| aggregate | string | Type of statistical aggregation: DETAIL,AVG,MAX, etc. | 
| data | array | Array of Value objects. | 
| meta | object | Metric and entity metadata fields, if requested with the addMetaparameter. | 
Value Object
- The value object contains a sample time and a numeric (vfield) or text (xfield) value.
- Specify sample time in Unix time with millisecond precision (tfield) or ISO format (dfield).
| Name | Type | Description | 
|---|---|---|
| t | integer | Sample Unix time with millisecond precision. | 
| d | string | Sample time in ISO format. | 
| v | number | Numeric sample value at time t/d.The field is set to nullif the value is Not a Number:{"d":"2017-09-14T17:00:03.000Z","v":null} | 
| x | string | Text sample value at time t/d. | 
| version | object | Object containing version source and status fields for versioned metrics. | 
Example
Request
URI
POST /api/v1/series/query
Payload
[{
  "startDate": "2017-09-14T17:00:00Z",
  "endDate":   "2017-09-14T18:00:00Z",
  "entity":    "nurswgvml007",
  "metric":    "mpstat.cpu_busy"
}]
Response
[{
    "entity": "nurswgvml007",
    "metric": "mpstat.cpu_busy",
    "tags": {},
    "type": "HISTORY",
    "aggregate": {
      "type": "DETAIL"
    },
    "data": [
        {"d":"2017-09-14T17:00:03.000Z","v":24.24},
        {"d":"2017-09-14T17:00:19.000Z","v":39.8},
        {"d":"2017-09-14T17:00:35.000Z","v":39.18}
    ]
}]
 curl Example
 curl https://atsd_hostname:8443/api/v1/series/query \
  -k --user {username}:{password} \
  --header "Content-Type: application/json" \
  -d '[{"metric":"mpstat.cpu_busy", "entity":"nurswgvml007", "startDate":"previous_day", "endDate": "now"}]' > response.json
Java Example
Python Example
Additional Examples
Time Range
- ISO Start/End Range
- ISO Millisecond Precision
- ISO hh:mm Time Zone
- ISO: All Data Range
- Interval Window
- End Date and Interval
- EndTimeSyntax
- EndTimeSyntax with Expression
- EndTime: Current Day
- EndTime: Previous Hour
- EndTime: Hour Window
- Response Time Format
- Cache Range
Series Tags
- Defined Tags
- Multiple Tag Values
- Wildcard: All Values
- Wildcard: Expression
- Exact Tag Match
- Unknown Tag
- Tag Expression
Special Values
Entity Filter
- Multiple Entities
- Multiple Entities Including Entities without Data
- Entity Wildcard
- Entity Expression: Name
- Entity Expression: Entity Tags
- Entity Expression: No Entity Tag
- Entity Expression: Entity Properties
- Entity Group
Multiple Queries
- Multiple Queries
- Multiple Queries With Request Id
- Multiple Queries for Unknown Entity
- Multiple Queries with Limit
Control Fields
Regularize / Downsample
Aggregation
- Average
- Multiple Functions
- All Functions
- Counter/Delta
- Maximum Value Times
- Maximum Value Time (2)
- Threshold
- Threshold with Working Minutes
- Average Threshold Percentage
- Interpolation
- Aggregation of Interpolated Values
Period
Group
- Group Order
- Group by Entity and Tags
- Group Without Aggregation
- Group Without Aggregation: Truncate
- Group Without Aggregation: Extend
- Group Without Aggregation: Interpolate
- Group Without Aggregation: Wildcard and Entity Group
- Group With Period Aggregation
- Group > Period Aggregation
- Period Aggregation > Group
