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

What is Prometheus?

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Today, I would like to talk to you about what Prometheus is, many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something from this article.

What is Prometheus?

Prometheus is an open source combination of monitoring-alarm-time series database, which was originally developed by SoundCloud. As it grows, more and more companies and organizations accept the adoption of Prometheus, and society is very active, so they turn it into an open source project and have companies to operate it. Google SRE also mentioned in his book that a similar implementation to their BorgMon monitoring system is Prometheus. Nowadays, the most common Kubernetes container management systems are usually monitored with Prometheus.

Advantages of Prometheus

Very few external dependencies, ultra-easy to install and use

There have been a lot of system integration, such as docker HAProxy Nginx JMX and so on.

Service automation discovery

Integrate directly into the code

The design idea is implemented according to the distributed and micro-service architecture.

Characteristics of Prometheus

Custom multi-dimensional data model

Very efficient storage of an average of about 3.5 bytes of sampled data, 3.2 million of the time series, sampling every 30 seconds, holding for 60 days, consuming about 228G of disk.

Powerful query statement

Easy data visualization

Wait

Compared with Graphite, it still has many advantages. What makes me feel good is the excellent write performance and read performance. Its data structure implementation is similar to OpenTSDB. If you are interested, you can take a look at this document. Decrypt the table storage of OpenTSDB

System Architecture of Prometheus

Its service process is that Prometheus daemon is responsible for regularly fetching metrics (index) data on the target, and each fetching target needs to expose an interface of the http service to it.

Prometheus supports specifying crawling targets through configuration files, text files, zookeeper, Consul, DNS SRV lookup, and so on.

Alertmanager is a component independent of Prometheus, which can support the query statement of Prometheus and provide a very flexible alarm mode.

Prometheus supports many ways of chart visualization, such as very exquisite Grafana, its own Promdash, and its own template engine, etc., and also provides HTTP API query method to customize the required output.

PushGateway is a component that supports Client to actively push metrics to PushGateway, while Prometheus only regularly goes to Gateway to grab data.

If there are users who have used statsd, they will feel that this is very similar, except that the statsd is sent directly to the server, while the Prometheus mainly depends on the process to grab it.

Data Model of Prometheus

Fundamentally, all the storage of Prometheus is implemented according to time series. The same metrics (indicator name) and label (one or more tags) form a time series, and different label represents different time series. In order to support some queries, sometimes some time series storage is generated temporarily.

Metrics name & label metric name and label

Each time series consists of a unique indicator name and a set of tags (key=value).

The indicator name is usually given a name to the monitoring object, such as http_requests_total, which has some naming rules, such as alphanumeric _, and so on.

It usually starts with the application name _ monitoring object _ numeric type _ unit.

For example:

Push_total

Userlogin_mysql_duration_seconds

App_memory_usage_bytes

Tags are the identification of different dimensions of a time series, such as whether a http request uses POST or GET, and what its endpoint is.

The final logo is like this.

Http_requests_total {method= "POST", endpoint= "/ api/tracks"}

Remember, for the metrics name of http_requests_total, either adding tags or removing tags will form a new time series.

The query statement can then query the aggregate results according to the combination of the above tags.

If you look at this statement from the perspective of a traditional database, you can consider that http_requests_total is the table name, label is the field, timestamp is the primary key, and a float64 field is the value. (all values in Prometheus are stored as float64)

Four data types of Prometheus Counter

Counter is used to accumulate values, such as the number of requests, tasks completed, and errors that have occurred.

It keeps increasing, but it won't decrease.

After the process is restarted, it will be reset.

For example: http_response_total {method= "GET", endpoint= "/ api/tracks"} 100

Grab http_response_total {method= "GET", endpoint= "/ api/tracks"} 100 after 10 seconds

Gauge

Gauge general values, such as temperature changes, memory usage changes.

Variable big, variable small.

After restarting the process, it will be reset

For example: memory_usage_bytes {host= "master-01"} 100

< 抓取值 memory_usage_bytes{host="master-01"} 30 memory_usage_bytes{host="master-01"} 50 memory_usage_bytes{host="master-01"} 80 < 抓取值 Histogram Histogram 可以理解为柱状图的意思,常用于跟踪事件发生的规模,例如:请求耗时、响应大小。它特别之处是可以对记录的内容进行分组,提供 count 和 sum 全部值的功能。 例如:{小于10=5次,小于20=1次,小于30=2次},count=7次,sum=7次的求和值

Summary

Summary and Histogram are very similar and are often used to track the size of events, such as request time and response size. It also provides the function of all values of count and sum.

For example, the evaluation of count=7 times and sum=7 times

It provides a quantiles function that divides the tracked results by% ratio. For example, the value of quantile is 0.95, which means 95% of the data in the sampling value.

After reading the above, do you have any further understanding of what Prometheus is? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

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