Follow the steps for installing Applicare SingleAgent
Before configuring, verify the following details:
- Locate the default log configuration settings for the Apache server.
- Ensure that all Apache server requests are being logged into the existing configured log file.
Monitoring Apache Server with Applicare
Step 1: Enable the server-status and custom log modules in Apache by navigating to the Apache installed directory and editing the conf file. (Default locations are: /etc/httpd/conf (or) /etc/apache/conf).
Step 2: Verify that the following modules are enabled in the conf file. If they are not, enable them by removing '#’ at the beginning of the lines.
Some modules might not be included in the Apache conf file by default. If this is the case, manually add the following modules below the 'Listen' line in the Apache 'conf' file.
LoadModule status_module modules/mod_status.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule unique_id_module modules/mod_unique_id.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule headers_module modules/mod_headers.so
Module Details:
mod_status.so
This module provides server performance and status information.
mod_log_config.so
It is used for configuring and customizing logging behavior in apache. It allows to specify exactly what information should be logged, in what format, and where it should be logged.
mod_unique_id.so
This module is used to configure and customize logging behavior in Apache. It allows you to specify what information is logged, the format of the logs, and the log location.
mod_setenvif.so
This module is used to set environment variables based on characteristics of the client request.
mod_headers.so
This module is used to add custom headers.
Step 3: Ensure that LogLevel is set to warn. If it is set to a different value, comment out the existing LogLevel line.
.
Step 4: Create a new log folder inside the Apache home directory and sets its permission to 777 using the "chmod -R 777" command.
Step 5: Append the following five lines to the end of the log_config_module section in the conf file. Do not alter the existing CustomLog path within the log_config_module.
SetEnvIfNoCase Request_URI "^/server-status/pingFromApplicare" dontlog
SetEnvIfNoCase Request_URI "^/applicare_agent/*" dontlog
SetEnvIf _ap_trace_id ^[a-zA-Z0-9].* HAVE_AP_ID
RequestHeader set _ap_trace_id "%{UNIQUE_ID}e" env=!HAVE_AP_ID
RequestHeader set _ap_apache_id "<Apache_servername>"
CustomLog "|<rotatelogs_path> <ApacheInstalledDir>/newlogfolder/apl_log 60" "%t %h %s %B %D %U :%{_ap_trace_id}i" env=!dontlog
1. Replace <Apache_servername> with a custom name (without space) enclosed in double quotes, (remove the angle brackets too). The name can be anything <Apache_servername>. But it must be unique.
2. The "_ap_trace_id" is an environment variable appended to every request. and its value will a random ID.
3. Replace "<ApacheInstalledDir>" with the path to your Apache installation (removing the angle brackets too) and <rotatelogs_path> with the path to 'rotate logs'. On Linux, you can find the path using the following command.
which rotatelogs (or) sudo which rotatelogs
4. Replace <newlogfolder>with the name of the folder you created inside the Apache installation directory (remove the angle brackets too).
Step 6: Append the following lines to the end of the conf file.
<IfModule mod_status.c>
<Location /server-status>
ProxyPass !
SetHandler server-status
Order allow,deny
Allow from 127.0.0.1 ::1 localhost
</Location>
</IfModule>
Allow from 127.0.0.1 ::1 localhost - This setting restricts server status access to the local machine only.
Step 7: Check for any syntax errors in the configuration. If the output shows Syntax OK then the configuration is correct.
For httpd execute the following command
httpd -t
For apachectl execute the below command
apachectl -t
(or)
apachectl configtest
For apache2ctl execute the below command
apache2ctl -t
(or)
apache2ctl configtest
Step 8: If the configuration is success restart Apache server.
After restarting the Apache server, enter the following URL in your browser. This will display information about Apache server.
To check in your browser:
<Apache_Protocol>://<Apache_IP>:<Apache_Port>/server-status?auto
Example: http://127.0.0.1:80/server-status?auto
To check using curl:
curl <Apache_Protocol>://<Apache_IP>:<Apache_Port>/server-status?auto
Example: curl http://127.0.0.1:80/server-status?auto
<Apache_Protocol> - 'http' (or) "https"
<Apache_IP> - IP address of the Apache server
<Apache_Port> - Port number on which the Apache server is running
ServerMPM: event
Server Built: Jan 27 2021 07:22:47
CurrentTime: Monday, 28-Jun-2021 18:11:40 EDT
RestartTime: Monday, 28-Jun-2021 18:08:24 EDT
ParentServerConfigGeneration: 1
ParentServerMPMGeneration: 0
ServerUptimeSeconds: 195
ServerUptime: 3 minutes 15 seconds
Step 9: After starting the agent, it will be automatically registered with the Applicare controller. Log in to the Applicare console and navigate to the Overview menu.
Step 10: Select the newly added agent and click the Edit button.
Step 11: Check the "Add Apache Configuration" box and configure the setting as shown below. If the Apache is running over HTTPS, select HTTPS from the Apache Protocol dropdown. Click the update button to save the changes
2. If the new log configuration isn't taking effect, verify whether a custom configuration is being in the referenced in the default configuration. Custom configuration may be included using the "IncludeOptional" keyword.
3. To monitor only error logs, append the following syntax to the end of the CustomLog configuration.
"expr=%{REQUEST_STATUS} > 200"
e.g.
CustomLog "logs/access.log" combined "expr=%{REQUEST_STATUS} > 200"
Comments
0 comments
Article is closed for comments.