prometheus+grafana for server resource monitoring

In performance testing, server resources are worth paying attention to. At present, there are many server resource monitoring methods and various monitoring tools on the market, which are convenient for use in various projects.

However, in performance testing, which indicators are worthy of attention?

The monitoring has a classification system, which is quoted below:

picture

In previous work, if we want to monitor server resources and DB, we can only rely on the task manager and the naked eye, and cannot save historical data. There are also large errors in the results, resulting in the inability to give accurate results.

The following is an introduction to prometheus:

node_expoert: The monitored machine. Both Windows and Linux systems can use Prometheus: Prometheus service, used for monitoring data collection and query, can be deployed under Windows and Linux

Grafana: Grafana service, used for data display, can be deployed under windows and Linux

picture

node_expoert:(windows)

first step:

Open and run windows_exporter.exe

picture

Verification method: visit in the browser: locahost:9182, if it can be accessed normally, the following content appears, indicating that the startup is successful:

picture

Step 2: The firewall should be enabled on the server, and the port used needs to be allowed to pass through the firewall before it can be used.

picture

picture

picture

Step 3: Verify whether it can be normal on another machine Enter the server's ip+9182 in the browser on another machine to check whether the same result as the first step occurs

node_expoert: (Linux, take centos7 as an example)

first step:

Upload node_expoert. The node_expoert used by Windows and Linux is inconsistent. Step 2:

move directory

picture

Step 3: Start in the background

nohup /usr/local/node_exporter/node_exporter & If the output is appended to nohup.out, it is normal Step 4: Check whether the service is opened normally

Run: netstat -nultp

Successful startup results:

picture

Step 4: The server should have opened the firewall

Under Linux, the port used by node_expoert is 9100. First check if the port is open:

Run: firewall-cmd --query-port=9100/tcp

If no is returned, the port is not open

Open the corresponding port:

firewall-cmd --zone=public --add-port=9100/tcp --permanent After opening the port, you need to restart the firewall:

firewall-cmd –reload

the fifth step:

Access the collection address on another machine:

Server ip:9100/metrics

If the following content appears, it means success

picture

Prometheus:

Take windows as an example, if you need to use docker or Linux, please refer to: https://testerhome.com/topics/22231 Download: You can get the latest installation package on the official website

The first step: service startup: double-click to run

picture

Authentication method:

Access the server ip+9090, it can be accessed normally, and the following content appears to indicate that the startup is successful

picture

Step two:

prepare node_expoert

Open the configuration file of prometheus.yml and add a new job to the configuration file

picture

Step 3: Restart the service of prometheus

the fourth step:

After a short delay, access the service address of prometheus. Enter status---targets to see the node_expoert just added

picture

If the state of node_expoert is up, it means that the access to node_expoert is down, which means it failed

picture

Grafana:

Grafana is an open source measurement analysis and visualization tool that can analyze, query, and then visualize the collected data, and realize alarms.

Service installation:

Visit the official website to get the installation package

Service start:

Enter GrafanaLabs\grafana\bin, run grafana-server.exe to start the service access address: server ip+3000

Similarly, if the firewall is open, you need to allow grafana-server.exe to access for the first time through the firewall, use

admini/admini can log in successfully. After that, the system will prompt to change the password. Just change the password that meets the requirements of the rules.

first step:

add data source

Enter Configuration-Data Sources, add a data source, select Prometheus

picture

Data source settings:

Fill in the name and url and save it

picture

Step two:

Add monitoring board Currently, we use the official board to click create----import

picture

pay attention:

1. Windows machines and Linux machines use inconsistent kanban files. Windows machines can only use Windows kanban, and Linux machines can only use Linux kanban.

2. If node_expoert uses the latest V0.13.0 version when monitoring the window server, you need to modify and replace the query statement in the Kanban

Need to modify wmi_ to windows_

picture

3. If you want to get the official dashboard, please visit: https://grafana.com/grafana/dashboards

picture

Finally, I would like to thank everyone who has read my article carefully. Reciprocity is always necessary. Although it is not a very valuable thing, you can take it away if you need it:

insert image description here

Software testing interview applet

The software test question bank maxed out by millions of people! ! ! Who is who knows! ! ! The most comprehensive quiz mini program on the whole network, you can use your mobile phone to do the quizzes, on the subway or on the bus, roll it up!

The following interview question sections are covered:

1. Basic theory of software testing, 2. web, app, interface function testing, 3. network, 4. database, 5. linux

6. web, app, interface automation, 7. performance testing, 8. programming basics, 9. hr interview questions, 10. open test questions, 11. security testing, 12. computer basics

These materials should be the most comprehensive and complete preparation warehouse for [software testing] friends. This warehouse has also accompanied tens of thousands of test engineers through the most difficult journey. I hope it can help you too!   

Guess you like

Origin blog.csdn.net/qq_48811377/article/details/132638679