Intrusion Link Tracking APM with Pinpoint
I. Intrusion Link Tracking APM
Application Performance Management (APM)
It means to monitor and optimize the key business of an enterprise, to improve the reliability and quality of its business, to ensure that its customers receive good service, to reduce the total cost of IT operation and maintenance, and to bring more business benefits to the enterprise.
Introduction to Pinpoint
Pinpoint is an APM (Application Performance Management) tool for large distributed systems written in Java / PHP. We try to be simple and efficient in use. By installing agent at startup, we can minimize the performance loss (3%) without modifying even one line of code.
- Advantages:
1) Distributed transaction tracking, tracking messages across distributed applications;
2) Automatically detect the application topology to help you understand the application architecture;
3) Horizontal scaling to support large-scale server clusters;
4) Provide code-level visibility to easily locate failures and bottlenecks;
5) Use bytecode enhancement technology to add new functions without modifying the code. - Major components
assembly | Component function |
---|---|
Pinpoint-Collector | Collect various performance data |
Pinpoint-Agent | Probes are associated with application servers, such as tomcat, and deployed on the same server |
Abase Storage | Collected data stored in HBase |
Pinpoint-Web | The data layer to be collected is now displayed on the web |
2. Fast deployment of pinpoint in Rainbond
Key installation based on Rainbond application market.
This deployment method reduces the deployment difficulty and workload to the greatest extent for complex multi-component applications such as pinpoint.
- Import the UI interface to pinpoint through pinpoint-web application
- In the default settings, the pinpoint application has monitored its own collector, web components. After entering the UI interface, you can see that both of them already exist in the application list.
3. Adding monitored objects
- Inserting agent in war start-up process
1) To mirror the pinpoint-agent resources in advance;
2) Insert startup key code:
#pinpoint-agent.sh #Specify pinpoint-agent resources CATALINA_OPTS="$CATALINA_OPTS -javaagent:$PINPOINT_AGENT_PATH/pinpoint-bootstrap-${PINPOINT_AGETN_VERSION}-SNAPSHOT.jar" #Specify pinpoint-agent ID CATALINA_OPTS="$CATALINA_OPTS -Dpinpoint.agentId=${AGENT_ID}" #Specify application name CATALINA_OPTS="$CATALINA_OPTS -Dpinpoint.applicationName=${APP_NAME}"
#docker-entrypoint.sh #Determine whether to open pinpoint-agent if [ "$ENABLE_APM" == "true" ];then #collector address COLLECTOR_TCP_HOST=${COLLECTOR_TCP_HOST:-127.0.0.1} #TCP port COLLECTOR_TCP_PORT=${COLLECTOR_TCP_PORT:-9994} COLLECTOR_UDP_SPAN_LISTEN_HOST=${COLLECTOR_UDP_SPAN_LISTEN_HOST:-127.0.0.1} COLLECTOR_UDP_SPAN_LISTEN_PORT=$ #UDP Port {COLLECTOR_UDP_SPAN_LISTEN_PORT:-9996} COLLECTOR_UDP_STAT_LISTEN_HOST=${COLLECTOR_UDP_STAT_LISTEN_HOST:-127.0.0.1} COLLECTOR_UDP_STAT_LISTEN_PORT=$ #UDP Port {COLLECTOR_UDP_STAT_LISTEN_PORT:-9995} #Loading agent at startup sed -i "2 a. /usr/local/tomcat/bin/pinpoint-agent.sh" /usr/local/tomcat/bin/catalina.sh #Import to pinpoint-agent configuration file sed -i -r -e "s/(profiler.collector.ip)=.*/\1=${COLLECTOR_TCP_HOST}/" \ -e "s/(profiler.collector.tcp.port)=.*/\1=${COLLECTOR_TCP_PORT}/" \ -e "s/(profiler.collector.span.port)=.*/\1=${COLLECTOR_UDP_SPAN_LISTEN_PORT}/" \ -e "s/(profiler.collector.stat.port)=.*/\1=${COLLECTOR_UDP_STAT_LISTEN_PORT}/" /usr/local/pinpoint-agent/pinpoint.config #Default values are generated for every application on the platform export APP_NAME=${APP_NAME:-${SERVICE_NAME:-${HOSTNAME}}} #Using APP_NAME, POD_IP differentiates Agent-ID of each instance under a service export AGENT_ID=${APP_NAME}-${POD_IP} fi
- Insert agent in jar start-up process
1) Put pinpoint-agent resources into source warehouse beforehand;
2) Start script content:
#!/bin/bash #Determining whether to start pinpoint agent by specific environment variables if [[ $ENABLE_APM == "true" ]];then AGENT_ID=${SERVICE_ID:0:10} PINPOINT_AGETN_VERSION=1.7.2 PINPOINT_AGENT_PATH=/app/pinpoint #Add the pinpoint agent startup parameter to $JAVA_OPTS export JAVA_OPTS="$JAVA_OPTS -javaagent:$ {PINPOINT_AGENT_PATH}/pinpoint-bootstrap-${PINPOINT_AGETN_VERSION}- SNAPSHOT.jar -Dpinpoint.agentId=${AGENT_ID:-${SERVICE_ID:0:10}} -Dpinpoint.applicationName=${APP_NAME:-${SERVICE_NAME:- $HOSTNAME}}" fi PORT=${PORT:-5000} sleep ${PAUSE:-0} #Final Start Command exec java -Dserver.port=$PORT $JAVA_OPTS -jar target/*.jar
In traditional architecture, pinpoint needs to add Agent to the monitored object and make it effective by modifying the configuration file. On the cloud platform, we have simplified these two steps accordingly.
Cloud Band Platform uses the way of setting environment variables instead of configuration files. Key value pairs are very simple and easy to use in the form of environment variables.
Adding Pinpoint Monitoring Object Practice
Method 1
Next, take the todo API as an example, and introduce how to add monitored objects.
- Associated Pinpoint-Collector
- View connection information
- Visit Pinpoint-Web View:
- Deployed applications can also be deployed through Application Management Interface Dependencies, settings tabs, to configure the corresponding service dependencies and environment variables.
Method 2
- After opening Pinpoint-Collector external services, the platform gateway defines a layer of port mapping relationships
- Check the todoshow variable value, check whether the port number is correct, and activate the agent's switch
- Visit Pinpoint-Web View and todoshow appears on the interface
- In Pinpoint-Web, Web ocket protocol is used for real-time push, but http protocol is used for access to Pinpoint-Web applications; therefore, we can not receive push in real-time. We need to find the Pinpoint-Web application in the application gateway - > access control of the platform, and open the support of Web ocket protocol by clicking on parameter configuration.