From cd1be809c8fd556a2db1080c20ade3edf888bc1f Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Thu, 6 Jul 2023 10:49:48 +0300 Subject: [PATCH] stats: Do not break submetrics is field is missing If the field does not exist, emulate it as empty field, and continue submetrics. --- src/stats/stats-metrics.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/stats/stats-metrics.c b/src/stats/stats-metrics.c index 301a0e5fc4..96dca8be2b 100644 --- a/src/stats/stats-metrics.c +++ b/src/stats/stats-metrics.c @@ -642,10 +642,17 @@ stats_metric_group_by(struct metric *metric, struct event *event, pool_t pool) event_find_field_recursive(event, metric->group_by[0].field); /* ignore missing field */ - if (field == NULL) - return; - - if (field->value_type != EVENT_FIELD_VALUE_TYPE_STRLIST) + if (field == NULL) { + const struct event_field empty_event_field = { + .value_type = EVENT_FIELD_VALUE_TYPE_STR, + .key = metric->group_by[0].field, + .value = { + .str = "", + }, + }; + stats_metric_group_by_field(metric, event, &empty_event_field, + pool); + } else if (field->value_type != EVENT_FIELD_VALUE_TYPE_STRLIST) stats_metric_group_by_field(metric, event, field, pool); else { /* Handle each string in strlist separately. The strlist needs -- 2.47.3