mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
This provides access logging metrics to Prometheus. For cardinality reasons, we cannot (nor would we want to) put every request path into its own label value -- but we do separate out the most-frequent access paths (as well as some low-frequency but high-interest ones) into their own label values. In order to differentiate accesses to https://zulip.com/ from https://example.zulipchat.com/ (both of which appear at path `/`), we use a `grok_exporter.realm_names_regex` value in `zulip.conf`, which is expected to be set to match the hostname of all possible realms.
69 lines
2.7 KiB
Plaintext
69 lines
2.7 KiB
Plaintext
global:
|
|
config_version: 3
|
|
input:
|
|
type: file
|
|
path: /var/log/nginx/access.log
|
|
fail_on_missing_logfile: false
|
|
readall: false
|
|
imports:
|
|
- type: grok_patterns
|
|
dir: <%= @include_dir %>
|
|
grok_patterns:
|
|
- 'NONQUERY [^? ]+'
|
|
- 'OPTIONALQUERY (?:\?%{NOTSPACE})?'
|
|
- 'APIPATH /+(api/v1|json)(?<apipath>/(events|users/me/presence|messages(/flags)?|remotes/push/(register|unregister|notify)|remotes/server/(register|analytics|analytics/status)|typing|register|server_settings))'
|
|
- 'EXTERNALPATH /+(?<external>api/v1/external/)[a-zA-Z0-9_-]+'
|
|
- 'ROOTPATH (?<rootpath>/+)'
|
|
- 'TOPPATH /+(?<toppath>(api/internal/(email_mirror_message|tusd)|compatibility|error_tracing))'
|
|
- 'PREFIXPATH /+(?<prefixpath>(static|user_uploads|avatar|api/v1/tus)/)\S+'
|
|
- 'ANYPATH (%{APIPATH}|%{EXTERNALPATH}|%{TOPPATH}|%{PREFIXPATH}|%{ROOTPATH}|%{NONQUERY:otherpath})%{OPTIONALQUERY}'
|
|
- 'OURHOSTNAME (?<hostname>((?<realm><%= @realm_names_regex %>)|%{NOTSPACE}))'
|
|
- 'OURLOG %{IPORHOST:clientip} - \S+ \[%{HTTPDATE:timestamp}\] "%{WORD:verb} %{ANYPATH} HTTP/%{NUMBER:httpversion}" %{NUMBER:response} (?:%{NUMBER:bytes}|-) %{QS:referrer} %{QS:agent} %{OURHOSTNAME} %{NUMBER:response_time}'
|
|
metrics:
|
|
- type: counter
|
|
name: nginx_http_response_codes_total
|
|
help: Total number of requests, by response code, normalized path, and HTTP method
|
|
match: '%{OURLOG}'
|
|
labels:
|
|
code: '{{.response}}'
|
|
method: '{{.verb}}'
|
|
path: '{{if .apipath}}/api/v1{{.apipath}}{{else if .external}}/api/v1/external/...{{else if .rootpath}}{{if .realm}}/{{else}}(other){{end}}{{else if .toppath}}/{{.toppath}}{{else if .prefixpath}}/{{.prefixpath}}...{{else}}(other){{end}}'
|
|
- type: counter
|
|
name: nginx_http_response_bytes
|
|
help: Total number of bytes, by normalized path
|
|
match: '%{OURLOG}'
|
|
value: '{{.bytes}}'
|
|
labels:
|
|
path: '{{if .apipath}}/api/v1{{.apipath}}{{else if .external}}/api/v1/external/...{{else if .rootpath}}{{if .realm}}/{{else}}(other){{end}}{{else if .toppath}}/{{.toppath}}{{else if .prefixpath}}/{{.prefixpath}}...{{else}}(other){{end}}'
|
|
- type: histogram
|
|
name: nginx_http_response_time_seconds
|
|
help: Response time in seconds, from first request byte to last response byte
|
|
match: '%{OURLOG}'
|
|
value: '{{.response_time}}'
|
|
buckets:
|
|
- 0.001
|
|
- 0.002
|
|
- 0.005
|
|
- 0.010
|
|
- 0.025
|
|
- 0.050
|
|
- 0.100
|
|
- 0.200
|
|
- 0.500
|
|
- 1.000
|
|
- 2.000
|
|
- 5.000
|
|
- 10.00
|
|
- 20.00
|
|
- 50.00
|
|
- 60.00
|
|
- 120.0
|
|
labels:
|
|
code: '{{.response}}'
|
|
method: '{{.verb}}'
|
|
path: '{{if .apipath}}/api/v1{{.apipath}}{{else if .external}}/api/v1/external/...{{else if .rootpath}}{{if .realm}}/{{else}}(other){{end}}{{else if .toppath}}/{{.toppath}}{{else if .prefixpath}}/{{.prefixpath}}...{{else}}(other){{end}}'
|
|
|
|
server:
|
|
protocol: http
|
|
port: 9144
|