Skip to content

Commit 4b25cff

Browse files
sirainencmouse
authored andcommitted
Convert metric_group_by setting
1 parent e12d5ee commit 4b25cff

File tree

2 files changed

+215
-43
lines changed

2 files changed

+215
-43
lines changed

data/settings.js

Lines changed: 135 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8619,7 +8619,8 @@ setting.`
86198619
tags: [ 'metrics' ],
86208620
values: setting_types.STRING,
86218621
text: `
8622-
Name of the metric. It is visible in statistics outputs.`
8622+
Name of the metric. It is visible in statistics outputs. The [[setting,metric]]
8623+
filter name refers to this setting.`
86238624
},
86248625

86258626
metric_fields: {
@@ -8636,10 +8637,141 @@ field that does not need to be listed explicitly.`
86368637

86378638
metric_group_by: {
86388639
tags: [ 'metrics' ],
8639-
values: setting_types.BOOLLIST,
8640+
values: setting_types.NAMED_LIST_FILTER,
8641+
seealso: [ '[[link,stats_group_by]]' ],
8642+
text: `
8643+
Creates a new [[link,stats_group_by,group_by]] for dynamically generating
8644+
sub-metrics based on the specified field's values. The filter name refers to
8645+
the [[setting,metric_group_by_field]].`
8646+
},
8647+
8648+
metric_group_by_field: {
8649+
tags: [ 'metrics' ],
8650+
values: setting_types.STRING,
8651+
seealso: [ '[[link,stats_group_by]]' ],
8652+
text: `
8653+
Generate sub-metrics based on this event field name. The
8654+
[[setting,metric_group_by]] filter name refers to this setting.`
8655+
},
8656+
8657+
metric_group_by_method: {
8658+
tags: [ 'metrics' ],
8659+
values: setting_types.NAMED_LIST_FILTER,
8660+
seealso: [ '[[link,stats_group_by]]' ],
8661+
text: `
8662+
Configures [[setting,metric_group_by_method_method,the aggregation method]] for
8663+
the [[setting,metric_group_by]]. Only a single method can be specified for
8664+
a group_by. The filter name refers to the
8665+
[[setting,metric_group_by_method_method]].`
8666+
},
8667+
8668+
metric_group_by_method_method: {
8669+
tags: [ 'metrics' ],
8670+
values: setting_types.ENUM,
8671+
values_enum: [ 'discrete', 'exponential', 'linear' ],
8672+
default: 'discrete',
8673+
seealso: [ '[[link,stats_group_by]]' ],
8674+
text: `
8675+
Configures the aggregation method for the
8676+
[[setting,metric_group_by]]. The [[setting,metric_group_by_method]] filter name
8677+
refers to this setting.`
8678+
},
8679+
8680+
metric_group_by_method_discrete_modifier: {
8681+
tags: [ 'metrics' ],
8682+
values: setting_types.STRING_NOVAR,
86408683
seealso: [ '[[link,stats_group_by]]' ],
86418684
text: `
8642-
This can be used to dynamically generate sub-metrics based on fields' values.`
8685+
Configures a modifier string for values grouped by the
8686+
[[link,stats_group_by_discrete,discrete method]].
8687+
[[link,settings_variables,%variables]] and their functions can be used:
8688+
8689+
\`%{value}\`
8690+
: The original value.
8691+
8692+
\`%{domain}\`
8693+
: If the value is in \`user@domain\` format, this contains the \`domain\`
8694+
text. Otherwise empty.`
8695+
},
8696+
8697+
metric_group_by_method_exponential_min_magnitude: {
8698+
tags: [ 'metrics' ],
8699+
values: setting_types.UINT,
8700+
seealso: [
8701+
'[[link,stats_group_by]]',
8702+
'metric_group_by_method_exponential_max_magnitude',
8703+
'metric_group_by_method_exponential_base'
8704+
],
8705+
text: `
8706+
Configures the minimum magnitude for values grouped by the
8707+
[[link,stats_group_by_exponential,exponential method]].`
8708+
},
8709+
8710+
metric_group_by_method_exponential_max_magnitude: {
8711+
tags: [ 'metrics' ],
8712+
values: setting_types.UINT,
8713+
seealso: [
8714+
'[[link,stats_group_by]]',
8715+
'metric_group_by_method_exponential_min_magnitude',
8716+
'metric_group_by_method_exponential_base'
8717+
],
8718+
text: `
8719+
Configures the maximum magnitude for values grouped by the
8720+
[[link,stats_group_by_exponential,exponential method]].`
8721+
},
8722+
8723+
metric_group_by_method_exponential_base: {
8724+
tags: [ 'metrics' ],
8725+
values: setting_types.UINT,
8726+
default: 10,
8727+
seealso: [
8728+
'[[link,stats_group_by]]',
8729+
'metric_group_by_method_exponential_min_magnitude',
8730+
'metric_group_by_method_exponential_max_magnitude'
8731+
],
8732+
text: `
8733+
Configures the base for values grouped by the
8734+
[[link,stats_group_by_exponential,exponential method]]. Only 2 and 10 are
8735+
supported.`
8736+
},
8737+
8738+
metric_group_by_method_linear_min: {
8739+
tags: [ 'metrics' ],
8740+
values: setting_types.UINT,
8741+
seealso: [
8742+
'[[link,stats_group_by]]',
8743+
'metric_group_by_method_linear_max',
8744+
'metric_group_by_method_linear_step'
8745+
],
8746+
text: `
8747+
Configures the minimum for values grouped by the
8748+
[[link,stats_group_by_linear,linear method]].`
8749+
},
8750+
8751+
metric_group_by_method_linear_max: {
8752+
tags: [ 'metrics' ],
8753+
values: setting_types.UINT,
8754+
seealso: [
8755+
'[[link,stats_group_by]]',
8756+
'metric_group_by_method_linear_min',
8757+
'metric_group_by_method_linear_step'
8758+
],
8759+
text: `
8760+
Configures the maximum for values grouped by the
8761+
[[link,stats_group_by_linear,linear method]].`
8762+
},
8763+
8764+
metric_group_by_method_linear_step: {
8765+
tags: [ 'metrics' ],
8766+
values: setting_types.UINT,
8767+
seealso: [
8768+
'[[link,stats_group_by]]',
8769+
'metric_group_by_method_linear_min',
8770+
'metric_group_by_method_linear_max'
8771+
],
8772+
text: `
8773+
Configures the step for values grouped by the
8774+
[[link,stats_group_by_linear,linear method]].`
86438775
},
86448776

86458777
metric_filter: {

docs/core/config/statistics.md

Lines changed: 80 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ dovecotlinks:
99
stats_group_by:
1010
hash: group-by
1111
text: "Statistics: Group By"
12+
stats_group_by_discrete:
13+
hash: discrete
14+
text: "Statistics: Group By: Discrete"
15+
stats_group_by_exponential:
16+
hash: exponential
17+
text: "Statistics: Group By: Exponential"
18+
stats_group_by_linear:
19+
hash: linear
20+
text: "Statistics: Group By: Linear"
1221
---
1322

1423
# Statistics
@@ -36,27 +45,24 @@ filter setting. You can also use `event=*` to match all named events.
3645

3746
## Group By
3847

39-
The `group_by` metric setting allows dynamic hierarchical metric
48+
The [[setting,metric_group_by]] setting allows dynamic hierarchical metric
4049
generation based on event fields' values.
4150

42-
Each field listed in the `group_by` generates one level of "sub-metrics".
51+
Each listed [[setting,metric_group_by]] generates one level of "sub-metrics".
4352
These automatically generated metrics are indistinguishable from those
4453
statically defined in the config file. "sub-metric" names can be up to
4554
256 bytes in total.
4655

47-
Dovecot supports a number of aggregation functions that can be used to
48-
quantize a field's value before it is used to generate a metric.
49-
50-
The format is always the same: the field name, a colon, the aggregation
51-
function name, and optionally a colon followed by colon delimited parameters
52-
to the aggregation function.
56+
Dovecot supports a number of aggregation methods that can be used to quantize
57+
a field's value before it is used to generate a metric.
5358

5459
### `discrete`
5560

56-
The simplest aggregation function is to use the value as is. Because this
57-
is a very common use case, not specifying an aggregation function is treated
58-
as an alias for discrete aggregation. In other words, `field` and
59-
`field:discrete` produce the same behavior.
61+
The simplest aggregation method is to use the value as is. Because this
62+
is a very common use case, this is the default aggregation method.
63+
64+
The value can be further modified by
65+
[[setting,metric_group_by_method_discrete_modifier]].
6066

6167
[[added,metric_group_by_discrete_modifiers_added]] An additional parameter
6268
can be added to provide modifiers to the discrete value. This is done as
@@ -71,7 +77,10 @@ Example:
7177
```[dovecot.conf]
7278
metric imap_command {
7379
filter = event=imap_command_finished
74-
group_by = cmd_name tagged_reply_state
80+
group_by cmd_name {
81+
}
82+
group_by tagged_reply_state {
83+
}
7584
}
7685
metric login_domains {
7786
filter = event=auth_request_finished
@@ -102,21 +111,24 @@ when first observed.
102111

103112
The field's integer value is quantized into exponentially sized ranges.
104113

105-
The exponential aggregation function takes three colon delimited integer
106-
arguments that define the set of ranges used: the minimum magnitude, the
107-
maximum magnitude, and the base. The exact configuration syntax is:
108-
`field:exponential:min:max:base`
114+
The exponential aggregation method uses three settings:
109115

110-
Note: Currently, only base 2 and base 10 are supported.
116+
* [[setting,metric_group_by_method_exponential_min_magnitude]]
117+
* [[setting,metric_group_by_method_exponential_max_magnitude]]
118+
* [[setting,metric_group_by_method_exponential_base]]
119+
Note: Currently, only base 2 and base 10 are supported.
111120

112-
The first range starts at negative infinity and ends at `pow(base, min)`.
113-
The second range begins at `pow(base, min) + 1` and ends at
114-
`pow(base, min + 1)`, the next covers `pow(base, min + 1) + 1` to
115-
`pow(base, min + 2)`, and so on. The last range covers
116-
`pow(base, max) + 1` to positive infinity.
121+
The first range starts at negative infinity and ends at
122+
`pow(base, min_magnitude)`. The second range begins at
123+
`pow(base, min_magnitude) + 1` and ends at `pow(base, min_magnitude + 1)`,
124+
the next covers `pow(base, min_magnitude + 1) + 1` to
125+
`pow(base, min_magnitude + 2)`, and so on. The last range covers
126+
`pow(base, max_magnitude) + 1` to positive infinity.
117127

118-
For example, given the specification `duration:exponential:1:5:10`, the
119-
ranges would be:
128+
For example, given the settings
129+
[[setting,metric_group_by_method_exponential_min_magnitude,1]],
130+
[[setting,metric_group_by_method_exponential_max_magnitude,5]] and
131+
[[setting,metric_group_by_method_exponential_base,10]], the ranges would be:
120132

121133
* (-inf, 10]
122134
* [11, 100]
@@ -125,8 +137,8 @@ ranges would be:
125137
* [10001, 100000]
126138
* [100001, +inf)
127139

128-
Much like the metric names generated with the `discrete` aggregation
129-
function, the ones generated by the `exponential` function include
140+
Much like the metric names generated with the [discrete](#discrete) aggregation
141+
method, the ones generated by the `exponential` method include
130142
information about the value of the field. However, in this case it is the
131143
range the value belongs to.
132144

@@ -138,7 +150,15 @@ Example:
138150
```[dovecot.conf]
139151
metric imap_command {
140152
filter = event=imap_command_finished
141-
group_by = cmd_name duration:exponential:1:5:10
153+
group_by cmd_name {
154+
}
155+
group_by duration {
156+
method exponential {
157+
min_magnitude = 1
158+
max_magnitude = 5
159+
base = 10
160+
}
161+
}
142162
}
143163
```
144164

@@ -157,7 +177,7 @@ for a `SELECT` IMAP command, the possible generated metric names are:
157177
Note: Since the metric names cannot contain `-`, the string `ninf` is used
158178
to denote negative infinity.
159179

160-
Note: Much like in the `discrete` case, the metrics are allocated only
180+
Note: Much like in the [discrete](#discrete) case, the metrics are allocated only
161181
when first observed.
162182

163183
Finally, because all intermediate level metrics are generated as well. The
@@ -170,18 +190,20 @@ above example, will also generate all of the following metrics:
170190

171191
The field's integer value is quantized into linearly sized ranges.
172192

173-
The linear aggregation function takes three colon delimited integer
174-
arguments that define the set of ranges used: the minimum value, the
175-
maximum value, and the range step size. The exact configuration syntax is:
176-
`field:linear:min:max:step`
193+
The linear aggregation method uses three settings:
194+
195+
* [[setting,metric_group_by_method_linear_min]]
196+
* [[setting,metric_group_by_method_linear_max]]
197+
* [[setting,metric_group_by_method_linear_step]]
177198

178199
The first range starts at negative infinity and ends at `min`. The second
179200
range begins at `min + 1` and ends at `min + step`, the next covers
180201
`min + step + 1` to `min + (2 * step)`, and so on. The last range
181202
covers `max + 1` to positive infinity.
182203

183-
For example, given the specification `net_out_bytes:linear:0:5000:1000`, the
184-
ranges would be:
204+
For example, given settings [[setting,metric_group_by_method_linear_min,0]],
205+
[[setting,metric_group_by_method_linear_max,5000]] and
206+
[[setting,metric_group_by_method_linear_step,1000]], the ranges would be:
185207

186208
* (-inf, 0]
187209
* [1, 1000]
@@ -191,7 +213,7 @@ ranges would be:
191213
* [4001, 5000]
192214
* [5001, +inf)
193215

194-
See the description of the [exponential](#exponential) aggregation function
216+
See the description of the [exponential](#exponential) aggregation method
195217
for how metric names are formed from these ranges.
196218

197219
## Listing Statistics
@@ -298,7 +320,8 @@ metric storage_http_gets {
298320
# generate per-command metrics on successful commands
299321
metric imap_command {
300322
filter = event=imap_command_finished AND tagged_reply_state=OK
301-
group_by = cmd_name
323+
group_by cmd_name {
324+
}
302325
}
303326
```
304327

@@ -377,17 +400,34 @@ metric auth_success {
377400
378401
metric imap_command {
379402
filter = event=imap_command_finished
380-
group_by = cmd_name tagged_reply_state
403+
group_by cmd_name {
404+
}
405+
group_by tagged_reply_state {
406+
}
381407
}
382408
383409
metric smtp_command {
384410
filter = event=smtp_server_command_finished
385-
group_by = cmd_name status_code duration:exponential:1:5:10
411+
group_by cmd_name {
412+
}
413+
group_by status_code {
414+
}
415+
group_by duration {
416+
method exponential {
417+
min_magnitude = 1
418+
max_magnitude = 5
419+
}
420+
}
386421
}
387422
388423
metric mail_delivery {
389424
filter = event=mail_delivery_finished
390-
group_by = duration:exponential:1:5:10
425+
group_by duration {
426+
method exponential {
427+
min_magnitude = 1
428+
max_magnitude = 5
429+
}
430+
}
391431
}
392432
```
393433

0 commit comments

Comments
 (0)