From 58a07923d28a0f027fae41aec177df0875e4a738 Mon Sep 17 00:00:00 2001 From: Frank Hamand Date: Mon, 12 Aug 2024 09:35:18 +0100 Subject: [PATCH] return quota limited in response --- vector/replay-capture/tests.yaml | 2 ++ vector/replay-capture/vector.yaml | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/vector/replay-capture/tests.yaml b/vector/replay-capture/tests.yaml index 1c30b243c480c..d36ea0ea88019 100644 --- a/vector/replay-capture/tests.yaml +++ b/vector/replay-capture/tests.yaml @@ -44,6 +44,8 @@ tests: ."_" = "123456789" %token = "limited_token" + # we can't properly check things that we verify in the capture decoding vrl sadly :( + %quota_limited = true outputs: - conditions: - source: | diff --git a/vector/replay-capture/vector.yaml b/vector/replay-capture/vector.yaml index 23f8052e29f53..15f6378fb4ada 100644 --- a/vector/replay-capture/vector.yaml +++ b/vector/replay-capture/vector.yaml @@ -63,7 +63,15 @@ sources: assert!(is_string(.message[0].properties."$$session_id"), "$$session_id is required") assert!(is_string(%token), "token is required") + _, err = get_enrichment_table_record("quota_limited_teams", { "token": %token }) + # get_enrichment_table_record returns an err if record is not found + # that means err == null iff we found the quota limited record + %quota_limited = err == null + %response = {"status": 1} + if %quota_limited { + %response.quota_limited = ["recordings"] + } transforms: quota_check: @@ -74,8 +82,7 @@ transforms: quota_limited: type: vrl source: | - _, err = get_enrichment_table_record("quota_limited_teams", { "token": %token }) - err == null # err is not null if row not found, we want to drop where the row _is_ found + %quota_limited events_parsed: type: remap