From 098be060824452d85b961471132739604f921278 Mon Sep 17 00:00:00 2001 From: Kaushik Iska Date: Fri, 22 Dec 2023 09:22:07 -0500 Subject: [PATCH] fix --- flow/shared/alerting/alerting.go | 6 +++--- nexus/catalog/migrations/V17__alert_has_mirror_opt.sql | 5 ----- nexus/catalog/migrations/V17__mirror_errors.sql | 9 +++++++++ 3 files changed, 12 insertions(+), 8 deletions(-) delete mode 100644 nexus/catalog/migrations/V17__alert_has_mirror_opt.sql create mode 100644 nexus/catalog/migrations/V17__mirror_errors.sql diff --git a/flow/shared/alerting/alerting.go b/flow/shared/alerting/alerting.go index 274a420b69..50608087d2 100644 --- a/flow/shared/alerting/alerting.go +++ b/flow/shared/alerting/alerting.go @@ -116,10 +116,10 @@ func (a *Alerter) AddAlertToCatalog(ctx context.Context, alertKey string, alertM func (a *Alerter) LogFlowError(ctx context.Context, flowName string, err error) { errorWithStack := fmt.Sprintf("%+v", err) _, err = a.catalogPool.Exec(ctx, - "INSERT INTO peerdb_stats.alerts_v1(alert_key,alert_message, flow_name) VALUES($1,$2,$3)", - "flow_error", errorWithStack, flowName) + "INSERT INTO peerdb_stats.flow_errors(flow_name,error_message,error_type) VALUES($1,$2,$3)", + flowName, errorWithStack, "error") if err != nil { - a.logger.WarnContext(ctx, "failed to insert alert", slog.Any("error", err)) + a.logger.WarnContext(ctx, "failed to insert flow error", slog.Any("error", err)) return } } diff --git a/nexus/catalog/migrations/V17__alert_has_mirror_opt.sql b/nexus/catalog/migrations/V17__alert_has_mirror_opt.sql deleted file mode 100644 index 6beeb7a94c..0000000000 --- a/nexus/catalog/migrations/V17__alert_has_mirror_opt.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE peerdb_state.alerts_v1 -ADD COLUMN IF NOT EXISTS flow_name TEXT -ADD COLUMN IF NOT EXISTS ack BOOLEAN DEFAULT FALSE; - -CREATE INDEX alerts_v1_flow_name_idx ON peerdb_state.alerts_v1 (flow_name); diff --git a/nexus/catalog/migrations/V17__mirror_errors.sql b/nexus/catalog/migrations/V17__mirror_errors.sql new file mode 100644 index 0000000000..a136f1b6a7 --- /dev/null +++ b/nexus/catalog/migrations/V17__mirror_errors.sql @@ -0,0 +1,9 @@ +CREATE TABLE peerdb_stats.flow_errors ( + id BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY, + flow_name TEXT NOT NULL, + error_message TEXT NOT NULL, + error_type TEXT NOT NULL, + error_timestamp TIMESTAMP NOT NULL DEFAULT now() +); + +CREATE INDEX idx_flow_errors_flow_name ON peerdb_stats.flow_errors (flow_name);