Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Prometheus PromQL

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use Prometheus PromQL". Friends who are interested might as well take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use Prometheus PromQL.

Data type

There are currently four data types in PromQL Expression Language:

Instant vector (instant vector): a set of time series containing a single sample, each sharing the same timestamp

Range vector (range vector): a set of time series of data points that vary with time in each time series.

Scalar: a simple floating-point value

String (string): a simple string value that is not currently used

Literal string

The string is used as the value of the query condition label in PromQL, such as "apiserver" and "/ api/comments" in http_requests_total {job= "apiserver", handler= "/ api/comments"}, similar to the string in the Go language, for example:

"this is a string" 'these are unescaped:\ n\\ t' `these are not unescaped:\ n'"\ t` floating point value

The scalar floating-point numeric format is [-] (digits) [. (digits)], for example:

-2.43 timing selector real-time vector selector

The real-time vector selector is used to use metric name and label to return a time series that meets the criteria from the current moment.

The simplest form is to use only one metric name, such as http_requests_total, and you can further filter the time series through attachment I set of label enclosed in {}, such as http_requests_total {job= "prometheus", group= "canary"}. The matching of label supports the following forms:

= Select an equal label

! = Select an unequal label

= ~ Select a tag (or subtag) that matches the regular expression

! ~ Select tags (or subtags) that do not match regular expressions

For example, query the time series of http_requests_total with non-GET methods in staging, testing, and development environments:

Http_requests_total {environment=~ "staging | testing | development", methodological = "GET"} range vector selector

The time range represented by [] in a vector selector is the range vector selector. The units of the time range can be taken as follows:

S-seconds

M-minutes

H-hours

D-days

W-weeks

Y-years

For example:

Offset modifier

The Offset modifier, the offset modifier, can be used to specify the time offset of an immediate vector or a range vector, for example:

For example, http_requests_total offset 5m returns the data of the current http_requests_total five minutes ago.

Operator

Prometheus supports many binary and aggregate operators, such as arithmetic, comparison, logic, and aggregation operators. For more information, please see operators

Function

Prometheus supports many functions that can be used to manipulate data, such as functions.

At this point, I believe you have a deeper understanding of "how to use Prometheus PromQL". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report