Search K
Appearance
Appearance
See all events for list of all events that can be used in statistics.
Dovecot supports gathering statistics from events (see events design). Currently there are no statistics logged by default, and therefore they must be explicitly added using the metric
configuration blocks.
The event filter settings are the only required settings in a metric block. The filter specifies which events should be used when calculating the statistics for a given metric block. Event filtering is described in detail in Event Filtering.
In addition to the event filter, a list of fields that are included in the metrics can be specified using the fields
setting. All events have a default "duration" field that doesn't need to be listed explicitly.
All fields listed in fields
are exported to OpenMetrics as well.
Finally, the group_by
metric setting can be used to dynamically generate sub-metrics based on fields' values.
In general, the metric block has the form:
metric name {
...filter related settings...
# List of fields in event parameters that are included in the metrics.
fields = abc def
List of fields to group events by into auto-generated sub-metrics.
group_by = field another-field
}
Example:
metric imap_command {
filter = event=imap_command_finished
fields = net_in_bytes net_out_bytes
group_by = cmd_name tagged_reply_state
}
The group_by
metric setting allows dynamic hierarchical metric generation based on event fields' values.
Each field listed in the group_by
generates one level of "sub-metrics". These automatically generated metrics are indistinguishable from those statically defined in the config file. "sub-metric" names can be up to 256 bytes in total.
Dovecot supports a number of aggregation functions that can be used to quantize a field's value before it is used to generate a metric.
The format is always the same: the field name, a colon, the aggregation function name, and optionally a colon followed by colon delimited parameters to the aggregation function.
discrete
The simplest aggregation function is to use the value as is. Because this is a very common use case, not specifying an aggregation function is treated as an alias for discrete aggregation. In other words, field
and field:discrete
produce the same behavior.
Example:
metric imap_command {
filter = event=imap_command_finished
group_by = cmd_name tagged_reply_state
}
This example configuration will generate statistics for each IMAP command. The first "sub-metric" level is based on the IMAP command name, and the second (and in this example final) level is based on the tagged reply. For example, a SELECT
IMAP command that succeeded (in other words, it had an OK
reply) will generate the metric imap_command_SELECT_ok
.
In addition to the final level metric, all intermediate level metrics are generated as well. For example, the same SELECT
IMAP command will generate all of the following metrics:
imap_command
imap_command_SELECT
imap_command_SELECT_ok
Note: While the top level metrics (e.g., imap_command
above) are generated at start up, all group_by
metrics are generated dynamically when first observed.
exponential
The field's integer value is quantized into exponentially sized ranges.
The exponential aggregation function takes three colon delimited integer arguments that define the set of ranges used: the minimum magnitude, the maximum magnitude, and the base. The exact configuration syntax is: field:exponential:min:max:base
Note: Currently, only base 2 and base 10 are supported.
The first range starts at negative infinity and ends at pow(base, min)
. The second range begins at pow(base, min) + 1
and ends at pow(base, min + 1)
, the next covers pow(base, min + 1) + 1
to pow(base, min + 2)
, and so on. The last range covers pow(base, max) + 1
to positive infinity.
For example, given the specification duration:exponential:1:5:10
, the ranges would be:
Much like the metric names generated with the discrete
aggregation function, the ones generated by the exponential
function include information about the value of the field. However, in this case it is the range the value belongs to.
Specifically, it is the name of the field being quantized, and the lower and upper bounds for the range.
Example:
metric imap_command {
filter = event=imap_command_finished
group_by = cmd_name duration:exponential:1:5:10
}
This will generate metric names of the format imap_command_{cmd}_duration_{min}_{max}
where {cmd}
is the IMAP command name, and {min}
and {max}
are the range bounds. Therefore, for a SELECT
IMAP command, the possible generated metric names are:
imap_command_SELECT_ninf_10
imap_command_SELECT_11_100
imap_command_SELECT_101_1000
imap_command_SELECT_1001_10000
imap_command_SELECT_10001_100000
imap_command_SELECT_100001_inf
Note: Since the metric names cannot contain -
, the string ninf
is used to denote negative infinity.
Note: Much like in the discrete
case, the metrics are allocated only when first observed.
Finally, because all intermediate level metrics are generated as well. The above example, will also generate all of the following metrics:
imap_command
imap_command_SELECT
linear
The field's integer value is quantized into linearly sized ranges.
The linear aggregation function takes three colon delimited integer arguments that define the set of ranges used: the minimum value, the maximum value, and the range step size. The exact configuration syntax is: field:linear:min:max:step
The first range starts at negative infinity and ends at min
. The second range begins at min + 1
and ends at min + step
, the next covers min + step + 1
to min + (2 * step)
, and so on. The last range covers max + 1
to positive infinity.
For example, given the specification net_out_bytes:linear:0:5000:1000
, the ranges would be:
See the description of the exponential aggregation function for how metric names are formed from these ranges.
The gathered statistics are available by running:
$ doveadm stats dump
Each event has a duration
field, which tracks in microseconds how long the event existed. For example with imap_command_finished
field it could be:
metric_name field count sum min max avg median stddev %95
imap_commands duration 35 1190122 162 340477 34003 244 31215 188637
The above means:
Field | Description |
---|---|
count | There have been 35 IMAP commands |
sum | The IMAP commands were running in total for 1190122 microseconds (= 1.1 seconds) |
min | The fastest IMAP command took 162 microseconds |
max | The slowest IMAP command took 340477 microseconds |
avg | The average time spent on an IMAP commands was 34003 microseconds |
median | The median time spent on an IMAP command was 244 microseconds |
stddev | Standard deviation for the time spent on IMAP commands |
%95 | 95% of the IMAP commands took 188637 microseconds or less |
The other fields (than duration) track whatever that field represents. For example with imap_command_finished's net_in_bytes
field could be tracking how many bytes were being used by the IMAP commands. Non-numeric fields can also be tracked, although only the count
is relevant to those.
The list of fields can be specified with the -f
parameter. The default is:
$ doveadm stats dump -f 'count sum min max avg median stddev %95'
It's also possible to specify other percentiles than just 95%, for example:
$ doveadm stats dump -f 'count sum min max avg median stddev %95 %99 %99.9 %99.99'
The stats counters are reset whenever the stats process is started, which also means a dovecot reload will reset statistics. Using doveadm stats -r
parameter will also reset the statistics atomically after they're dumped.
Metrics can be added or removed dynamically. The changes do not persist after configuration reload.
Metrics can be added dynamically by running doveadm stats add
.
exporter
and exporter-include
parameters are described in Filtering Events.fields
and group-by
are described above.<filter>
syntax is described in Metric Filters.For example:
$ doveadm stats add --description "IMAP SELECT commands" \
--exporter log-exporter --exporter-include "name timestamps" \
--fields "net_in_bytes net_out_bytes" \
--group-by "cmd_name tagged_reply_state" imap_cmd_select \
"event=imap_command_finished AND cmd_name=SELECT"
Metrics can be removed dynamically by running doveadm stats remove
.
For example:
$ doveadm stats remove imap_cmd_select
metric imap_select_no {
filter = event=imap_command_finished AND cmd_name=SELECT AND \
tagged_reply_state=NO
}
metric imap_select_no_notfound {
filter = event=imap_command_finished AND cmd_name=SELECT AND \
tagged_reply="NO*Mailbox doesn't exist:*"
}
metric storage_http_gets {
filter = event=http_request_finished AND category=storage AND \
method=get
}
# generate per-command metrics on successful commands
metric imap_command {
filter = event=imap_command_finished AND tagged_reply_state=OK
group_by = cmd_name
}
metric push_notifications {
filter = event=push_notification_finished
}
# for OX driver
metric push_notification_http_finished {
filter = event=http_request_finished AND category=push_notification
}
Dovecot has support for OpenMetrics exposition format for statistics.
This can be enabled by adding following configuration:
service stats {
inet_listener http {
port = 9900
}
}
This will enable Dovecot to expose all configured metrics in OpenMetrics format on http://host:9900/metrics
using text-based format.
By default, Dovecot exposes all configured metrics.
If the metric name does not conform with OpenMetrics requirements, it is not exported.
All metric names are prefixed with dovecot_
and each non-histogram metric is exported as dovecot_<metric_name>_total
and dovecot_<metric_name>_duration_seconds_total
.
Dynamically generated statistics with group_by will be exported too.
The name of the base metric is used as above, and any dynamically generated sub-metrics are exported using labels.
Quantized sub-metrics are exported as histograms.
Histograms are exported as dovecot_<metric_name>_bucket
with corresponding labels. Each histogram will have an automatically generated _sum
(specifying sum of all values in quantiles) and _count
(total number of samples in the quantiles) metrics.
Dovecot will also export version information and startup time as special metrics even if nothing is configured. These are called dovecot_build_info
and process_start_time_seconds
.
An excerpt of an example Dovecot configuration that defines a set of metrics, and the sample exported data with such metrics configuration:
metric auth_success {
filter = (event=auth_request_finished AND success=yes)
}
metric imap_command {
filter = event=imap_command_finished
group_by = cmd_name tagged_reply_state
}
metric smtp_command {
filter = event=smtp_server_command_finished
group_by = cmd_name status_code duration:exponential:1:5:10
}
metric mail_delivery {
filter = event=mail_delivery_finished
group_by = duration:exponential:1:5:10
}
# HELP process_start_time_seconds Timestamp of service start
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1606393397
# HELP dovecot_build Dovecot build information
# TYPE dovecot_build info
dovecot_build_info{version="2.4.devel",revision="38ecc424a"} 1
# HELP dovecot_auth_success Total number of all events of this kind
# TYPE dovecot_auth_success counter
dovecot_auth_success_total 892
# HELP dovecot_auth_success_duration_seconds Total duration of all events of this kind
# TYPE dovecot_auth_success_duration_seconds counter
dovecot_auth_success_duration_seconds_total 0.085479
# HELP dovecot_imap_command Total number of all events of this kind
# TYPE dovecot_imap_command counter
dovecot_imap_command_total{cmd_name="LIST"} 423
dovecot_imap_command_total{cmd_name="LIST",tagged_reply_state="OK"} 423
dovecot_imap_command_total{cmd_name="STATUS"} 468
dovecot_imap_command_total{cmd_name="STATUS",tagged_reply_state="OK"} 468
dovecot_imap_command_total{cmd_name="SELECT"} 890
dovecot_imap_command_total{cmd_name="SELECT",tagged_reply_state="OK"} 890
dovecot_imap_command_total{cmd_name="APPEND"} 449
dovecot_imap_command_total{cmd_name="APPEND",tagged_reply_state="OK"} 449
dovecot_imap_command_total{cmd_name="LOGOUT"} 892
dovecot_imap_command_total{cmd_name="LOGOUT",tagged_reply_state="OK"} 892
dovecot_imap_command_total{cmd_name="UID FETCH"} 888
dovecot_imap_command_total{cmd_name="UID FETCH",tagged_reply_state="OK"} 888
dovecot_imap_command_total{cmd_name="FETCH"} 2148
dovecot_imap_command_total{cmd_name="FETCH",tagged_reply_state="OK"} 2148
dovecot_imap_command_total{cmd_name="STORE"} 794
dovecot_imap_command_total{cmd_name="STORE",tagged_reply_state="OK"} 794
dovecot_imap_command_total{cmd_name="EXPUNGE"} 888
dovecot_imap_command_total{cmd_name="EXPUNGE",tagged_reply_state="OK"} 888
dovecot_imap_command_count 7840
# HELP dovecot_imap_command_duration_seconds Total duration of all events of this kind
# TYPE dovecot_imap_command_duration_seconds counter
dovecot_imap_command_duration_seconds_total{cmd_name="LIST"} 0.099115
dovecot_imap_command_duration_seconds_total{cmd_name="LIST",tagged_reply_state="OK"} 0.099115
dovecot_imap_command_duration_seconds_total{cmd_name="STATUS"} 0.161195
dovecot_imap_command_duration_seconds_total{cmd_name="STATUS",tagged_reply_state="OK"} 0.161195
dovecot_imap_command_duration_seconds_total{cmd_name="SELECT"} 0.184907
dovecot_imap_command_duration_seconds_total{cmd_name="SELECT",tagged_reply_state="OK"} 0.184907
dovecot_imap_command_duration_seconds_total{cmd_name="APPEND"} 0.273893
dovecot_imap_command_duration_seconds_total{cmd_name="APPEND",tagged_reply_state="OK"} 0.273893
dovecot_imap_command_duration_seconds_total{cmd_name="LOGOUT"} 0.033494
dovecot_imap_command_duration_seconds_total{cmd_name="LOGOUT",tagged_reply_state="OK"} 0.033494
dovecot_imap_command_duration_seconds_total{cmd_name="UID FETCH"} 0.181319
dovecot_imap_command_duration_seconds_total{cmd_name="UID FETCH",tagged_reply_state="OK"} 0.181319
dovecot_imap_command_duration_seconds_total{cmd_name="FETCH"} 1.169456
dovecot_imap_command_duration_seconds_total{cmd_name="FETCH",tagged_reply_state="OK"} 1.169456
dovecot_imap_command_duration_seconds_total{cmd_name="STORE"} 0.368621
dovecot_imap_command_duration_seconds_total{cmd_name="STORE",tagged_reply_state="OK"} 0.368621
dovecot_imap_command_duration_seconds_total{cmd_name="EXPUNGE"} 0.247657
dovecot_imap_command_duration_seconds_total{cmd_name="EXPUNGE",tagged_reply_state="OK"} 0.247657
dovecot_imap_command_duration_seconds_sum 2.719657
# HELP dovecot_smtp_command Histogram
# TYPE dovecot_smtp_command histogram
dovecot_smtp_command_bucket{cmd_name="LHLO",status_code="250",le="10"} 0
dovecot_smtp_command_bucket{cmd_name="LHLO",status_code="250",le="100"} 1
dovecot_smtp_command_bucket{cmd_name="LHLO",status_code="250",le="1000"} 1
dovecot_smtp_command_bucket{cmd_name="LHLO",status_code="250",le="10000"} 1
dovecot_smtp_command_bucket{cmd_name="LHLO",status_code="250",le="100000"} 1
dovecot_smtp_command_bucket{cmd_name="LHLO",status_code="250",le="+Inf"} 1
dovecot_smtp_command_sum{cmd_name="LHLO",status_code="250"} 0.000020
dovecot_smtp_command_count{cmd_name="LHLO",status_code="250"} 1
dovecot_smtp_command_bucket{cmd_name="MAIL",status_code="250",le="10"} 0
dovecot_smtp_command_bucket{cmd_name="MAIL",status_code="250",le="100"} 1
dovecot_smtp_command_bucket{cmd_name="MAIL",status_code="250",le="1000"} 1
dovecot_smtp_command_bucket{cmd_name="MAIL",status_code="250",le="10000"} 1
dovecot_smtp_command_bucket{cmd_name="MAIL",status_code="250",le="100000"} 1
dovecot_smtp_command_bucket{cmd_name="MAIL",status_code="250",le="+Inf"} 1
dovecot_smtp_command_sum{cmd_name="MAIL",status_code="250"} 0.000021
dovecot_smtp_command_count{cmd_name="MAIL",status_code="250"} 1
dovecot_smtp_command_bucket{cmd_name="RCPT",status_code="250",le="10"} 0
dovecot_smtp_command_bucket{cmd_name="RCPT",status_code="250",le="100"} 0
dovecot_smtp_command_bucket{cmd_name="RCPT",status_code="250",le="1000"} 1
dovecot_smtp_command_bucket{cmd_name="RCPT",status_code="250",le="10000"} 1
dovecot_smtp_command_bucket{cmd_name="RCPT",status_code="250",le="100000"} 1
dovecot_smtp_command_bucket{cmd_name="RCPT",status_code="250",le="+Inf"} 1
dovecot_smtp_command_sum{cmd_name="RCPT",status_code="250"} 0.000195
dovecot_smtp_command_count{cmd_name="RCPT",status_code="250"} 1
dovecot_smtp_command_bucket{cmd_name="DATA",status_code="250",le="10"} 0
dovecot_smtp_command_bucket{cmd_name="DATA",status_code="250",le="100"} 0
dovecot_smtp_command_bucket{cmd_name="DATA",status_code="250",le="1000"} 0
dovecot_smtp_command_bucket{cmd_name="DATA",status_code="250",le="10000"} 1
dovecot_smtp_command_bucket{cmd_name="DATA",status_code="250",le="100000"} 1
dovecot_smtp_command_bucket{cmd_name="DATA",status_code="250",le="+Inf"} 1
dovecot_smtp_command_sum{cmd_name="DATA",status_code="250"} 0.001249
dovecot_smtp_command_count{cmd_name="DATA",status_code="250"} 1
dovecot_smtp_command_bucket{cmd_name="QUIT",status_code="221",le="10"} 1
dovecot_smtp_command_bucket{cmd_name="QUIT",status_code="221",le="100"} 1
dovecot_smtp_command_bucket{cmd_name="QUIT",status_code="221",le="1000"} 1
dovecot_smtp_command_bucket{cmd_name="QUIT",status_code="221",le="10000"} 1
dovecot_smtp_command_bucket{cmd_name="QUIT",status_code="221",le="100000"} 1
dovecot_smtp_command_bucket{cmd_name="QUIT",status_code="221",le="+Inf"} 1
dovecot_smtp_command_sum{cmd_name="QUIT",status_code="221"} 0.000010
dovecot_smtp_command_count{cmd_name="QUIT",status_code="221"} 1
# HELP dovecot_mail_delivery Histogram
# TYPE dovecot_mail_delivery histogram
dovecot_mail_delivery_bucket{le="10"} 0
dovecot_mail_delivery_bucket{le="100"} 0
dovecot_mail_delivery_bucket{le="1000"} 1
dovecot_mail_delivery_bucket{le="10000"} 1
dovecot_mail_delivery_bucket{le="100000"} 1
dovecot_mail_delivery_bucket{le="+Inf"} 1
dovecot_mail_delivery_sum 0.000656
dovecot_mail_delivery_count 1
# EOF