APM Monitoring on Android Based on General + Promthues + Pushgateway on Mac (1)
With the continuous increase of the company’s business and the growth of each business, each business pays more and more attention to some performance indicators of the APP. Since the company does not have a complete APM system at present, it has to build a complete APM system by itself
-
Environment set up
-
General installation
brew install grafana
Copy the code
Default installation path:
/usr/local/Cellar/grafana
Copy the code
Activation:
grafana-server --config=/usr/local/etc/grafana/grafana.ini --homepath /usr/local/share/grafana --packaging=brew cfg:default.paths.logs=/usr/local/var/log/grafana cfg:default.paths.data=/usr/local/var/lib/grafana cfg:default.paths.plugins=/usr/local/var/lib/grafana/plugins
Copy the code
After the startup is complete, enter http://localhost:3000/ in the browser and press Enter to enter the home page. The default user name and password are admin.
Enter the account and password (both are admin), then go to the home page
Here, General has been successfully installed and started. However, General is just a UI display interface for us. Specific data sources need to be added by ourselves, as shown in the figure below
The data source chosen for this article is Promthues
-
Promthues installation
brew install prometheus
Copy the code
The default installation path is:
/usr/local/Cellar/prometheus
Copy the code
Also generates a default configuration file: / usr/local/etc/Prometheus. Yml
global:
scrape_interval: 15s
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
Copy the code
Enter the installation directory and run the following command:
./prometheus --config.file=/usr/local/etc/prometheus.yml
Copy the code
If smooth, should be able to start successfully normally, enter http://localhost:9090 in browser enter home page
The Promthues installation is successful
-
Pushgateway installation
Download the latest pushgateway-1.4.1. Darwina-amd64.tar. gz from Prometheus
After the download is complete, decompress it to a local directory and enter the decompressed directory
./pushgateway
Copy the code
If it starts properly, browse http://localhost:9091 to see why you need to install Pushgateway. The following is the Pushgateway and Promthues working flowchart
The client (either writing code or typing on the command line) pushes the data to the pushgateway, from which Prometheus pulls the data.
After installed, change to the/usr/local/etc/Prometheus. Yml or Prometheus not perceive the existence of the gateway
global: scrape_interval: 15s scrape_configs: - job_name: "prometheus" static_configs: - targets: -job_name: "push-metrics" static_configs: -targets: ["localhost:9091"] Honor_labels: trueCopy the code
Add these last few lines, and it is best to restart Prometheus for the configuration file to take effect.
The installation of the General, Promthues, and Pushgateway environment is complete. The next installment will introduce how to upload data to Promthues and how to configure Promthues as the data source