Spring cloud security services combat micro-environment to build -7-3prometheus

Prmetheus Metrics mainly used to do monitoring and alarm, this picture is the official organization chart.

This is his core and its role is based on our configuration to complete data collection, service discovery, and data storage.

This is a service of discovery through the Service discovery, prmethesu will know where to go to collect data. Service discovery in two forms, one is static, that is, go through the file with. Tell it you're going to get this data Metrics, and the other is dynamic, zookeeper or through some other distribution center, distribution center inside when the data changes, Prometheus also follow the change, go to different places to grab data,

this is all my applications to provide, Prometheus is caught data, is a pull mode, Prometheus calling our interface, and then taken away by our data, we are Prometheus to pull this data, so that the benefits for our application, we need to know where the Prometheus of service, do not need to do these configurations, as long as we expose our data to see it. Prometheus unity in which to configure. In this way you can go to various places Prometheus catch a wide variety of data.


Pushgateway is used to support push mode, because sometimes, some of the data it is not always present, such as our regular tasks, Prometheus came, I just did not start timing task, then you catch data so it will be sent to the data timing tasks Pushgateway a push gateway interface this time, the timing task calls Pushgateway call, the data directly to the Pushgateway. Then Prometheus to Pushgateway get something, the equivalent of an intermediate Pushgateway is temporarily stored, the data such short living it stored. Then for Prometheus to pull.


Collection are some of the formatting of data, flow ah, response time, these digital formatted data, this page can help you to graphically display the data out. But this page is very simple. So in order to solve this problem has a special program called Grafana, it is a more advanced graphical interface Grafana, it can take data from Prometheus inside. The data show up in the form of icons. And then let you see at a glance what your current system status.
Of course, you can go to write their own code for API clients to the tune of Prometheus service, then you do handle yourself out. .

And when they Prometheus communications, the main language used is PromQL, Prometheus own a query language, SQL, and type, but the only difference is that this language can only write queries,

the upper right corner, AlertManager warning police management, which do the police, there are many ways alarm.
There will be a number between Prometheus and AlertManager push, you can define rules, Prometheus is doing Metrics to monitor the so-called Metrics that all data can be represented by numbers, can be used to collect Metrics. For example, the appropriate time flow of your system, the service, you can define rules according to these Metrics, for example, you can define the appropriate time if the service is greater than 100 ms, then I call the police, if you set such a rule later, Prometheus from time to time, this is also the time you specify, for example, every 10 seconds or every minute went to assess the data collected and assessed according to the rules you set, if you collected data more than the value of your pre-defined, such as response time exceeds 100 milliseconds, it will push to the side a warning. But this warning after pushing past, and will not immediately alarm. Because it will re-evaluate several consecutive cycles. For example, you set the evaluation period is 10 seconds. He may re-evaluation about five times, five times in the back of the case is this to the police, and it will really reported to the police. And not to say that every assessment have not seen it immediately to the police. This is very false positives may occur. For example, network jitter ah. Cause your services in some cases delayed. But these may shake, may soon passed. This time if you collect to abnormal data, the police immediately. Is likely to have a lot of alarm is false, there is no real problems found.

This is the whole Prometheus large infrastructure
project which built a folder. Called the monitoring, surveillance of a folder,


there is put a lot of configuration files. Code is no longer knocked bring everyone to read the code line by line.


This is a composite file a docker, the role was a mirror for me to install some docker.


Once you have installed Prometheus, orange boxes are installed on it, and only the yellow box needs to be installed separately.

Here is the installation of a two prometheus and hgrafana,
image configuration, it will start after the docker's central warehouse to pull it down. A run up, I had a Prometheus of the server.

Each mirror run when he generated a container, the container by a name prometheus.

We got prometheus, we give it some configuration, this prometheus tell you where to go to catch data,

the need to configure a service discovery. I tell it you're going to catch me those services orderService monitoring data ,, then go into how these configurations. Is through the volumes, mount the volume way,

that is, before we talk about the material resources mapped to a container of the way

then what is the value mapping? This configuration is

in front of the colon is my local machine directory, relative to my current location of the directory, which is prometheus folder.

I actually refers to items left inside this folder, which put a prometheus profile.
Then I put the file on the prometheus image in the / etc / prometheus this folder.

This means that each prometheus.yml will eventually appear in the image of / etc / prometheus / this directory. By default prometheus it is from this path / etc / prometheus read configuration files. So I can put my profile prometheus put a mirror in, so when he ran as I defined configuration to run.

Machine access port with 9092, 9090 is the port of the container. Why not use port 9090, because my 9090 port is occupied by the authentication server api. So here it is mapped to 9092



into the monitoring folder

as a docker-compose.yml -f specify a file. up is to start.

The first run, then there may be mirroring the log, because there has been running before. So here done the amount of direct


access to 9092. This is just ui peometheus itself with the

targets that you collect your data from where

now there are two goals. One is prometheus itself. It is from his 9090 / metrics to collect information on this path, the state represents the normal start up. Because prometheus itself is to start with, and

the latest one to obtain data from this endpoint,

srpingBoot not start up this app.

So these two goals came from it?

It knows how to go to this location information springboot-app grasp of it?

prometheus.yml profile

全局的配置,抓取的频率。prometheus是一个拉的模式,每隔一段时间去目标拉取数据,合理配置的就是拉取的频率默认是每隔十五秒一次。


拉取的目标,定义了两个job

抓取prometheus本身的时候又配置了 scrape_interval频率是5秒。这就意味着抓取自己的时候是 5秒每次。

静态的配置下有个targets,就是你要去哪抓数据。配置的是去本机的9090端口去抓。

prometheus是跑在容器里面的,容器你本身可以认为它就是一个机器。我们自己的电脑是另一个机器。你要理解为这两个是两个完全不同的机器。这个配置文件你要明白它是放在prometheus的机器上的。

抓数据,请求路径。一会我们会在Order-APi上做一些操作,让他可以提供出这个路径的接口来。供普罗米修斯来抓数据。

你要去运行docker环境的宿主机的9082端口上去抓,springboot-app的数据。 一会我们会吧orderAPi跑在9082的端口上。

labels就是把抓出来的数据打一个标签。标签名字叫做springboot-app

结束


 

Guess you like

Origin www.cnblogs.com/wangjunwei/p/12001221.html