Skip to content

Commit

Permalink
feat: use patched vector to fix 400 responses and to add response bod…
Browse files Browse the repository at this point in the history
…y feature (#24302)
  • Loading branch information
frankh authored Aug 12, 2024
1 parent 531eb54 commit 12bd51f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/vector-docker-build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion vector/replay-capture/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions vector/replay-capture/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
14 changes: 12 additions & 2 deletions vector/replay-capture/vector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ sources:
query_parameters:
- _
host_key: ip
response_body_key: '%response'
decoding:
codec: vrl
vrl:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 12bd51f

Please sign in to comment.