How to enable Debug in the Apigee Edge Router and Message Processor?

Enabling debug sends debug level messages to the <InstallRoot>/apigee4/var/log/apigee/router/logs/system.log or <InstallRoot>/apigee4/var/log/apigee/message-processor/logs/system.log. These steps to enable debug using router and message processor management API calls allow you to enable debug to troubleshoot a problem without having to restart your message processor or router.

Router:

1. To Create a debug session on router

curl -v -X POST "http://localhost:8081/v1/logsessions?session=test"

2. To disable

curl -v -X DELETE "http://localhost:8081/v1/logsessions/test"

Message-Processor:

1. To Create a debug session on MP

curl -v -X POST "http://localhost:8082/v1/logsessions?session=test"

2. To disable

curl -v -X DELETE "http://localhost:8082/v1/logsessions/test"

Note: the query value for the session name can be any alphanumeric string. I used the value "test" as an example. Remember that the value of the session will need to be used to disable debug logging when used as part of the DELETE request uri.

Also note, enabling debug create a performance I/O hog and will slow down API traffic. We do NOT recommend enabling debug in production.

Comments
gnanasekaran
Staff

This is great! Thanks @Janice Hunt, @Floyd Jones - this will be very useful in operations guide, if not already captured

sgilson
New Member

I can add it.

Stephen

atoombs
Staff

Thanks for this @Janice Hunt.

Isn't there an API call to retrieve (GET) the debug sessions once created, or is it required to have access to the Router/MP server's filesystem (to scp the files, for example)?

remeeshnair
Bronze 1
Bronze 1

There is a catch here. If you run the DEBUG for longer duration the DELETE commands will not function and DEBUG will not stop. To recover from the situation there is a restart of the Router or Message Processor process required. From my experience anything above 30 minutes is not safe. So watch out your system.log is still in DEBUG mode after the DELETE curl call. My OPDK is 4.15.04.04, there was a case open with Apigee team, there might be a fixpack releasing soon if not already.

Not applicable

I could replicate this bug in my environment. Hopefully there will be a fix out soon.

Also, It would be nice if there is an option to DELETE the debug session using the session uuid

Not applicable

@jhunt@apigee.com

Disable MP did not work for me.

curl -v -X DELETE "http://xxx.xxxxx.xxx:8080/v1/logsessions/test"

I get following error.

[root@edge-ui]# curl -v -X DELETE "http://xxxxx.xxxx.local:8080/v1/logsessions/test" -u sample@sample.com Enter host password for user 'sample@sample.com': * About to connect() to xxxxx.xxxxx.local port 8080 (#0) * Trying 10.0.8.565... connected * Connected to xxxxx.xxx.local (10.0.8.565) port 8080 (#0) * Server auth using Basic with user 'sample@sample.com' > DELETE /v1/logsessions/test HTTP/1.1 > Authorization: Basic dddddddddddddddddddddddddddddd > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.19.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2 > Host: xxxxx.xxxx.local:8080 > Accept: */* > < HTTP/1.1 404 Not Found

I was able to start the DEBUG. but unable STOP now. what's wrong my curl ? thank you.

atoombs
Staff

Here is set of commands that has worked for me to get this information. Note, while you don't need access to the file system on the RRTs/MPs, this does require access to a *nix server that can reach ports 8080-8082. (These could be altered slightly for Windows if needed).

You would first need to create /tmp/servers.lst that contains a list (one per line) of the hostname or IP of the servers. After you run these, you will have files like /tmp/2016.06.30_09.00.00-servername.zip, which will contain the DEBUG logs. As this is most commonly used on MPs, I've set the port to 8082:

svcPort="8082" ; logDate=`date +%Y.%m.%d` ; for m in $(cat /tmp/servers.lst) ; do curl -v -u $USERID:$USERPASSWORD -X POST "http://$m:$svcPort/v1/logsessions?session=$logDate-$m" ; done ; echo 

Recreate the issue being debugged at this point

svcPort="8082" ; logDate=`date +%Y.%m.%d` ; for m in $(cat /tmp/servers.lst) ; do curl -v -u $USERID:$USERPASSWORD -X GET "http://$m:$svcPort/v1/logsessions/$logDate-$m" -o /tmp/`date +%Y.%m.%d_%k.%M.%S`-$m.zip ; done ; echo 
svcPort="8082" ; logDate=`date +%Y.%m.%d` ; for m in $(cat /tmp/servers.lst) ; do curl -v -u $USERID:$USERPASSWORD -X DELETE "http://$m:$svcPort/v1/logsessions/$logDate-$m" ; done ; echo 
Version history
Last update:
‎02-16-2015 06:50 PM
Updated by: