In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Introduction to Prometheus
Prometheus is an open source system monitoring and alerting framework inspired by Google's Borgmon monitoring system. In 2012, former Google employees of SoundCloud created Prometheus and developed it as a community open source project. In 2015, the project was officially launched. In 2016, Prometheus joined the Cloud Native Computing Foundation, becoming the second most popular project after Kubernetes.
Prometheus has the following characteristics:
Multidimensional data model (Key/Value pairs based on time series) Flexible query and aggregation language PromQL provides local and distributed storage Time series data collection via HTTP-based Pull model Push mode can be implemented using Pushgateway (Prometheus optional middleware) Target machines can be discovered via dynamic service discovery or static configuration Support for multiple graphs and data disks
III. Structure
prometheus is a temporal database written in Go that supports multiple language clients
IV. Module Introduction
Prometheus Server
Prometheus Server is the server side of the monitoring system. The server side fetches the metrics of the monitored service through service discovery, or indirectly fetches them through pushgateway. After capturing the metrics data, it stores them through a specific storage engine, and exposes an HTTP service to provide PromQL for data query. Note that Prometheus is timed sampling data, not full volume data.
Exporter
Prometheus needs the service to expose the http interface. If the service itself does not have it, we do not need to modify the service. We can obtain it indirectly through the exporter. The Exporter acts as a target for Prometheus collection, and each exporter directly acquires metrics. At present, most of the services have ready-made exporters, we do not need to repeat the wheel, use it, such as MySQL, MongoDB, etc., you can refer to here.
Push Gateway
There are two main ways Prometheus collects metrics: one is the server-side exposure interface (Exporter), and Prometheus actively captures metrics, which is called pull mode. The other is that the server actively reports the metrics to the Push Gateway, and Prometheus obtains them from the Push Gateway, which is called push mode. Push Gateway is an important intermediary role in push mode, used to temporarily store the metrics reported by the server and wait for Prometheus to collect them.
Why are there two models? Let's compare the characteristics of these two models.
1. Pull mode: Prometheus active crawling mode, the frequency of crawling can be controlled by Prometheus server, simple and clear, and the control power is in Prometheus server. Through the service discovery mechanism, new services can be automatically accessed and offline services removed without any manual intervention. For a variety of common services, the official or community has a large number of Exporters to provide metrics collection interfaces, basically without development. It's officially recommended.
2. Push mode: The server actively reports to Push Gateway, and the minimum granularity of collection is determined by the server, which means that Push Gateway acts as an intermediary, collecting the metrics actively reported by each service, and then collecting them by Prometheus. However, there is a single performance point of Push Gateway, and Push Gateway also has to deal with persistence problems, otherwise some data will be lost due to downtime. At the same time, the server needs to provide the function of active reporting, which may involve some development changes. Not the preferred method, but it works well in some scenarios. For example, some temporary tasks may exist for a very short time, and if Pull mode is used, data may not be captured.
Alert Manager
Alert Manager is an alert component of Prometheus. When Prometheus server detects an alarm, it pushes an alert to Alert Manager, which then sends it to notification end, such as Email, Slack, WeChat, nail, etc. Alert Manager provides grouping, aggregation, suppression, silence and other functions of alarms according to relevant rules.
Web UI/Grafana
Prometheus provides a simple web UI interface for querying data, viewing alarms, configurations, etc. It is officially recommended to use grafana, another open source project, to visualize indicators, make dashboards, etc.
V. Download
Download address: prometheus.io/download/
Download serverwget -c https://github.com/prometheus/prometheus/releases/download/v2.15.0/prometheus-2.15.0.linux-amd64.tar.gz Download nodewget -c https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
VI. Configuration Description
Profile: prometheus.yml
# my global configglobal: scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. 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 #alarm monitoring 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=` to any timeseries scraped from this config. - job_name: 'prometheus' # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ['localhost:9090']
Description:
global: global configuration, wherein scrape_interval indicates the interval time for fetching data once, evaluation interval: indicates the interval time for detecting alarm rules;
alerting: configuration of alert manager, alert manager needs to be installed;
rulefiles: what are the alarm rules;
scrapeconfigs: targets for capturing surveillance information. A job_name is a target, and its targets are the IP and port on which the information is collected. Prometheus itself is monitored by default here. You can modify the monitoring port of Prometheus by modifying here. Each exporter of Prometheus will be a target, they can report different monitoring information, such as machine status, or mysql performance, etc., different languages sdk will also be a target, they will report your custom business monitoring information.
VII. Deployment
Deployment process:
Install prometheus on the monitoring server
2. Install export on the monitored environment
1. Server startup method:
./ prometheus --config.file=/data/prometheus-2.15.0.linux-amd64/prometheus.yml
2. Node startup method:
nohup ./ node_exporter &
3. Add the application to the system service
vim /etc/systemd/system/prometheus.service
[unit]Description=Prometheus Monitoring SystemDocumentation=Prometheus Monitoring System[Service] ExecuStart =/data/prometheus/prometheus \ --config.file=/data/prometheus/prometheus.yml \ --web. liste-address =:9090##Refer to installation directory [Install]WantedBy=multi-user.target for file path
Then you can start with systemctl.| stop| status| enable promethods.service
VIII. VISITS
http://127.0.0.1:9090
Reference link: prometheus installation
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.