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

How does prometheus+grafana monitor nginx

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces prometheus+grafana how to monitor nginx, the article is very detailed, has a certain reference value, interested friends must read it!

In the prometheus, we need to insert the probe into the ngxin, obtain the ngxin information through the probe, and output it through the interface. How to monitor ngxin is described below.

1. download

For the convenience of everyone, here is a wave of download address, if the template is not particularly satisfied, you can also go to the official website to download it.

Nginx:

Link: https://pan.baidu.com/s/1QxcWrxAEARlEhxSb2ZETjQ

Extraction code: 6fp5

Nginx-module-vts-master:

Link: https://pan.baidu.com/s/1gCyAithAlRkORuZwhpcPmA

Extraction code: h9aa

Nginx-vts-exporter

Link: https://pan.baidu.com/s/1gVB_I6ifDbeNIBX5x9pGAA

Extraction code: upkw

Nginx-vts-stats_rev2 (grafana display template)

Link: https://pan.baidu.com/s/1VI9V395OemPkf6W-sNL9HQ

Extraction code: da56

two。 Install nginx and nginx-vts-exporter

1. Decompress nginx-vts-exporter

Here nginx is reinstalled, unzip nginx-vts-exporter here and put it in usr/local.

Unzip nginx-module-vts-master.zip

Note here that the nginx version is required or an error will be reported. The following is the corresponding version of nginx.

two。 Extract the nginx.

Tar-zxvf nginx-1.14.2.tar.gz

3. Installation

Put nginx-vts-exporter into the nginx path and perform the installation operation.

Cd usr/local/nginx-1.14.2./configure-- prefix=/usr/local/nginx-- add-module=usr/local/nginx-module-vts-master/ Note: note that prefix=/usr/local/nginx means the installation location is / usr/local/nginx folder make install

4. Modify the conf file

Http {vhost_traffic_status_zone; vhost_traffic_status_filter_by_host on;...server {... Location / status {vhost_traffic_status_display; vhost_traffic_status_display_format html;}}

5. Start

Cd / usr/local/nginx/sbin./nginx

When accessing http://ip/status, the following display indicates that nginx and nginx-vts-exporter are installed successfully.

3. Install nginx-vts-exporter-0.9.1.linux-amd64.tar

Here the installation package is placed under usr/local and decompressed.

Tar-zxvf nginx-vts-exporter-0.9.1.linux-amd64.tar

Activate.

Cd / usr/local/nginx-vts-exporter-0.9.1.linux-amd64nohup. / nginx-vts-exporter- nginx.scrape_uri http://ip/status/format/json &

Enter http://ip:9913/metrics, and if the following proof appears, complete.

4. Configure Prometheus

Modify / usr/local/prometheus-2.17.1.linux-amd64/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 configurationalerting: 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' static_configs:-targets: [' localhost:9090']-job_name: 'nginx' static_configs:-targets: [' ip:9913']

The following configuration is successful.

5. Configure Grafana

Enter the grafana visualization page address: ip:3000.

1. Configure the data source (prometheus address: ip:9090)

Fill in your prometheus address in the above picture, and remember to fill in 9090 in the port. After clicking save, there will be a prompt if you fail.

two。 Visual interface template

Select the data source configured above, and the prometheus option is the data source configured above.

3. Verification

The following display indicates success.

The above is all the contents of the article "how prometheus+grafana monitors nginx". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report