From: Michael Tremer Date: Sun, 28 Sep 2025 10:06:18 +0000 (+0000) Subject: module: Define some default RRAs X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=314bb67b8ae72f7a7c0df2a865b911763bcefc49;p=telemetry.git module: Define some default RRAs Signed-off-by: Michael Tremer --- diff --git a/src/daemon/module.c b/src/daemon/module.c index d3c950f..4c4aebc 100644 --- a/src/daemon/module.c +++ b/src/daemon/module.c @@ -40,6 +40,29 @@ // Interval after which the heartbeat function is being called again #define HEARTBEAT (STEPSIZE * 1000000) // usecs +// XXX We need to check whether it is a good idea to hardcode this here +#define XFF 0.1 + +// Define some default RRAs +static const collecty_rrd_rra default_rras[] = { + // Keep AVERAGE/MIN/MAX with a one minute resolution for two weeks + { "AVERAGE", "1m", "14d", }, + { "MIN", "1m", "14d", }, + { "MAX", "1m", "14d", }, + + // After that, keep a one hour resolution for the next 18 months + { "AVERAGE", "1h", "18M", }, + { "MIN", "1h", "18M", }, + { "MAX", "1h", "18M", }, + + // Finally, keep a one day resolution for ten years + { "AVERAGE", "1d", "10y", }, + { "MIN", "1d", "10y", }, + { "MAX", "1d", "10y", }, + + { NULL }, +}; + struct collecty_module { collecty_ctx* ctx; int nrefs; @@ -305,6 +328,20 @@ static int collecty_module_create_database(collecty_module* self, const char* pa goto ERROR; } + // Add all default round-robin archives + for (const collecty_rrd_rra* rra = default_rras; rra->type; rra++) { + r = collecty_args_push(args, "RRA:%s:%.2f:%s:%s", rra->type, XFF, rra->steps, rra->rows); + if (r < 0) + goto ERROR; + } + + // Add all custom round-robin archives + for (const collecty_rrd_rra* rra = self->methods->rrd_rras; rra->type; rra++) { + r = collecty_args_push(args, "RRA:%s:%.2f:%s:%s", rra->type, XFF, rra->steps, rra->rows); + if (r < 0) + goto ERROR; + } + // Dump all arguments r = collecty_args_dump(args); if (r < 0) diff --git a/src/daemon/module.h b/src/daemon/module.h index e6b5601..0678991 100644 --- a/src/daemon/module.h +++ b/src/daemon/module.h @@ -26,7 +26,8 @@ typedef struct collecty_module collecty_module; #include "ctx.h" #include "daemon.h" -#define MAX_FIELDS 64 +#define MAX_DS 64 +#define MAX_RRA 8 typedef struct collecty_rrd_ds { // Field @@ -40,11 +41,23 @@ typedef struct collecty_rrd_ds { int max; } collecty_rrd_ds; +typedef struct collecty_rrd_rra { + // Type + const char* type; + + // Steps + const char* steps; + + // Rows + const char* rows; +} collecty_rrd_rra; + typedef struct collecty_module_methods { const char* name; // RRD Schema - collecty_rrd_ds rrd_dss[MAX_FIELDS]; + collecty_rrd_ds rrd_dss[MAX_DS]; + collecty_rrd_rra rrd_rras[MAX_RRA]; // Init int (*init)(collecty_ctx* ctx);