APM Monitoring on Android Based on Grafana + Promthues + Pushgateway

Grafana + Promthues + Pushgateway service environment What’s missing now is how to upload data. Before we talk about data uploading, we’d like to summarize the overall framework of the APM:

From the figure, we can see that the whole package is divided into four components: Pushgateway, Promthues, Grafana (WEB UI), and Alertmanager

Pushagateway: Is an important tool in the Promthues ecosystem. Because the Promthues uses the pull mode, the Promthues may not be in the same subnet or firewall. As a result, the Promthues may not be able to directly pull data from each target. Unified is collected by Promthues

Promthues: An open source monitoring alarm solution from SoundCloud, Promthues stores temporal data, which is a collection of continuous data stored in time dimensions with the same timing (same name and label)

You can set up different data sources. Promthues is one of the data sources. Then you can display it in different charts, reports, etc. Grafana is very powerful

Alertmanager: The Alertmanager is an alarm component of the Promthues to facilitate data monitoring

  • Data upload

  1. Mac curl Post is used to upload data

First create a new data.txt file and then write the following

Blog_visit_total {blogid = "12345", clientip = "10.0.1.1}" 30 blog_visit_total {blogid = "34567", clientip = "10.0.1.2}" 40 Blog_visit_total {blogid = "56789", clientip = "10.0.1.3}" 50Copy the code

Use curl to delete data

curl -XPOST --data-binary @/Users/dengqu/Downloads/data.txt http://localhost:9091/metrics/job/cnblogs
Copy the code

After, go to http://localhost:9091/metrics you will see just upload data

Visit http://localhost:9091

At this time, the data has been uploaded successfully. You can log in to the Promthues service address again to query the data

The data is already stored in Promthues, so we can have the data graphically displayed on Grafana

1. Log in to Grafana and add the data sourceLog in to Grafana and create the data source

Add a data source

Select Promthues as the data source

Enter the Promthues server address

Save and test

2. Add Pannel The data source has been added. The following is the display of data in Pannel

Add na empty Pannel

Set the panel title, write the PromSql statement, and save it

Finally, it’s presented graphically

You can select the data time and refresh time to select the data area. Last 5 minutes indicates the data in the last 5 minutes

Select the page refresh interval, below is 5s automatic refresh once

The data report is based on the MAC curl post command to upload the data. How to collect and upload the data