Analyze the method of prometheus+grafana monitoring nginx

Analyze the method of prometheus+grafana monitoring nginx

insert image description here

In prometheus, you need to insert probes into ngxin, obtain ngxin information through the probes, and output it through the interface. The following will describe how to monitor ngxin.

1. Download

For your convenience, a wave of download addresses are provided here. If you are not particularly satisfied with the template, you can also go to the official website to download it yourself.

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

2. Install nginx and nginx-vts-exporter

1. Unzip nginx-vts-exporter

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

unzip nginx-module-vts-master.zip

Please note that there are requirements for the nginx version, otherwise an error will be reported. The following is the corresponding version of nginx.

insert image description here

2. Unzip nginx.

tar -zxvf nginx-1.14.2.tar.gz

3. Installation

Put nginx-vts-exporter in the nginx path and install it.

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 the /usr/local/nginx folder.

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. Startup

cd /usr/local/nginx/sbin
./nginx 

insert image description here

Visit http://ip/status and the following information appears, indicating that nginx and nginx-vts-exporter have been successfully installed.

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

The installation package here is placed in usr/local and unzipped.

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

start up.

cd /usr/local/nginx-vts-exporter-0.9.1.linux-amd64
nohup ./nginx-vts-exporter -nginx.scrape_uri http://ip/status/format/json &

Enter http://ip:9913/metrics. If the following information is displayed, the system is complete.

insert image description here

4. Configure Prometheus

Modify /usr/local/prometheus-2.17.1.linux-amd64/prometheus.yml.

# my global config
global:
  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
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'
    static_configs:
    - targets: ['localhost:9090']
  - job_name: 'nginx'
    static_configs:
      - targets: ['ip:9913']    

The following configuration is successful.

insert image description here

5. Configure Grafana

Enter the grafana visualization page address: ip:3000.

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

insert image description here
insert image description here

Fill in your prometheus address in the above picture, remember to fill in 9090 as the port, and click save. If it fails, there will be a prompt.

2. Visual interface template

insert image description here

Select the data source configured above. The prometheus option is the data source configured above.

insert image description here

3. Verification

The following display indicates success.

insert image description here

This is the end of this article about analyzing the method of prometheus+grafana monitoring nginx. For more relevant prometheus+grafana monitoring nginx content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed explanation of performance monitoring of MySQL server using Prometheus and Grafana
  • Detailed tutorial on grafana installation and usage
  • Use Grafana to display monitoring charts of Docker containers and set email alert rules (illustration)
  • Detailed explanation of the tutorial on monitoring Springboot applications using Prometheus+Grafana
  • Use Grafana+Prometheus to monitor MySQL service performance
  • Detailed explanation of the process of building Prometheus+Grafana based on docker
  • Summary of influx+grafana custom python data collection and some pitfalls
  • Detailed steps for SpringBoot+Prometheus+Grafana to implement application monitoring and alarm
  • How to install grafana and add influxdb monitoring under Linux
  • Prometheus monitors MySQL using grafana display
  • How to monitor Docker using Grafana on Ubuntu
  • Detailed tutorial on building a JMeter+Grafana+Influxdb monitoring platform with Docker
  • Tutorial on building a JMeter+Grafana+influxdb visual performance monitoring platform in docker environment
  • Deploy grafana+prometheus configuration using docker
  • ELK and Grafana jointly create visual monitoring to analyze nginx logs
  • It doesn’t matter if you forget your Grafana password. 2 ways to reset your Grafana admin password

<<:  MySQL master-slave synchronization principle and application

>>:  CSS3+Bezier curve to achieve scalable input search box effect

Recommend

MySQL database JDBC programming (Java connects to MySQL)

Table of contents 1. Basic conditions for databas...

Solve the error problem caused by modifying mysql data_dir

Today, I set up a newly purchased Alibaba Cloud E...

The forgotten button tag

Note: This article has been translated by someone ...

How to install Linux online software gcc online

Linux online installation related commands: yum i...

Vue imports Echarts to realize line scatter chart

This article shares the specific code of Vue impo...

Implementation of Docker deployment of MySQL cluster

Disadvantages of single-node database Large-scale...

HTML tbody usage

Structured Table (IExplore Only) 1) Group by rows ...

MySQL Query Cache Graphical Explanation

Table of contents 1. Principle Overview Query Cac...

Some thoughts and experience sharing on web page (website) design and production

First, before posting! Thanks again to I Want to S...

Vue Element front-end application development table list display

1. List query interface effect Before introducing...

Detailed explanation of the use of HTML header tags

HTML consists of two parts: head and body ** The ...

Detailed explanation of how to use the calendar plugin implemented in Vue.js

The function to be implemented today is the follo...

How to use CSS to write different styles according to sub-elements

The effect we need to achieve: What is needed The...

In-depth explanation of the maximum value of int in MySQL

Introduction I will write about the problem I saw...

An example of elegantly writing status labels in Vue background

Table of contents Preface optimization Extract va...