File: apache_metrics.mtail

package info (click to toggle)
mtail 3.2.24-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,384 kB
  • sloc: yacc: 647; makefile: 226; sh: 78; lisp: 77; awk: 17
file content (47 lines) | stat: -rw-r--r-- 2,496 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Copyright 2015 Ben Kochie <superq@gmail.com>. All Rights Reserved.
# This file is available under the Apache license.

# Parser for a metrics-friendly apache log format
# LogFormat "%v:%p %R %m %>s %H conn=%X %D %O %I %k" metrics
counter http_connections_aborted_total by server_port, handler, method, code, protocol, connection_status
counter http_connections_closed_total by server_port, handler, method, code, protocol, connection_status

counter http_request_size_bytes_total by server_port, handler, method, code, protocol
counter http_response_size_bytes_total by server_port, handler, method, code, protocol

histogram http_request_duration_seconds by server_port, handler, method, code, protocol buckets 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 15

/^/ +
/(?P<server_port>\S+) / + # %v:%p - The canonical ServerName of the server serving the request. : The canonical port of the server serving the request.
/(?P<handler>\S+) / + # %R - The handler generating the response (if any).
/(?P<method>[A-Z]+) / + # %m - The request method.
/(?P<code>\d{3}) / + # %>s - Status code.
/(?P<protocol>\S+) / + # %H - The request protocol.
/(?P<connection_status>conn=.) / + # %X - Connection status when response is completed
/(?P<time_us>\d+) / + # %D - The time taken to serve the request, in microseconds.
/(?P<sent_bytes>\d+) / + # %O - Bytes sent, including headers.
/(?P<received_bytes>\d+) / + # %I - Bytes received, including request and headers.
/(?P<keepalives>\d+)/ + # %k - Number of keepalive requests handled on this connection.
/$/ {
  ###
  # HTTP Requests with histogram buckets.
  #
  http_request_duration_seconds[$server_port][$handler][$method][$code][$protocol] = $time_us / 1000000.0

  ###
  # Sent/Received bytes.
  http_response_size_bytes_total[$server_port][$handler][$method][$code][$protocol] += $sent_bytes
  http_request_size_bytes_total[$server_port][$handler][$method][$code][$protocol] += $received_bytes

  ### Connection status when response is completed:
  # X = Connection aborted before the response completed.
  # + = Connection may be kept alive after the response is sent.
  # - = Connection will be closed after the response is sent.
  / conn=X / {
    http_connections_aborted_total[$server_port][$handler][$method][$code][$protocol][$connection_status]++
  }
  # Will not include all closed connections. :-(
  / conn=- / {
    http_connections_closed_total[$server_port][$handler][$method][$code][$protocol][$connection_status]++
  }
}