当前位置:网站首页>Prometheus deployment
Prometheus deployment
2022-07-02 23:04:00 【fangandpu】
Catalog
One 、Prometheus Deployment experiments
1.2 Deploy and monitor other nodes ( static state )
1.3 Deploy and monitor other nodes ( dynamic )
One 、Prometheus Deployment experiments
1.1 Deployment experiments
## Experiment preparation
## Turn off firewall
[[email protected] ~]# systemctl stop firewalld.service
[[email protected] ~]# setenforce 0
## Time synchronization
[[email protected] ~]# ntpdate ntp1.aliyun.com
## Download the installation package on the official website and unzip it
[[email protected] opt]# tar zxf prometheus-2.27.1.linux-amd64.tar.gz -C /usr/local/
[[email protected] opt]# cd /usr/local/prometheus-2.27.1.linux-amd64/
[[email protected] prometheus-2.27.1.linux-amd64]# ls
console_libraries consoles LICENSE NOTICE prometheus prometheus.yml promtool
## View the rule file
[[email protected] prometheus-2.27.1.linux-amd64]# cat prometheus.yml
[[email protected] prometheus-2.27.1.linux-amd64]# cat prometheus.yml
# my global config
global: // Global components
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. // How often do I grab indicators , Do not set default 15 second
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).# Alertmanager configuration // Butted altermanager( Third party alarm module )
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files: // Alarm rules
# - "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' // Indicators need to be labeled# metrics_path defaults to '/metrics' // The path to collect data
# scheme defaults to 'http'.static_configs: / about Prometheus The static configuration of the listening port, the specific data collection location Default port 9090
- targets: ['localhost:9090']
## Turn on monitoring
[[email protected] prometheus-2.27.1.linux-amd64]# ls
console_libraries consoles LICENSE NOTICE prometheus prometheus.yml promtool
[[email protected] prometheus-2.27.1.linux-amd64]# ./prometheus Enter the monitoring address in the web page 
1.2 Deploy and monitor other nodes ( static state )
Static discovery default :static_config : Service discovery in the form of static configuration
① File based service discovery ;
② be based on DNS Service discovery of ;
③ be based on API Service discovery of :Kubernetes、Consul、Azure、 Re label 、target Re mark 、 metric Re mark
④ be based on K8S Service discovery of
##prometheus Want to monitor other nodes , You need to use node_exporter
## Put and unzip the installation package on the node server
[[email protected] opt]# tar zxf node_exporter-1.1.2.linux-amd64.tar.gz
## Toggle directory
[[email protected] opt]# cd node_exporter-1.1.2.linux-amd64
[[email protected] node_exporter-1.1.2.linux-amd64]# cp node_exporter /usr/local/bin
## Two node servers start the service
[[email protected] node_exporter-1.1.2.linux-amd64]# ./node_exporter
## close Prometheus Add node information to the server
[[email protected] prometheus-2.27.1.linux-amd64]# vim prometheus.yml
## Restart service after adding
[[email protected] prometheus-2.27.1.linux-amd64]# ./prometheus
- job_name: 'nodes'
static_configs:
- targets:
- 192.168.162.121:9100
- 192.168.162.122:9100



The data collected by a single node is displayed

1.3 Deploy and monitor other nodes ( dynamic )
## If Prometheus Monitoring runs directly in the background
kill -9 PrometheusFile based service discovery is only slightly better than statically configured service discovery , It does not rely on any platform or third-party services , Therefore, it is also the simplest and most common implementation . prometheus server Load from file periodically target Information (pro-server pull Indicator discovery mechanism -job_name Get what I want pull The object of target) Files can be used only json and yaml Format , It contains defined target list , And optional label information ; The following is the first configuration , To be able to prometheus The default static configuration is converted to the configuration required for file based service discovery ;(prometheus Will periodically read 、 Reload the configuration in this file , So as to achieve dynamic discovery 、 Update operation )
## Create a directory to store the written yml file
[[email protected] prometheus-2.27.1.linux-amd64]# mkdir files_sd
[[email protected] prometheus-2.27.1.linux-amd64]# cd files_sd/
[[email protected] files_sd]# mkdir targets
## What will be written yml File import
[[email protected] files_sd]# ls
prometheus.yml targets
[[email protected] files_sd]# cd targets/
[[email protected] targets]# cat prometheus_server.yaml
- targets:
- 192.168.162.123:9090
labels:
app: prometheus
job: prometheus
[[email protected] targets]#

## Start... On the command line
[[email protected] prometheus-2.27.1.linux-amd64]# ./prometheus --config.file=./files_sd/prometheus.yml
## When a new node is added, it is directly in /usr/local/prometheus-2.27.1.linux-amd64/files_sd/targets/node Add records
[[email protected] targets]# cat nodes_centos.yaml
- targets:
- 192.168.162.101:9100
- 192.168.162.122:9100
- 192.168.162.121:9100
- 192.168.162.123:9100
labels:
app: node-exporter
job: node

1.4 Basic interface functions



Two 、 Common query statements
up Query active status
## see cpu Total amount
node_cpu_seconds_total
## Look at the first one cpu Idle state of
node_cpu_seconds_total{cpu="0",mode="idle"}
## Count the first cpu In the past 5 Minutes of the CPU Rate of use ( The data queried is double precision floating point )
irate(node_cpu_seconds_total{cpu="0",mode="idle"}[5m])
analysis :
irate: Rate calculation function ( Very sensitive )
node_cpu_seconds_total:node node CPU Total usage
mode="idle" Idle indicator 5m: In the past 5 Within minutes , all CPU Sample value of idle number , Do rate calculation for each value
## first cpu The average usage rate of
1- avg(irate(node_cpu_seconds_total{cpu="0",mode="idle"}[5m]))
## Every mainframe CPU One of the first cpu stay 5 Average usage within the group
(1- avg (irate(node_cpu_seconds_total{cpu="0",mode='idle'}[5m]))by (instance))*100
边栏推荐
- Innovation strength is recognized again! Tencent security MSS was the pioneer of cloud native security guard in 2022
- Application of containerization technology in embedded field
- How does Jerry test the wrong touch rate of keys [chapter]
- Motivation du Protocole de chiffrement avancé AES
- 海思3559万能平台搭建:在截获的YUV图像上旋转操作
- xshell配置xforward转发火狐浏览器
- [chestnut sugar GIS] how does global mapper batch produce ground contour lines through DSM
- Comprehensively analyze the logic of the shared purchase business model? How sharing purchase empowers Enterprises
- Qt QScrollArea
- STM32之ADC
猜你喜欢

中国信通院、清华大学、腾讯安全,云原生安全产学研用强强联合!

Chow-Liu Tree

Kubernetes uses the host name to allocate the pod on the specified node

boot actuator - prometheus使用

泛型与反射,看这篇就够了

China Academy of information technology, Tsinghua University, Tencent security, cloud native security, industry university research and use strong alliance!

海思3559万能平台搭建:在截获的YUV图像上旋转操作

数据分析学习记录--用EXCEL完成简单的单因素方差分析

Webrtc audio and video capture and playback examples and mediastream media stream analysis

Xiaopeng P7 had an accident and the airbag did not pop up. Is this normal?
随机推荐
数据分析学习记录(二)---响应曲面法及Design-Expert的简单使用
Jerry's prototype has no touch, and the reinstallation becomes normal after dismantling [chapter]
[Solved] Splunk: Cannot get username when all users are selected“
go 多线程数据搜索
【喜欢的诗词】好了歌
Set right click to select vs code to open the file
情感对话识别与生成简述
Array advanced improvement
pytorch训练CPU占用持续增长(bug)
密码技术---分组密码的模式
Construction of Hisilicon 3559 universal platform: draw a frame on the captured YUV image
Sword finger offer II 099 Sum of minimum paths - double hundred code
容器化技术在嵌入式领域的应用
P1007 独木桥
移动端 1px 像素兼容性问题,实现1px 边框
STM32之ADC
Value sequence < detailed explanation of daily question >
Analyse des données dossiers d'apprentissage - - analyse simple de la variance à facteur unique avec Excel
数据标注典型案例,景联文科技如何助力企业搭建数据方案
[chestnut sugar GIS] ArcMap - why should the tick of classic capture be removed when using custom capture?






