diff --git a/apier/v1/ees.go b/apier/v1/ees.go index 4e5428e0e..93bd49d33 100644 --- a/apier/v1/ees.go +++ b/apier/v1/ees.go @@ -37,3 +37,9 @@ func (eeSv1 *EeSv1) ProcessEvent(ctx *context.Context, args *engine.CGREventWith reply *map[string]map[string]any) error { return eeSv1.eeS.V1ProcessEvent(ctx, args, reply) } + +// V1ResetExporterMetrics resets the metrics for a specific exporter identified by ExporterID. +// Returns utils.ErrNotFound if the exporter is not found in the cache. +func (eeSv1 *EeSv1) ResetExporterMetrics(ctx *context.Context, params ees.V1ResetExporterMetricsParams, reply *string) error { + return eeSv1.eeS.V1ResetExporterMetrics(ctx, params, reply) +} diff --git a/ees/ees.go b/ees/ees.go index 9c21ac52f..278e899e4 100644 --- a/ees/ees.go +++ b/ees/ees.go @@ -410,3 +410,24 @@ func ExportWithAttempts(exp EventExporter, eEv any, key string) (err error) { } return } + +// V1ResetExporterMetricsParams contains required parameters for resetting exporter metrics. +type V1ResetExporterMetricsParams struct { + Tenant string + ID string // unique identifier of the request + ExporterID string + APIOpts map[string]any +} + +// V1ResetExporterMetrics resets the metrics for a specific exporter identified by ExporterID. +// Returns utils.ErrNotFound if the exporter is not found in the cache. +func (eeS *EventExporterS) V1ResetExporterMetrics(ctx *context.Context, params V1ResetExporterMetricsParams, reply *string) error { + eeCfg := eeS.cfg.EEsCfg().ExporterCfg(params.ExporterID) + ee, ok := eeS.exporterCache[eeCfg.Type].Get(eeCfg.ID) + if !ok { + return utils.ErrNotFound + } + ee.(EventExporter).GetMetrics().Reset() + *reply = utils.OK + return nil +} diff --git a/utils/consts.go b/utils/consts.go index bc4e63f85..f5d563346 100644 --- a/utils/consts.go +++ b/utils/consts.go @@ -1907,9 +1907,10 @@ const ( // EEs const ( - EeSv1 = "EeSv1" - EeSv1Ping = "EeSv1.Ping" - EeSv1ProcessEvent = "EeSv1.ProcessEvent" + EeSv1 = "EeSv1" + EeSv1Ping = "EeSv1.Ping" + EeSv1ProcessEvent = "EeSv1.ProcessEvent" + EeSv1ResetExporterMetrics = "EeSv1.ResetExporterMetrics" ) // ERs