You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+35Lines changed: 35 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -286,6 +286,8 @@ For details of each metric type, see [Prometheus documentation](http://prometheu
286
286
-`type`: metric type (required)
287
287
-`desc`: description of this metric (required)
288
288
-`key`: key name of record for instrumentation (**optional**)
289
+
-`retention`: time in seconds to remove a metric after not being updated (optional). See [Retention](#retention)
290
+
-`retention_check_interval`: time in seconds to check for expired metrics (optional). Has no effect when `retention` not set. See [Retention](#retention)
289
291
-`<labels>`: additional labels for this metric (optional). See [Labels](#labels)
290
292
291
293
If key is empty, the metric values is treated as 1, so the counter increments by 1 on each record regardless of contents of the record.
@@ -310,6 +312,8 @@ If key is empty, the metric values is treated as 1, so the counter increments by
310
312
-`type`: metric type (required)
311
313
-`desc`: description of metric (required)
312
314
-`key`: key name of record for instrumentation (required)
315
+
-`retention`: time in seconds to remove a metric after not being updated (optional). See [Retention](#retention)
316
+
-`retention_check_interval`: time in seconds to check for expired metrics (optional). Has no effect when `retention` not set. See [Retention](#retention)
313
317
-`<labels>`: additional labels for this metric (optional). See [Labels](#labels)
314
318
315
319
### summary type
@@ -332,6 +336,8 @@ If key is empty, the metric values is treated as 1, so the counter increments by
332
336
-`type`: metric type (required)
333
337
-`desc`: description of metric (required)
334
338
-`key`: key name of record for instrumentation (required)
339
+
-`retention`: time in seconds to remove a metric after not being updated (optional). See [Retention](#retention)
340
+
-`retention_check_interval`: time in seconds to check for expired metrics (optional). Has no effect when `retention` not set. See [Retention](#retention)
335
341
-`<labels>`: additional labels for this metric (optional). See [Labels](#labels)
336
342
337
343
### histogram type
@@ -356,6 +362,8 @@ If key is empty, the metric values is treated as 1, so the counter increments by
356
362
-`desc`: description of metric (required)
357
363
-`key`: key name of record for instrumentation (required)
358
364
-`buckets`: buckets of record for instrumentation (optional)
365
+
-`retention`: time in seconds to remove a metric after not being updated (optional). See [Retention](#retention)
366
+
-`retention_check_interval`: time in seconds to check for expired metrics (optional). Has no effect when `retention` not set. See [Retention](#retention)
359
367
-`<labels>`: additional labels for this metric (optional). See [Labels](#labels)
360
368
361
369
## Labels
@@ -430,6 +438,33 @@ Prometheus output/filter plugin can have multiple metric section. Top-level labe
430
438
431
439
In this case, `message_foo_counter` has `tag`, `hostname`, `key` and `data_type` labels.
432
440
441
+
## Retention
442
+
443
+
By default metrics with all encountered label combinations are preserved until the next restart of fluentd.
444
+
Even if a label combination did not receive any update for a long time.
445
+
That behavior is not always desired especially when having labels where the value is determined by the user like a `url` label.
446
+
For these metrics you can set `retention` and `retention_check_interval` like this:
447
+
448
+
```
449
+
<metric>
450
+
name message_foo_counter
451
+
type counter
452
+
desc The total number of foo in message.
453
+
key foo
454
+
retention 3600 # 1h
455
+
retention_check_interval 1800 # 30m
456
+
<labels>
457
+
bar ${bar}
458
+
</labels>
459
+
</metric>
460
+
```
461
+
462
+
If `${bar}` was `baz` one time but after that no records with that value were processed, then after one hour the metric
463
+
`foo{bar="baz"}` might be removed.
464
+
When this actually happens depends on `retention_check_interval` (default 60).
465
+
It causes a background thread to check every 30 minutes for expired metrics.
466
+
So worst case the metrics are removed 30 minutes after expiration.
467
+
You can set this value as low as `1`, but that may put more stress on your CPU.
0 commit comments