This article mainly explains how to use the APM function of ES to get the running status. In fact, the official website has an installation process, I just record my installation process.
Preface
Because Alibaba Cloud has ARMS. I found out about APM just when I was communicating with friends on the Internet. Suddenly I discovered that Alibaba Cloud's AMRS is not APM. And because ARMS only supports up to PHP7.3, I specially came to see how to install ES's APM, because it supports PHP8.0. The supported version is also relatively new.
First, please follow the previous two articles to set ubuntu install ElasticSearch and ubuntu install kibana .
Install the required packages
What we need here is apm-server. Execute the following command to install:
sudo apt install apm-server
Finally, execute the start command.
Management commands
start up:
sudo systemctl start apm-server
stop:
sudo systemctl stop apm-server
Restart:
sudo systemctl restart apm-server
Set boot up:
sudo systemctl enable apm-server
Cancel startup
sudo systemctl disable apm-server
Check running status
sudo systemctl status apm-server
PHP Agent
An extension needs to be installed here. First of all, you need to install PHP. Here is an article about installing PHP8.0 for reference.
If it is not apt
, it is recommended to use the following manually install .
First download the specified deb
package GitHub package download
Then execute the command to install agent
:
sudo dpkg -i <package-file>.deb
After the installation is successful, the editable configuration file address is: /etc/php/8.0/fpm/conf.d/99-elastic-apm-custom.ini
.
Manual installation
You can perform the following steps to compile and install.
First we need to store the source code in a directory. For example, /usr/local/src
.
The first is to download the file and unzip it:
sudo wget -c https://github.com/elastic/apm-agent-php/archive/refs/tags/v1.3.tar.gz
sudo tar zxf v1.3.tar.gz
Then we cut into the directory to be compiled and execute the compilation command
cd apm-agent-php-1.3/src/ext
sudo phpize
sudo CFLAGS="-std=gnu99" ./configure --enable-elastic_apm
sudo make
sudo make install
After completion php.ini
add the following configuration to enable elastic_apm
.
extension=elastic_apm.so
elastic_apm.bootstrap_php_part_file=<repo root>/src/bootstrap_php_part.php
Configuration
elastic_apm.environment
Set the environment name. For example, the test environment can be set to testing
or production
. Used to distinguish environmental variables.
elastic_apm.hostname
Set the host name. Because the default names are random, they can be set to more user-friendly names. If the name is not set, the name of the host is read by default
elastic_apm.server_url
The link address of the APM server. Contains protocol and port. The default address is http://localhost:8200
, if the APM server is not in this machine, you need to set it up.
elastic_apm.service_name
The name of the service. That is, the name of the project. For example, the api
project, the base
project and so on.
elastic_apm.service_node_name
Node name. This setting is particularly useful when there is a web cluster. For example, the name is php-1
and so on.
elastic_apm.service_version
The version number of the service. For example, for PHP, you can use commit ID
as the version number. It can be set to git rev-parse HEAD
or use the abbreviation git log --pretty="%h" -n1 HEAD
.
elastic_apm.transaction_sample_rate
Set the frequency of sampling requests. The default is 1.0
and the range is 0.0
~ 1.0
. If it is not collected, no context information, tags or spans will be recorded.
finally
In this way, restart PHP and visit a few links to view the relevant information collected by APM in Kibana.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。