OpenTSDB-Querying or Reading Data

Querying or Reading Data

OpenTSDB offers a number of means to extract data such as CLI tools, an HTTP API and as a GnuPlot graph. Querying with OpenTSDB‘s tag based system can be a bit tricky so read through this document and checkout the following pages for deeper information. Example queries on this page follow the HTTP API format.

OpenTSDB提供很多方法抽取数据,例如CLI tools,HTTPAPI,Gnuplot图。

基于系统查询OpenTSDB的tag是件困难的事情。通过阅读下面的文档获取更多信息。

Query Components

OpenTSDB‘s query language is fairly simple but flexible. Each query has the following components:

OpenTSDB的查询语言是比较简单,灵活的。每个查询包括如下部分:

ParameterDate TypeRequiredDescriptionExample
Start Time String or Integer Yes

Starting time for the query. This may be an absolute or relative time. See Dates and Times for details

相对值和绝对值都支持

24h-ago
End Time String or Integer No

An end time for the query. If the end time is not supplied, the current time on the TSD will be used. See Dates and Times for details.

可以不提供,默认是当前时间

1h-ago
Metric String Yes

The full name of a metric in the system. Must be the complete name. Case sensitive

metric的名字,大小写敏感

sys.cpu.user
Aggregation Function String Yes

A mathematical function to use in combining multiple time series

整合多个时间序列的数学函数

sum
Tags String No

An optional set of tags for filtering or grouping

基于tags进行过滤

host=*,dc=lax
Downsampler String No

An optional interval and function to reduce the number of data points returned

减少返回数据点

1h-avg
Rate String No

An optional flag to calculate the rate of change for the result

计算结果变化的比率

rate

 

Times

Absolute time stamps are supported in human readable format or Unix style integers. Relative times may be used for refreshing dashboards. Currently, all queries are able to cover a single time span. In the future we hope to provide an offset query parameter that would allow for aggregations or graphing of a metric over different time periods, such as comparing last week to 1 year ago. See Dates and Times for details on what is permissible.

While OpenTSDB can store data with millisecond resolution, most queries will return the data with second resolution to provide backwards compatibility for existing tools. Unless a down sampling algorithm has been specified with a query, the data will automatically be down sampled to 1 second using the same aggregation function specified in a query. This way, if multiple data points are stored for a given second, they will be aggregated and returned in a normal query correctly.

To extract data with millisecond resolution, use the /api/query endpoint and specify the msResolution JSON parameter or ms query string flag and it will bypass down sampling (unless specified) and return all timestamps in Unix epoch millisecond resolution. Also, the scancommandline utility will return the timestamp as written in storage.

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。