当前位置:网站首页>Prometheus prometheus+grafana, monitoring setup and basic interface configuration
Prometheus prometheus+grafana, monitoring setup and basic interface configuration
2022-07-22 14:29:00 【The, only】
One 、Prometheus brief introduction
gitlab Official address :https://github.com/prometheus/prometheus
Prometheus( Prometheus ) Is a set of open source monitoring & Call the police & Combination of time series databases , from SoundCloud Companies to develop .
Prometheus The basic principle is through HTTP Protocol periodically grabs the status of monitored components , The advantage of this is that any component only provides HTTP The interface can be connected to the monitoring system , No need for any SDK Or other integration processes . This is ideal for virtualized environments like VM perhaps Docker .
Prometheus There should be a few suits Docker、Mesos、Kubernetes One of the environmental monitoring systems .
Prometheus Infrastructure
Pictured above ,Prometheus It is mainly composed of the following parts :
- Prometheus Server: Mainly responsible for storage 、 Grab 、 polymerization 、 In terms of inquiry .( Server side )
- Alertemanager: It is mainly responsible for realizing the alarm function .
- Pushgateway: Mainly to achieve the reception of Client-push The past indicator data , At a specified time interval , There is a main program to grab .
- *_exporter: Mainly responsible for collecting physical machines 、 Middleware information .( client )
Two 、Prometheus Server side installation
preparation :
Server side :192.168.152.103 ubuntu
client :192.168.152.101 ubuntu
1: download
stay 192.168.152.103, Server side download address :https://github.com/prometheus/prometheus/releases
Find yourself Linux edition , I'm here for Linux-amd64, Most of them are basically this .
# download
wget https://github.com/prometheus/prometheus/releases/download/v2.37.0/prometheus-2.37.0.linux-amd64.tar.gz
# decompression
tar -zxvf prometheus-2.37.0.linux-amd64.tar.gz
# Rename folder , name too long , Convenient follow-up operation
mv prometheus-2.37.0.linux-amd64 prometheus
# Enter folder
cd prometheus/
Check the file to see the following file .
[email protected]:~/prometheus$ ls
console_libraries consoles LICENSE NOTICE prometheus prometheus.yml promtool
Just pay attention prometheus( Startup file ), prometheus.yml( The configuration file ), These two files are sufficient .
The default configuration file content is
cat prometheus.yml
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. By default , Every time 15s Pull the target sampling point data once .
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. Every time 15 Evaluate the rule every second . The default value is per 1 minute
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "prometheus"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ["localhost:9090"]
2: Start the test server
start-up
./prometheus --config.file=prometheus.yml
When to start Prometheus after , You can go through 9090 Port to access Prometheus Self contained UI Interface :
Open in browser http://192.168.152.103:9090/, Can access UI Interface .
3、 ... and 、 install Node_Exporter client
1: Download decompression
stay 192.168.152.101, Client download address :https://github.com/prometheus/node_exporter/releases
Find the same Linux-amd64 This version , Download and unzip
# download
wget https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz
# decompression
tar -zxvf node_exporter-1.3.1.linux-amd64.tar.gz
# rename
mv node_exporter-1.3.1.linux-amd64 node_exporter
2: start-up Node_Exporter client
client , There are no other configuration files , It can be started directly by default
./node_exporter
After starting , The default listening port is 9100, Type in the browser ,192.168.152.101:9100 You can view and visit Client Monitoring indicators of .
Click on Metrics Enter to see relevant information .
Four 、 Add a connection client to the server
Just type in the server configuration file , add to job_name that will do , There are several clients , Just add a few . Name yourself .
Change the server configuration file
vim prometheus.yml
Add the last side .[‘192.168.152.101:9100’] For client information .
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. By default , Every time 15s Pull the target sampling point data once .
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. Every time 15 Evaluate the rule every second . The default value is per 1 minute
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "prometheus"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ["localhost:9090"]
- job_name: "linux"
static_configs:
- targets: ['192.168.152.101:9100']
Restart the server , that will do
./prometheus --config.file=prometheus.yml
test , See if it is added successfully , Log in to the browser UI Interface , stay Status >> Targets You can view all client information and server information .
state UP It's normal .
5、 ... and 、 Third party interface installation
because prometheus Bring their own UI The interface is relatively simple , So we need to use third-party tools Grafana In management , This is more friendly , More intuitive .
The testing machine here is limited , So it is also installed in 192.168.152.103 Server side , You can also install it on other machines .
1:Grafana install
Official installation documentation :https://grafana.com/docs/grafana/next/setup-grafana/installation/debian/
Choose your own system , You can choose the enterprise version (Enterprise) Or open source version (OSS), I'm here for Ubuntu Install enterprise , So the installation is as follows :
Get the latest version of key( Enterprise Edition )
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
Add the latest stable warehouse
echo "deb https://packages.grafana.com/enterprise/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
If you want to install the latest beta , Add the warehouse as follows
echo "deb https://packages.grafana.com/enterprise/deb beta main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
The last update , install
sudo apt-get update
sudo apt-get install grafana-enterprise
Of course, you can also install the open source version OSS, The document also has configuration , The installation is the same .
2: start-up Grafana, And add prometheus
start-up Grafana, The default port is 3000.
sudo systemctl start grafana-server.service
visit Grafana, Sign in http://192.168.152.103:3000/, Default password :admin,admin
Add data add data source
choice prometheus
add to prometheus Server for IP Address , The default port is 9090
Other default , Save it .
After saving , stay explore You can see what you just added prometheus data .
Of course, at this time , I still can't understand , At this time, you need to configure the next step Dashboards Interface , More friendly and intuitive .
3:Grafana Configuration add Dashboards
There are many official templates , You can choose according to your needs and preferences . Of course, you can only choose prometheus The template of .
Official module address :https://grafana.com/grafana/dashboards/
Here I 1 One is prometheus The template of , Most people watch downloads , So I choose this , Click in . You can see this code , copying , The code is 1860.
go back to Grafana, stay Dashboards in , choice Import Just import .
Fill in 1860,load Can finish .
When I'm done , Press host And time in the selection of graphics to watch .
Here the interface is basically configured .
6、 ... and 、 Background start
Configuration complete , You also need to configure background startup , Direct use nohup Just go
Server side :
# Don't save logs
nohup ./prometheus --config.file=prometheus.yml >/dev/null 2>&1 &
# Save log to /var/log/prometheus.log
nohup ./prometheus --config.file=prometheus.yml >/var/log/prometheus.log 2>&1 &
client :
# Don't save logs
nohup ./node_exporter >/dev/null 2>&1 &
# Save log to /var/log/node_exporter.log
nohup ./node_exporter >/var/log/node_exporter.log 2>&1 &
Of course, you can also write services into systemd, Set power on self start , You can do your own research .
The next step is to configure the alarm sending , I'll introduce it in the next article .
边栏推荐
- parker液压油泵PV140R1K1T1NMM1
- ABAP grammar basics 3
- 腾讯测试岗,被面试官虐哭...直到学长给了我这些知识点
- 什么是“异步 Request-Reply”模式?编程如何实现?
- Kuzaobao: summary of Web3 encryption industry news on July 21
- Développement d'ardunio - processus de fonctionnement des pompes
- 树莓派——云服务器部署——内网穿透——cpolar工具使用
- Redis data structure analysis (I)
- STM32状态机编程实例——全自动洗衣机(上)
- OA项目之项目简介&会议发布
猜你喜欢
Rexroth proportional valve 4wrpeh6c3b04l-3x/m/24f1-885
Ardunio开发——舵机控制
时间复杂度与复杂度
飞行员兄弟
年薪30W,软件测试人的成长之路,你在哪个阶段?
With an annual salary of 30W, the growth path of software testers, at which stage are you?
Ardunio开发——水泵操作过程
腾讯测试岗,被面试官虐哭...直到学长给了我这些知识点
What is the "asynchronous request reply" mode? How to realize programming?
微服务架构 | 服务注册发现中心/配置中心/消息总线 - [nacos] TBC...
随机推荐
Concurrency opening -- take you from 0 to 1 to build the cornerstone of concurrency knowledge system
微信打开时支持消息通知横幅引热议;Google和甲骨文的云服务因英国高温天气而下线;谷歌发布开源开发语言Carbon|极客头条
Tencent test post, was abused by the interviewer... Until the senior gave me these knowledge points
State owned enterprises work overtime in 996, but job hopping offers are outsourcing. What should we do?
parker液压油泵PV140R1K1T1NMM1
Design of consumption system of unmanned Supermarket Based on stm32
What is the "asynchronous request reply" mode? How to realize programming?
MMD PMX import unit related data
SOC first project
Ardunio開發——水泵操作過程
classes.jar: 另一个程序正在使用此文件,进程无法访问。
RenderFlex children have non-zero flex but incoming height constraints are unbounded.
cookie和seesion的区别和联系
dom——事件链(捕获目标和捕获)
Interlaced color change of table
The difference between using @fastnative and @criticalnative
When wechat is opened, it supports message notification banners to attract hot discussion; The cloud services of Google and Oracle were offline due to the high temperature weather in the UK; Google re
Solve the problems of El Popover display in V-for
Mysql索引分類及其使用實例
字节跳动测试岗,前面都过了,最后一面HR天坑...跟我说这话