apm-agent-php icon indicating copy to clipboard operation
apm-agent-php copied to clipboard

Getting 502 when using in combination with Azure Application Gateway

Open romulo-dbts opened this issue 5 years ago • 6 comments

Hi there,

I was testing the extension with my PHP 7.3.14 (Ubuntu) which runs an Apache server. As load balancer solution we are using Azure Application Gateway. So basically the requests go first to Application Gateway and then it hits my Apache server.

Checking the logs I can see that my Apache is responding the requests with 200 but the application gateway is responding with 502. Disabling the APM extension everything starts working fine again. Even getting 502 I am able to see the traces being sent to APM dashboard.

Any thoughts on what can be the issue here?

romulo-dbts avatar Aug 24 '20 09:08 romulo-dbts

Hi @romulo-dbts,

Could you please provide agent's logs? The agent logs to syslog by default.

SergeyKleyman avatar Aug 24 '20 09:08 SergeyKleyman

@SergeyKleyman here it goes https://pastebin.com/Tpz5Lwpa

romulo-dbts avatar Aug 24 '20 09:08 romulo-dbts

I see a few messages of the following kind

AH00051: child pid 91 exit signal Segmentation fault (11), possible coredump in /etc/apache2

Also I don't see any messages from PHP Agent - please add elastic_apm.log_level_syslog = TRACE to php.ini.

  1. If you remove elastic_apm extension from php.ini do messages exit signal Segmentation fault still occur?
  2. If the answer to the previous question is no (which means elastic_apm extension crashes Apache) please remove elastic_apm.bootstrap_php_part_file=<repo root>/src/bootstrap_php_part.php line from php.ini (but leave extension=elastic_apm.so) - does Apache still crash?

Please provide the logs (with elastic_apm.log_level_syslog = TRACE) for both with and without elastic_apm.bootstrap_php_part_file=<repo root>/src/bootstrap_php_part.php line.

SergeyKleyman avatar Aug 24 '20 10:08 SergeyKleyman

Do you have any additional non-standard extensions? I would like to make sure that there are no other extensions that might conflict with elastic_apm like the one mentioned in #123.

SergeyKleyman avatar Aug 24 '20 10:08 SergeyKleyman

These are my modules

[24-Aug-2020 11:21:20 UTC] PHP Warning:  Module 'imagick' already loaded in Unknown on line 0
[PHP Modules]
apcu
bcmath
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
geoip
gettext
hash
iconv
imagick
intl
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
soap
sodium
SPL
sqlite3
standard
tidy
timezonedb
tokenizer
xdebug
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Xdebug
Zend OPcache

romulo-dbts avatar Aug 24 '20 11:08 romulo-dbts

@SergeyKleyman Here is the outcome performing the tests that you asked.

  1. No. The errors does not occur
  2. Removing elastic_apm.bootstrap_php_part_file=<repo root>/src/bootstrap_php_part.php apache does not crash, works fine

Below you can find the requested logs

  1. With elastic_apm.bootstrap_php_part_file=<repo root>/src/bootstrap_php_part.php - https://pastebin.com/3LbRN5uv
  2. Without elastic_apm.bootstrap_php_part_file=<repo root>/src/bootstrap_php_part.php - https://pastebin.com/6miqsj4c

romulo-dbts avatar Aug 24 '20 11:08 romulo-dbts

@romulo-dbts HI. Could you please check if the problem still occurs with the latest agent release (it's v1.9.1 at the moment)?

SergeyKleyman avatar Jul 18 '23 08:07 SergeyKleyman