chore: disable stats persistence by default (#6900)

* chore: disable stats persistence by default

Signed-off-by: WenyXu <wenymedia@gmail.com>

* chore: apply suggestions

Signed-off-by: WenyXu <wenymedia@gmail.com>

* chore: apply suggestions

Signed-off-by: WenyXu <wenymedia@gmail.com>

* fix: fix clippy

Signed-off-by: WenyXu <wenymedia@gmail.com>

---------

Signed-off-by: WenyXu <wenymedia@gmail.com>
This commit is contained in:
Weny Xu
2025-09-03 20:39:43 +08:00
parent 9c1240921d
commit 8bf772fb50
5 changed files with 16 additions and 16 deletions

View File

@@ -402,8 +402,8 @@
| `event_recorder` | -- | -- | Configuration options for the event recorder. |
| `event_recorder.ttl` | String | `90d` | TTL for the events table that will be used to store the events. Default is `90d`. |
| `stats_persistence` | -- | -- | Configuration options for the stats persistence. |
| `stats_persistence.ttl` | String | `30d` | TTL for the stats table that will be used to store the stats. Default is `30d`.<br/>Set to `0s` to disable stats persistence. |
| `stats_persistence.interval` | String | `60s` | The interval to persist the stats. Default is `60s`.<br/>The minimum value is `60s`, if the value is less than `60s`, it will be overridden to `60s`. |
| `stats_persistence.ttl` | String | `0s` | TTL for the stats table that will be used to store the stats.<br/>Set to `0s` to disable stats persistence.<br/>Default is `0s`.<br/>If you want to enable stats persistence, set the TTL to a value greater than 0.<br/>It is recommended to set a small value, e.g., `3h`. |
| `stats_persistence.interval` | String | `10m` | The interval to persist the stats. Default is `10m`.<br/>The minimum value is `10m`, if the value is less than `10m`, it will be overridden to `10m`. |
| `logging` | -- | -- | The logging options. |
| `logging.dir` | String | `./greptimedb_data/logs` | The directory to store the log files. If set to empty, logs will not be written to files. |
| `logging.level` | String | Unset | The log level. Can be `info`/`debug`/`warn`/`error`. |

View File

@@ -274,12 +274,15 @@ ttl = "90d"
## Configuration options for the stats persistence.
[stats_persistence]
## TTL for the stats table that will be used to store the stats. Default is `30d`.
## TTL for the stats table that will be used to store the stats.
## Set to `0s` to disable stats persistence.
ttl = "30d"
## The interval to persist the stats. Default is `60s`.
## The minimum value is `60s`, if the value is less than `60s`, it will be overridden to `60s`.
interval = "60s"
## Default is `0s`.
## If you want to enable stats persistence, set the TTL to a value greater than 0.
## It is recommended to set a small value, e.g., `3h`.
ttl = "0s"
## The interval to persist the stats. Default is `10m`.
## The minimum value is `10m`, if the value is less than `10m`, it will be overridden to `10m`.
interval = "10m"
## The logging options.
[logging]

View File

@@ -152,13 +152,9 @@ fn align_ts(ts: i64, interval: Duration) -> i64 {
impl PersistStatsHandler {
/// Creates a new [`PersistStatsHandler`].
pub fn new(inserter: Box<dyn Inserter>, mut persist_interval: Duration) -> Self {
if persist_interval < Duration::from_secs(60) {
warn!("persist_interval is less than 60 seconds, set to 60 seconds");
persist_interval = Duration::from_secs(60);
}
if persist_interval.as_millis() == 0 {
warn!("persist_interval as milliseconds is zero, set to 60 second");
persist_interval = Duration::from_secs(60);
if persist_interval < Duration::from_mins(10) {
warn!("persist_interval is less than 10 minutes, set to 10 minutes");
persist_interval = Duration::from_mins(10);
}
Self {

View File

@@ -16,6 +16,7 @@
#![feature(assert_matches)]
#![feature(hash_set_entry)]
#![feature(let_chains)]
#![feature(duration_constructors_lite)]
#![feature(duration_constructors)]
pub mod bootstrap;

View File

@@ -114,8 +114,8 @@ pub struct StatsPersistenceOptions {
impl Default for StatsPersistenceOptions {
fn default() -> Self {
Self {
ttl: Duration::from_days(30),
interval: Duration::from_secs(60),
ttl: Duration::ZERO,
interval: Duration::from_mins(10),
}
}
}