Apache
Apache collector can collect the number of requests, connections and others from Apache services, and collect indicators to Guance to help monitor and analyze various abnormal situations of Apache.
Configuration¶
Preconditions¶
-
Apache version >=
2.4.6 (Unix)
. Already tested version:- 2.4.56
- 2.4.54
- 2.4.41
- 2.4.38
- 2.4.29
- 2.4.6
-
Default configuration path:
- /etc/apache2/apache2.conf
- /etc/apache2/httpd.conf
- /usr/local/apache2/conf/httpd.conf
-
Open Apache
mod_status
and add the followings in Apache profile:
<Location /server-status>
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from [YOUR_IP]
</Location>
- Restart Apache
Collector Configuration¶
Go to the conf.d/apache
directory under the DataKit installation directory, copy apache.conf.sample
and name it apache.conf
. Examples are as follows:
[[inputs.apache]]
url = "http://127.0.0.1/server-status?auto"
# ##(optional) collection interval, default is 30s
# interval = "30s"
# username = ""
# password = ""
## Optional TLS Config
# tls_ca = "/xxx/ca.pem"
# tls_cert = "/xxx/cert.cer"
# tls_key = "/xxx/key.key"
## Use TLS but skip chain & host verification
insecure_skip_verify = false
## Set true to enable election
election = true
# [inputs.apache.log]
# files = []
# #grok pipeline script path
# pipeline = "apache.p"
[inputs.apache.tags]
# some_tag = "some_value"
# more_tag = "some_other_value"
# ...
After configuration, restart DataKit.
The collector can now be turned on by configMap injection collector configuration.
Metric¶
For all of the following data collections, the global election tags will added automatically, we can add extra tags in [inputs.apache.tags]
if needed:
apache
¶
The collected metrics are affected by the environment in which Apache is installed. The metrics shown on the http://<your-apache-server>/server-status?auto
page will prevail.
- Tags
Tag | Description |
---|---|
host | Hostname. |
server_mpm | Apache server Multi-Processing Module, prefork , worker and event . Optional. |
server_version | Apache server version. Optional. |
url | Apache server status url. |
- Metrics
Metric | Description |
---|---|
busy_workers | The number of workers serving requests. Type: int Unit: count |
closing_connection | The amount of workers that are currently closing a connection Type: int Unit: count |
conns_async_closing | The number of asynchronous closing connections,windows not support Type: int Unit: count |
conns_async_keep_alive | The number of asynchronous keep alive connections,windows not support Type: int Unit: count |
conns_async_writing | The number of asynchronous writes connections,windows not support Type: int Unit: count |
conns_total | The total number of requests performed,windows not support Type: int Unit: count |
cpu_load | The percent of CPU used,windows not support. Optional. Type: float Unit: percent,percent |
disabled | These slots will never be able to handle any requests, indicates a misconfiguration. Type: int Unit: count |
dns_lookup | The workers waiting on a DNS lookup Type: int Unit: count |
gracefully_finishing | The number of workers finishing their request Type: int Unit: count |
idle_cleanup | These workers were idle and their process is being stopped Type: int Unit: count |
idle_workers | The number of idle workers Type: int Unit: count |
keepalive | The workers intended for a new request from the same client, because it asked to keep the connection alive Type: int Unit: count |
logging | The workers writing something to the Apache logs Type: int Unit: count |
max_workers | The maximum number of workers apache can start. Type: int Unit: count |
net_bytes | The total number of bytes served. Type: int Unit: digital,B |
net_hits | The total number of requests performed Type: int Unit: count |
open_slot | The amount of workers that Apache can still start before hitting the maximum number of workers Type: int Unit: count |
reading_request | The workers reading the incoming request Type: int Unit: count |
sending_reply | The number of workers sending a reply/response or waiting on a script (like PHP) to finish so they can send a reply Type: int Unit: count |
starting_up | The workers that are still starting up and not yet able to handle a request Type: int Unit: count |
uptime | The amount of time the server has been running Type: int Unit: time,s |
waiting_for_connection | The number of workers that can immediately process an incoming request Type: int Unit: count |
collector
¶
- Tags
Tag | Description |
---|---|
instance | Server addr of the instance |
job | Server name of the instance |
- Metrics
Metric | Description |
---|---|
up | Type: int Unit: - |
Custom Object¶
web_server
¶
- Tags
Tag | Description |
---|---|
col_co_status | Current status of collector on instance(OK/NotOK ) |
host | The server host address |
ip | Connection IP of the instance |
name | Object uniq ID |
reason | If status not ok, we'll get some reasons about the status |
- Metrics
Metric | Description |
---|---|
display_name | Displayed name in UI Type: string Unit: N/A |
uptime | Current instance uptime Type: int Unit: time,s |
version | Current version of the instance Type: string Unit: N/A |
Log Collection¶
To collect the Apache log, open files
in apache.conf and write to the absolute path of the Apache log file. For example:
[[inputs.apache]]
...
[inputs.apache.log]
files = [
"/var/log/apache2/error.log",
"/var/log/apache2/access.log"
]
When log collection is turned on, logs with apache
log (source
) will be generated by default.
Info
DataKit must be installed on the host where Apache is located to collect Apache logs.
Log Pipeline Function Cut Field Description¶
- Apache Error Log Cutting
Error Log Text Example
[Tue May 19 18:39:45.272121 2021] [access_compat:error] [pid 9802] [client ::1:50547] AH01797: client denied by server configuration: /Library/WebServer/Documents/server-status
The list of cut fields is as follows:
Field Name | Field Value | Description |
---|---|---|
status |
error |
log level |
pid |
9802 |
process id |
type |
access_compat |
log type |
time |
1621391985000000000 |
nanosecond timestamp (as row protocol time) |
- Apache Access Log Cutting
Example of access log text:
The list of cut fields is as follows:
Field Name | Field Value | Description |
---|---|---|
status |
info |
log level |
ip_or_host |
127.0.0.1 |
requester ip or host |
http_code |
200 |
http status code |
http_method |
GET |
http request type |
http_url |
/ |
http request url |
http_version |
1.1 |
http version |
time |
1621205469000000000 |
nanosecond timestamp (as row protocol time) |