Analyzing Logs with the Log Analyzer
The Log Analytics in WSO2 API Manager helps you to view your API related statistics and helps you to analyze it. Follow the procedure below to view reports in WSO2 Log Analyzer.
Start the WSO2 API-M Analytics server. Then start the WSO2 API Manager server by running one of the following commands from the
<API-M_ANALYTICS_HOME>/bin
directory.- On Windows:
wso2server.bat --run
On Linux/Mac OS:
sh wso2server.sh
To update the Log Analyzer with the most recent information, execute the
APIM_LOGANALYZER_SCRIPT
script as follows. This script is automatically run every 15 minutes based on the cron job.- Log into the API-M Analytics Management Console using the
https://<ANALYTICS-APIM_Host_Name>:<ANALYTICS-APIM_Port_Name>/carbon/
URL. - In the Main tab, click Scripts to open the Available Analytics Scripts page.
- Click Execute for the
APIM_LOGANALYZER_SCRIPT
script to update the Log Analyzer.
- On Windows:
- Access the WSO2 API Manager Admin Portal using the
https://<
URL. Log into the portal using your credentials. As default credentials use both username and password as "admin".APIM_Host_Name
>:<APIM_Port_Name
>/admin - In the left navigator, click Log Analyzer to expand the Log Analyzer section. Then click on one of the following depending on the information you want to view.
- LIVE LOG VIEWER: To view logs that are currently being generated. For more information about how to use the gadgets in this page, see Viewing Live Logs.
- OVERVIEW: To view the overall statistics for each log category generated. For more information about how to use the gadgets in this page, see Analyzing the Log Overview.
- APPLICATION ERRORS: To view detailed information about different categories of errors that have occurred. For more information about how to use the gadgets in this page, see Analyzing Application Errors.
- API DEPLOYMENT STATS: To view overall statistics relating to all the APIs that are deployed in WSO2 API Manager. For more information about how to use the gadgets in this page, see Analyzing API Deployment Statistics.
- LOGIN ERRORS: To view overall statistics for login errors that have occurred for your WSO2 API Manager installation. For more information about how to use the gadgets in this page, see Analyzing Login Errors.
- NUMBER OF API FAILURES: To view statistics relating to instances where the APIs deployed in your WSO2 API Manager installation have failed. For more information about how to use the gadgets in this page, see Analyzing the Number of API Failures.
- ACCESS TOKEN ERRORS: To view detailed statistics relating to access token errors. For more information about how to use the gadgets in this page, see Analyzing Access Token Errors.
Configuring Log Analyzer for reverse proxy enabled admin portal
If you have enabled a reverse proxy for admin portal of API Manager, follow the below additional steps to configure Log Analyzer.
Configure API Manager to work with reverse proxy as described in Configuring the Proxy Server and the Load Balancer.
Documentation describe how to apply reverse proxy to store and publisher applications. You can follow the same for admin portal(not WSO2 carbon management console) also.
Add two entries in your Load Balancer level for portal and shindig apps. Example Nginx configuration is shown below.
Note that, at the moment you have to use a context with no prefixes/suffixes as mapping for these two apps. These entries are internal but needed for functionality of admin portal.
Location /portal { index index.html; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass https://localhost:9443/portal; proxy_redirect https://localhost:9443/portal https://myhost/portal; proxy_cookie_path /portal /portal; }
Navigate to API Manager node where you are accessing admin portal and open file <APIM_HOME>/repository/deployment/server/jaggeryapps/portal/store/carbon.super/fs/gadget/gadget-commons/js/gadget-utils.js file.
Comment out the following line.
{ name: "APIM", svrUrl: "https://"+location.hostname +":"+ location.port +"/admin/modules/la/log-analyzer-proxy.jag"}
Add a new line representing reverse proxy URL for admin portal which replaces location.hostname +":"+ location.port in above commented out line.
If your admin portal URL is https://myhost/apimanager/admin after applying reverse proxy new line would look like below.
{ name: "APIM", svrUrl: "https://myhost/apimanager/admin/modules/la/log-analyzer-proxy.jag"}
Final configuration will look like below.
//{ name: "APIM", svrUrl: "https://"+location.hostname +":"+ location.port +"/admin/modules/la/log-analyzer-proxy.jag"} { name: "APIM", svrUrl: "https://myhost/apimanager/admin/modules/la/log-analyzer-proxy.jag"}
In the same APIM instance, open up <APIM_HOME>/repository/deployment/server/webapps/shindig/WEB-INF/web.xml and navigate to following section.
<context-param> <param-name>system.properties</param-name> <param-value> <![CDATA[ shindig.host= shindig.port= aKey=/shindig/gadgets/proxy?container=default&url=]]> </param-value> </context-param>
Here you have to set values as per your load balancer configuartion as shindig.host and shindig.port. Enter Server hostname as host and server HTTPS port as port.
If you use the same load balancer configuration used in this documentation, resulting configuration will look like below.
<context-param> <param-name>system.properties</param-name> <param-value> <![CDATA[ shindig.host=myhost shindig.port=443 aKey=/shindig/gadgets/proxy?container=default&url= ]]> </param-value> </context-param>
Save the configurations and start up API Manager.