Skip to content

Commit 76af389

Browse files
sirainencmouse
authored andcommitted
Convert metric_group_by setting
1 parent 6c093be commit 76af389

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
@@ -8607,7 +8607,8 @@ setting.`
86078607
tags: [ 'metrics' ],
86088608
values: setting_types.STRING,
86098609
text: `
8610-
Name of the metric. It is visible in statistics outputs.`
8610+
Name of the metric. It is visible in statistics outputs. The [[setting,metric]]
8611+
filter name refers to this setting.`
86118612
},
86128613

86138614
metric_fields: {
@@ -8624,10 +8625,141 @@ field that does not need to be listed explicitly.`
86248625

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

86338765
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,34 +45,34 @@ 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
Example:
6268

6369
```[dovecot.conf]
6470
metric imap_command {
6571
filter = event=imap_command_finished
66-
group_by = cmd_name tagged_reply_state
72+
group_by cmd_name {
73+
}
74+
group_by tagged_reply_state {
75+
}
6776
}
6877
```
6978

@@ -89,21 +98,24 @@ when first observed.
8998

9099
The field's integer value is quantized into exponentially sized ranges.
91100

92-
The exponential aggregation function takes three colon delimited integer
93-
arguments that define the set of ranges used: the minimum magnitude, the
94-
maximum magnitude, and the base. The exact configuration syntax is:
95-
`field:exponential:min:max:base`
101+
The exponential aggregation method uses three settings:
96102

97-
Note: Currently, only base 2 and base 10 are supported.
103+
* [[setting,metric_group_by_method_exponential_min_magnitude]]
104+
* [[setting,metric_group_by_method_exponential_max_magnitude]]
105+
* [[setting,metric_group_by_method_exponential_base]]
106+
Note: Currently, only base 2 and base 10 are supported.
98107

99-
The first range starts at negative infinity and ends at `pow(base, min)`.
100-
The second range begins at `pow(base, min) + 1` and ends at
101-
`pow(base, min + 1)`, the next covers `pow(base, min + 1) + 1` to
102-
`pow(base, min + 2)`, and so on. The last range covers
103-
`pow(base, max) + 1` to positive infinity.
108+
The first range starts at negative infinity and ends at
109+
`pow(base, min_magnitude)`. The second range begins at
110+
`pow(base, min_magnitude) + 1` and ends at `pow(base, min_magnitude + 1)`,
111+
the next covers `pow(base, min_magnitude + 1) + 1` to
112+
`pow(base, min_magnitude + 2)`, and so on. The last range covers
113+
`pow(base, max_magnitude) + 1` to positive infinity.
104114

105-
For example, given the specification `duration:exponential:1:5:10`, the
106-
ranges would be:
115+
For example, given the settings
116+
[[setting,metric_group_by_method_exponential_min_magnitude,1]],
117+
[[setting,metric_group_by_method_exponential_max_magnitude,5]] and
118+
[[setting,metric_group_by_method_exponential_base,10]], the ranges would be:
107119

108120
* (-inf, 10]
109121
* [11, 100]
@@ -112,8 +124,8 @@ ranges would be:
112124
* [10001, 100000]
113125
* [100001, +inf)
114126

115-
Much like the metric names generated with the `discrete` aggregation
116-
function, the ones generated by the `exponential` function include
127+
Much like the metric names generated with the [discrete](#discrete) aggregation
128+
method, the ones generated by the `exponential` method include
117129
information about the value of the field. However, in this case it is the
118130
range the value belongs to.
119131

@@ -125,7 +137,15 @@ Example:
125137
```[dovecot.conf]
126138
metric imap_command {
127139
filter = event=imap_command_finished
128-
group_by = cmd_name duration:exponential:1:5:10
140+
group_by cmd_name {
141+
}
142+
group_by duration {
143+
method exponential {
144+
min_magnitude = 1
145+
max_magnitude = 5
146+
base = 10
147+
}
148+
}
129149
}
130150
```
131151

@@ -144,7 +164,7 @@ for a `SELECT` IMAP command, the possible generated metric names are:
144164
Note: Since the metric names cannot contain `-`, the string `ninf` is used
145165
to denote negative infinity.
146166

147-
Note: Much like in the `discrete` case, the metrics are allocated only
167+
Note: Much like in the [discrete](#discrete) case, the metrics are allocated only
148168
when first observed.
149169

150170
Finally, because all intermediate level metrics are generated as well. The
@@ -157,18 +177,20 @@ above example, will also generate all of the following metrics:
157177

158178
The field's integer value is quantized into linearly sized ranges.
159179

160-
The linear aggregation function takes three colon delimited integer
161-
arguments that define the set of ranges used: the minimum value, the
162-
maximum value, and the range step size. The exact configuration syntax is:
163-
`field:linear:min:max:step`
180+
The linear aggregation method uses three settings:
181+
182+
* [[setting,metric_group_by_method_linear_min]]
183+
* [[setting,metric_group_by_method_linear_max]]
184+
* [[setting,metric_group_by_method_linear_step]]
164185

165186
The first range starts at negative infinity and ends at `min`. The second
166187
range begins at `min + 1` and ends at `min + step`, the next covers
167188
`min + step + 1` to `min + (2 * step)`, and so on. The last range
168189
covers `max + 1` to positive infinity.
169190

170-
For example, given the specification `net_out_bytes:linear:0:5000:1000`, the
171-
ranges would be:
191+
For example, given settings [[setting,metric_group_by_method_linear_min,0]],
192+
[[setting,metric_group_by_method_linear_max,5000]] and
193+
[[setting,metric_group_by_method_linear_step,1000]], the ranges would be:
172194

173195
* (-inf, 0]
174196
* [1, 1000]
@@ -178,7 +200,7 @@ ranges would be:
178200
* [4001, 5000]
179201
* [5001, +inf)
180202

181-
See the description of the [exponential](#exponential) aggregation function
203+
See the description of the [exponential](#exponential) aggregation method
182204
for how metric names are formed from these ranges.
183205

184206
## Listing Statistics
@@ -285,7 +307,8 @@ metric storage_http_gets {
285307
# generate per-command metrics on successful commands
286308
metric imap_command {
287309
filter = event=imap_command_finished AND tagged_reply_state=OK
288-
group_by = cmd_name
310+
group_by cmd_name {
311+
}
289312
}
290313
```
291314

@@ -364,17 +387,34 @@ metric auth_success {
364387
365388
metric imap_command {
366389
filter = event=imap_command_finished
367-
group_by = cmd_name tagged_reply_state
390+
group_by cmd_name {
391+
}
392+
group_by tagged_reply_state {
393+
}
368394
}
369395
370396
metric smtp_command {
371397
filter = event=smtp_server_command_finished
372-
group_by = cmd_name status_code duration:exponential:1:5:10
398+
group_by cmd_name {
399+
}
400+
group_by status_code {
401+
}
402+
group_by duration {
403+
method exponential {
404+
min_magnitude = 1
405+
max_magnitude = 5
406+
}
407+
}
373408
}
374409
375410
metric mail_delivery {
376411
filter = event=mail_delivery_finished
377-
group_by = duration:exponential:1:5:10
412+
group_by duration {
413+
method exponential {
414+
min_magnitude = 1
415+
max_magnitude = 5
416+
}
417+
}
378418
}
379419
```
380420

0 commit comments

Comments
 (0)