|
82 | 82 | [{atom(), pos_integer(), pos_integer() | skip}]} | |
83 | 83 | {pruning_interval, pos_integer()} | |
84 | 84 | {truncate_max_age, pos_integer()} | |
85 | | - {min_truncation_interval, pos_integer()} | |
86 | 85 | {decimation_match_patterns, [string()]} | |
87 | 86 | {truncation_match_patterns, [string()]} | |
88 | 87 | {token_file, string()} | |
@@ -157,7 +156,6 @@ default_settings() -> |
157 | 156 | {decimation_defs, decimation_definitions_default()}, |
158 | 157 | {pruning_interval, 60000}, %% frequency to try to prune stats (msecs) |
159 | 158 | {truncate_max_age, 3*?SECS_IN_DAY}, %% age (secs) to truncate stats |
160 | | - {min_truncation_interval, 0}, %% Secs past max age to keep stats |
161 | 159 | {decimation_match_patterns, ["{job=\"general\"}"]}, |
162 | 160 | {truncation_match_patterns, ["{job=~\".*_high_cardinality\"}"]}, |
163 | 161 | {token_file, "prometheus_token"}, |
@@ -1278,7 +1276,7 @@ run_prune_stats(Levels, LastPruningTime, Settings) -> |
1278 | 1276 | end, |
1279 | 1277 | StatsTruncated = case proplists:get_bool(truncation_enabled, Settings) of |
1280 | 1278 | true -> |
1281 | | - run_truncate_stats(LastPruningTime, Settings); |
| 1279 | + run_truncate_stats(Settings); |
1282 | 1280 | false -> |
1283 | 1281 | false |
1284 | 1282 | end, |
@@ -1367,36 +1365,25 @@ build_decimation_summary(SortedDeletions) -> |
1367 | 1365 | end, {First, 1, []}, Rest), |
1368 | 1366 | Summary. |
1369 | 1367 |
|
1370 | | -run_truncate_stats(LastPruningTime, Settings) -> |
| 1368 | +run_truncate_stats(Settings) -> |
1371 | 1369 | Now = os:system_time(seconds), |
1372 | 1370 | MaxAge = proplists:get_value(truncate_max_age, Settings), |
1373 | | - %% Amount of time to not truncate stats even if they're older than the |
1374 | | - %% maximum age. |
1375 | | - MinTruncationInterval = proplists:get_value(min_truncation_interval, |
1376 | | - Settings), |
1377 | 1371 | End = Now - MaxAge, |
1378 | 1372 | %% Each call truncates the little bit that has exceeded the age limit |
1379 | 1373 | %% since the last call. We might want to do this less frequently e.g. |
1380 | 1374 | %% when a certain time frame is exceeded. |
1381 | | - case End - LastPruningTime > MinTruncationInterval of |
1382 | | - true -> |
1383 | | - do_truncate_stats(LastPruningTime, End, Settings), |
1384 | | - true; |
1385 | | - false -> |
1386 | | - false |
1387 | | - end. |
| 1375 | + do_truncate_stats(End, Settings), |
| 1376 | + true. |
1388 | 1377 |
|
1389 | | -do_truncate_stats(StartTime, EndTime, Settings) -> |
| 1378 | +do_truncate_stats(EndTime, Settings) -> |
1390 | 1379 | %% Only high-cardinality stats are truncated |
1391 | 1380 | MatchPatterns = proplists:get_value(truncation_match_patterns, Settings), |
1392 | 1381 |
|
1393 | | - ?log_debug("Truncating stats from ~p (~p) to ~p (~p)", |
1394 | | - [calendar:system_time_to_rfc3339(StartTime, [{offset, 0}]), |
1395 | | - StartTime, |
1396 | | - calendar:system_time_to_rfc3339(EndTime, [{offset, 0}]), |
| 1382 | + ?log_debug("Truncating stats older than ~p (~p)", |
| 1383 | + [calendar:system_time_to_rfc3339(EndTime, [{offset, 0}]), |
1397 | 1384 | EndTime]), |
1398 | 1385 |
|
1399 | | - delete_series(MatchPatterns, StartTime, EndTime, 30000, Settings). |
| 1386 | + delete_series(MatchPatterns, min_possible_time, EndTime, 30000, Settings). |
1400 | 1387 |
|
1401 | 1388 | delete_series(MatchPatterns, Start, End, Timeout, Settings) -> |
1402 | 1389 |
|
|
0 commit comments