当前位置:网站首页>Promql select time series
Promql select time series
2022-07-01 03:41:00 【Foxconn quality inspector zhangquandan】
Instantaneous vector , Interval vector , Instantaneous query , Interval query .

Request URL: http://139.198.166.235:9090/api/v1/query?query=demo_api_http_requests_in_progress&time=1644905624.121You can see that this is a query promql The interface of ,query The parameter is actually promql A statement of ,time In fact, it is the timestamp of the evaluation , This only contains one promql A query such as a statement and a timestamp is actually a transient query .
The result is an instantaneous vector .

This is also a transient query , Only the result of instantaneous query is an interval vector .
The result of an instantaneous query may be an instantaneous vector , It could also be an interval vector . stay table All queries in the internal view are instantaneous queries .
If you switch to Graph Come here , Or the previous query , You can see that the interface has changed
Request URL: http://139.198.166.235:9090/api/v1/query_range?query=demo_api_http_requests_in_progress&start=1644904540.348&end=1644906340.348&step=7query_range This is a range query , Or interval query . Because you need to draw , So it's not a point , Is within a time frame .
stay granph All the queries are interval queries .
Choose a time series
In this section, we will learn how to select data in different ways , How to filter data based on tags in a single timestamp or over a period of time , And how to use mobile time to select data .
Filter indicator name
The simplest PromQL Query is to directly select the sequence with the specified indicator name , for example , The following query will return all with indicator names demo_api_request_duration_seconds_count Sequence :
demo_api_request_duration_seconds_count
The query will Returns a number of sequences with the same indicator name , But there are different label combinations instance、job、method、path and status etc. . The output is as follows :

Filter by tag
If we only query demo_api_request_duration_seconds_count There is method="GET" The index sequence of the tag , You can add this filter condition with braces after the indicator name :
demo_api_request_duration_seconds_count{method="GET"}
{__name__="demo_api_request_duration_seconds_count",instance="192.168.100.5:10000",method="GET",status="200"}In addition, we You can also use commas to combine multiple label matchers :
demo_api_request_duration_seconds_count{instance="demo-service-0:10000",method="GET",job="demo"}
Above will get demo Under the task demo-service-0:10000 The instance And method="GET" Index series data :

It should be noted that when multiple matching conditions are combined , It is to filter the time series that all conditions are satisfied .
In addition to equal matching ,Prometheus Several other matcher types are also supported :
!=: It's not equal to=~: Regular Expression Matching!~: Regular expressions don't match
Even we can omit the indicator name completely , For example, directly query all path Label with /api All sequences at the beginning :
{path=~"/api.*"}
The query will get some sequences with different indicator names :

Be careful : Prometheus Regular expressions in always match against complete strings rather than partial strings . therefore , Match any with
/apiWhen opening the path , There is no need to^start , But you need to add at the end.*, This will matchpath="/api"This sequence .
We said before that in Prometheus Inside , The index name is essentially a name __name__ The characteristic label of , So search demo_api_request_duration_seconds_count In fact, it is equivalent to the following query method :
{__name__="demo_api_request_duration_seconds_count"}
The selector written in the above way , You can get one Instantaneous vector , It contains a single... Of all the selected sequences Latest value .
In fact, some functions require you not to pass a single value , Instead, it passes a sequence of values over a period of time , That is, the interval vector . At this time, we can add a [< Numbers >< Company >] Duration specifier of form , Change the immediate vector selector to the range vector selector ( for example [5m] Express 5 minute ).
For example, to query the latest 5 Minutes of available memory , You can execute the following query statement :
demo_memory_usage_bytes{type="free"}[5m]
You will get the query result shown below : This is the interval vector , It contains multiple samples , Interval vectors cannot go graph To draw , That is, at the same time

The valid time units that can be used are :
ms- milliseconds- secondm- minuteh- Hoursd- Gody- year
Sometimes we need to access past data in a time-lapse way , Usually used to compare with current data . To move past data to the current location , have access to offset <duration> Modifiers are added to any range or immediate sequence selector to query ( for example my_metric offset 5m or my_metric[1m] offset 7d).
for example , To select the memory available one hour ago , You can use the following query statement :
demo_memory_usage_bytes{type="free"} offset 1h
At this time, the query value is the data one hour ago :

practice :
1. Build a query , Select all time series .
{job!=""}perhaps :
{__name__=~".+"}2. Build a query , Query all indicators whose names are
demo_api_request_duration_seconds_countalsomethodLabel is notPOSTSequence .demo_api_request_duration_seconds_count{method!="POST"}3. Use
demo_memory_usage_bytesIndex query one hour ago 1 Available in the minute time range Free Memory .demo_memory_usage_bytes{type="free"}[1m] offset 1h
边栏推荐
- Avalanche problem and the use of sentinel
- You cannot right-click F12 to view the source code solution on the web page
- Detailed explanation of ES6 deconstruction grammar
- FCN全卷积网络理解及代码实现(来自pytorch官方实现)
- 快速筛选打卡时间日期等数据:EXCEL筛选查找某一时间点是否在某一时间段内
- 168. Excel表列名称
- 【伸手党福利】JSONObject转String保留空字段
- 在 C 中声明函数之前调用函数会发生什么?
- bootsrap中的栅格系统
- Leetcode 1818 absolute value, sorting, dichotomy, maximum value
猜你喜欢
![[small sample segmentation] interpretation of the paper: prior guided feature enrichment network for fee shot segmentation](/img/b3/887d3fb64acbf3702814d32e2e6414.png)
[small sample segmentation] interpretation of the paper: prior guided feature enrichment network for fee shot segmentation

Develop industrial Internet with the technical advantages of small programs

Research on target recognition and tracking based on 3D laser point cloud

Thread data sharing and security -threadlocal

pytorch nn. AdaptiveAvgPool2d(1)

数据交换 JSON
![[深度学习]激活函数(Sigmoid等)、前向传播、反向传播和梯度优化;optimizer.zero_grad(), loss.backward(), optimizer.step()的作用及原理](/img/9f/187ca83be1b88630a6c6fbfb0620ed.png)
[深度学习]激活函数(Sigmoid等)、前向传播、反向传播和梯度优化;optimizer.zero_grad(), loss.backward(), optimizer.step()的作用及原理

整合阿里云短信的问题:无法从静态上下文中引用非静态方法

IPv4 and IPv6, LAN and WAN, gateway, public IP and private IP, IP address, subnet mask, network segment, network number, host number, network address, host address, and IP segment / number - what does

jeecgboot输出日志,@Slf4j的使用方法
随机推荐
完全背包问题
Random seed torch in deep learning manual_ seed(number)、torch. cuda. manual_ seed(number)
Blueprism registration, download and install -rpa Chapter 1
深度学习中的随机种子torch.manual_seed(number)、torch.cuda.manual_seed(number)
bootsrap中的栅格系统
后台系统页面左边菜单按钮和右边内容的处理,后台系统页面出现双滚动
Develop industrial Internet with the technical advantages of small programs
家居网购项目
318. 最大单词长度乘积
205. 同构字符串
ECMAScript 6.0
还在浪费脑细胞自学吗,这份面试笔记绝对是C站天花板
5. [WebGIS practice] software operation - service release and permission management
pytorch nn. AdaptiveAvgPool2d(1)
What happens when a function is called before it is declared in C?
数据交换 JSON
The shell script uses two bars to receive external parameters
Leetcode: offer 59 - I. maximum value of sliding window
实现pow(x,n)函数
389. 找不同