From 12bd51fd547b67aa46c899e147027b5644912109 Mon Sep 17 00:00:00 2001 From: Frank Hamand Date: Mon, 12 Aug 2024 10:06:32 +0100 Subject: [PATCH] feat: use patched vector to fix 400 responses and to add response body feature (#24302) --- .github/workflows/vector-docker-build-deploy.yml | 1 + vector/replay-capture/Dockerfile | 5 ++++- vector/replay-capture/tests.yaml | 2 ++ vector/replay-capture/vector.yaml | 14 ++++++++++++-- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/vector-docker-build-deploy.yml b/.github/workflows/vector-docker-build-deploy.yml index 44b86c24cd22a..940b87655a462 100644 --- a/.github/workflows/vector-docker-build-deploy.yml +++ b/.github/workflows/vector-docker-build-deploy.yml @@ -76,6 +76,7 @@ jobs: deploy: runs-on: ubuntu-latest needs: build + if: github.ref == 'refs/heads/master' steps: - name: get deployer token id: deployer diff --git a/vector/replay-capture/Dockerfile b/vector/replay-capture/Dockerfile index e32ab326aadd7..0715ef32a54ae 100644 --- a/vector/replay-capture/Dockerfile +++ b/vector/replay-capture/Dockerfile @@ -7,6 +7,9 @@ COPY vector.yaml . # evaluate with yq, basically to expand anchors (which vector doesn't support) RUN yq -i e 'explode(.)' vector.yaml -FROM timberio/vector:0.40.X-alpine +# fork of vector from this branch: https://github.com/frankh/vector/tree/main +# includes 2 fixed: 1 to make Kafka temporary errors return 500 not 400 +# and 1 to allow us to set response body on the http source +FROM frankh/vector:0.41.0-patched COPY --from=config-builder /config/vector.yaml /etc/vector/vector.yaml 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 8bcc51a10676f..feb30ef7fa3cc 100644 --- a/vector/replay-capture/vector.yaml +++ b/vector/replay-capture/vector.yaml @@ -32,6 +32,7 @@ sources: query_parameters: - _ host_key: ip + response_body_key: '%response' decoding: codec: vrl vrl: @@ -62,6 +63,16 @@ 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: type: route @@ -71,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 == true events_parsed: type: remap