0
    input:
      generate:
        mapping: root = {"id":48554}
    
    pipeline:
      processors:
        - http:
            url: https://example.com/**use_id_here_from_root**
            verb: GET
            retries: 5
            timeout: 10s
            retry_period: 2s

I tried using {{.id}}, eq.${! json("id") } but both of these dont seem to be working.

1 Answers1

0

The http processor url field supports interpolation functions. You should be on the right track with ${! json("id") }, but there might be something wrong with how your test setup.

This config worked for me:

input:
  generate:
    count: 1
    interval: 0s
    mapping: root = {"id":48554}

pipeline:
  processors:
    - http:
        url: http://127.0.0.1:6666/${! json("id") }
        verb: GET
        retries: 5
        timeout: 10s
        retry_period: 2s

output:
  stdout: {}

To test it, I ran nc in a loop:

> while true; do echo -e "HTTP/1.1 200 OK\r\n" | nc -l 127.0.0.1 6666; done

then I ran benthos:

> benthos -c test.yaml

and I got the following output from nc:

GET /48554 HTTP/1.1
Host: 127.0.0.1:6666
User-Agent: Go-http-client/1.1
Content-Length: 12
Content-Type: application/octet-stream
Accept-Encoding: gzip

{"id":48554}
Mihai Todor
  • 8,014
  • 9
  • 49
  • 86