Skip to main content

http_client

Connects to a server and continuously performs requests for a single message.

# Common config fields, showing default values
input:
label: ""
http_client:
url: "" # No default (required)
verb: GET
headers: {}
rate_limit: "" # No default (optional)
timeout: 5s
payload: "" # No default (optional)
stream:
enabled: false
reconnect: true
scanner:
lines: {}
auto_replay_nacks: true

The URL and header values of this type can be dynamically set using function interpolations described here.

Streaming​

If you enable streaming then Bento will consume the body of the response as a continuous stream of data, breaking messages out following a chosen scanner. This allows you to consume APIs that provide long lived streamed data feeds (such as Twitter).

Pagination​

This input supports interpolation functions in the url and headers fields where data from the previous successfully consumed message (if there was one) can be referenced. This can be used in order to support basic levels of pagination. However, in cases where pagination depends on logic it is recommended that you use an http processor instead, often combined with a generate input in order to schedule the processor.

Examples​

Interpolation functions within the url and headers fields can be used to reference the previously consumed message, which allows simple pagination.

input:
http_client:
url: >-
https://api.example.com/search?query=allmyfoos&start_time=${! (
(timestamp_unix()-300).ts_format("2006-01-02T15:04:05Z","UTC").escape_url_query()
) }${! ("&next_token="+this.meta.next_token.not_null()) | "" }
verb: GET
rate_limit: foo_searches
oauth2:
enabled: true
token_url: https://api.example.com/oauth2/token
client_key: "${EXAMPLE_KEY}"
client_secret: "${EXAMPLE_SECRET}"

rate_limit_resources:
- label: foo_searches
local:
count: 1
interval: 30s

Fields​

url​

The URL to connect to. This field supports interpolation functions.

Type: string

verb​

A verb to connect with

Type: string
Default: "GET"

# Examples

verb: POST

verb: GET

verb: DELETE

headers​

A map of headers to add to the request. This field supports interpolation functions.

Type: object
Default: {}

# Examples

headers:
Content-Type: application/octet-stream
traceparent: ${! tracing_span().traceparent }

metadata​

Specify optional matching rules to determine which metadata keys should be added to the HTTP request as headers.

Type: object

metadata.include_prefixes​

Provide a list of explicit metadata key prefixes to match against.

Type: array
Default: []

# Examples

include_prefixes:
- foo_
- bar_

include_prefixes:
- kafka_

include_prefixes:
- content-

metadata.include_patterns​

Provide a list of explicit metadata key regular expression (re2) patterns to match against.

Type: array
Default: []

# Examples

include_patterns:
- .*

include_patterns:
- _timestamp_unix$

dump_request_log_level​

EXPERIMENTAL: Optionally set a level at which the request and response payload of each request made will be logged.

Type: string
Default: ""
Options: TRACE, DEBUG, INFO, WARN, ERROR, FATAL, ``.

oauth​

Allows you to specify open authentication via OAuth version 1.

Type: object

oauth.enabled​

Whether to use OAuth version 1 in requests.

Type: bool
Default: false

oauth.consumer_key​

A value used to identify the client to the service provider.

Type: string
Default: ""

oauth.consumer_secret​

A secret used to establish ownership of the consumer key.

Secret

This field contains sensitive information that usually shouldn't be added to a config directly, read our secrets page for more info.

Type: string
Default: ""

oauth.access_token​

A value used to gain access to the protected resources on behalf of the user.

Type: string
Default: ""

oauth.access_token_secret​

A secret provided in order to establish ownership of a given access token.

Secret

This field contains sensitive information that usually shouldn't be added to a config directly, read our secrets page for more info.

Type: string
Default: ""

oauth2​

Allows you to specify open authentication via OAuth version 2 using the client credentials token flow.

Type: object

oauth2.enabled​

Whether to use OAuth version 2 in requests.

Type: bool
Default: false

oauth2.client_key​

A value used to identify the client to the token provider.

Type: string
Default: ""

oauth2.client_secret​

A secret used to establish ownership of the client key.

Secret

This field contains sensitive information that usually shouldn't be added to a config directly, read our secrets page for more info.

Type: string
Default: ""

oauth2.token_url​

The URL of the token provider.

Type: string
Default: ""

oauth2.scopes​

A list of optional requested permissions.

Type: array
Default: []

oauth2.endpoint_params​

A list of optional endpoint parameters, values should be arrays of strings.

Type: object
Default: {}

# Examples

endpoint_params:
bar:
- woof
foo:
- meow
- quack

basic_auth​

Allows you to specify basic authentication.

Type: object

basic_auth.enabled​

Whether to use basic authentication in requests.

Type: bool
Default: false

basic_auth.username​

A username to authenticate as.

Type: string
Default: ""

basic_auth.password​

A password to authenticate with.

Secret

This field contains sensitive information that usually shouldn't be added to a config directly, read our secrets page for more info.

Type: string
Default: ""

jwt​

BETA: Allows you to specify JWT authentication.

Type: object

jwt.enabled​

Whether to use JWT authentication in requests.

Type: bool
Default: false

jwt.private_key_file​

A file with the PEM encoded via PKCS1 or PKCS8 as private key.

Type: string
Default: ""

jwt.signing_method​

A method used to sign the token such as RS256, RS384, RS512 or EdDSA.

Type: string
Default: ""

jwt.claims​

A value used to identify the claims that issued the JWT.

Type: object
Default: {}

jwt.headers​

Add optional key/value headers to the JWT.

Type: object
Default: {}

tls​

Custom TLS settings can be used to override system defaults.

Type: object

tls.enabled​

Whether custom TLS settings are enabled.

Type: bool
Default: false

tls.skip_cert_verify​

Whether to skip server side certificate verification.

Type: bool
Default: false

tls.enable_renegotiation​

Whether to allow the remote server to repeatedly request renegotiation. Enable this option if you're seeing the error message local error: tls: no renegotiation.

Type: bool
Default: false
Requires version 1.0.0 or newer

tls.root_cas​

An optional root certificate authority to use. This is a string, representing a certificate chain from the parent trusted root certificate, to possible intermediate signing certificates, to the host certificate.

Secret

This field contains sensitive information that usually shouldn't be added to a config directly, read our secrets page for more info.

Type: string
Default: ""

# Examples

root_cas: |-
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----

tls.root_cas_file​

An optional path of a root certificate authority file to use. This is a file, often with a .pem extension, containing a certificate chain from the parent trusted root certificate, to possible intermediate signing certificates, to the host certificate.

Type: string
Default: ""

# Examples

root_cas_file: ./root_cas.pem

tls.client_certs​

A list of client certificates to use. For each certificate either the fields cert and key, or cert_file and key_file should be specified, but not both.

Type: array
Default: []

# Examples

client_certs:
- cert: foo
key: bar

client_certs:
- cert_file: ./example.pem
key_file: ./example.key

tls.client_certs[].cert​

A plain text certificate to use.

Type: string
Default: ""

tls.client_certs[].key​

A plain text certificate key to use.

Secret

This field contains sensitive information that usually shouldn't be added to a config directly, read our secrets page for more info.

Type: string
Default: ""

tls.client_certs[].cert_file​

The path of a certificate to use.

Type: string
Default: ""

tls.client_certs[].key_file​

The path of a certificate key to use.

Type: string
Default: ""

tls.client_certs[].password​

A plain text password for when the private key is password encrypted in PKCS#1 or PKCS#8 format. The obsolete pbeWithMD5AndDES-CBC algorithm is not supported for the PKCS#8 format. Warning: Since it does not authenticate the ciphertext, it is vulnerable to padding oracle attacks that can let an attacker recover the plaintext.

Secret

This field contains sensitive information that usually shouldn't be added to a config directly, read our secrets page for more info.

Type: string
Default: ""

# Examples

password: foo

password: ${KEY_PASSWORD}

extract_headers​

Specify which response headers should be added to resulting messages as metadata. Header keys are lowercased before matching, so ensure that your patterns target lowercased versions of the header keys that you expect.

Type: object

extract_headers.include_prefixes​

Provide a list of explicit metadata key prefixes to match against.

Type: array
Default: []

# Examples

include_prefixes:
- foo_
- bar_

include_prefixes:
- kafka_

include_prefixes:
- content-

extract_headers.include_patterns​

Provide a list of explicit metadata key regular expression (re2) patterns to match against.

Type: array
Default: []

# Examples

include_patterns:
- .*

include_patterns:
- _timestamp_unix$

rate_limit​

An optional rate limit to throttle requests by.

Type: string

timeout​

A static timeout to apply to requests.

Type: string
Default: "5s"

retry_period​

The base period to wait between failed requests.

Type: string
Default: "1s"

max_retry_backoff​

The maximum period to wait between failed requests.

Type: string
Default: "300s"

retries​

The maximum number of retry attempts to make.

Type: int
Default: 3

backoff_on​

A list of status codes whereby the request should be considered to have failed and retries should be attempted, but the period between them should be increased gradually.

Type: array
Default: [429]

drop_on​

A list of status codes whereby the request should be considered to have failed but retries should not be attempted. This is useful for preventing wasted retries for requests that will never succeed. Note that with these status codes the request is dropped, but message that caused the request will not be dropped.

Type: array
Default: []

successful_on​

A list of status codes whereby the attempt should be considered successful, this is useful for dropping requests that return non-2XX codes indicating that the message has been dealt with, such as a 303 See Other or a 409 Conflict. All 2XX codes are considered successful unless they are present within backoff_on or drop_on, regardless of this field.

Type: array
Default: []

proxy_url​

An optional HTTP proxy URL.

Type: string

digest_auth​

Digest authentication configuration.

Type: object
Requires version 1.18.0 or newer

digest_auth.enabled​

Enable the digest authentication

Type: bool
Default: false

digest_auth.username​

The username of the user.

Type: string
Default: ""

digest_auth.password​

The password of the user.

Type: string
Default: ""

negotiate​

Negotiate (SPNEGO) authentication configuration.

EXPERIMENTAL

The underlying package that implements the negotiate (SPNEGO) authentication is nascent.

Type: object
Requires version 1.19.0 or newer

negotiate.enabled​

Enable the spnego authentication.

Type: bool
Default: false

negotiate.api​

Change the underlying api, defaults to Pure, sspi only works on windows.

Type: string
Default: "pure"
Options: sspi, pure.

negotiate.user_only_for_fallback​

If a fallback to NTLM is required (no Kerberos on Pure api), a user configuration is required. Use this option to use this user only as a fallback.

Type: bool
Default: false

negotiate.user​

The user to use for the authentication. If the user is not configured, SSPI will use the currently logged-in user and Pure will use the Kerberos keytab file.

Type: object

negotiate.user.domain​

The domain of the user.

Type: string
Default: ""

negotiate.user.name​

The username of the user.

Type: string
Default: ""

negotiate.user.password​

The password of the user.

Secret

This field contains sensitive information that usually shouldn't be added to a config directly, read our secrets page for more info.

Type: string
Default: ""

negotiate.kerberos​

Options for Kerberos configuration. These options are ignored under SSPI.

Type: object

negotiate.kerberos.config_file_path​

The file path to the kerberos configuration file.

Type: string
Default: ""

negotiate.kerberos.ccname​

Setting for the Kerberos cache path. Allowed values would be FILE:/path/to/file for a file or DIR:/path/to/folder for a folder.

Type: string
Default: ""

transport​

Custom transport options.

Type: object
Requires version 1.13.0 or newer

transport.dial_context​

Settings for the dialer used to create new connections.

Type: object
Requires version 1.13.0 or newer

transport.dial_context.timeout​

Timeout for establishing new network connections.

Type: string
Default: "30s"
Requires version 1.13.0 or newer

transport.dial_context.keep_alive​

Keep-alive period for active network connections used by the dialer.

Type: string
Default: "30s"
Requires version 1.13.0 or newer

transport.force_http2​

If true, the transport will attempt to use HTTP/2.

Type: bool
Default: true
Requires version 1.13.0 or newer

transport.max_idle_connections​

Maximum number of idle keep-alive connections. Zero = unlimited.

Type: int
Default: 100
Requires version 1.13.0 or newer

transport.idle_connection_timeout​

Maximum time an idle keep-alive connection remains open before closing itself.

Type: string
Default: "90s"
Requires version 1.13.0 or newer

transport.tls_handshake_timeout​

Maximum time allowed for TLS handshake to complete.

Type: string
Default: "10s"
Requires version 1.13.0 or newer

transport.expect_continue_timeout​

Time to wait for a server's first response headers after sending request headers when 'Expect: 100-continue' is used. Zero means send body immediately.

Type: string
Default: "1s"
Requires version 1.13.0 or newer

payload​

An optional payload to deliver for each request. This field supports interpolation functions.

Type: string

drop_empty_bodies​

Whether empty payloads received from the target server should be dropped.

Type: bool
Default: true

stream​

Allows you to set streaming mode, where requests are kept open and messages are processed line-by-line.

Type: object

stream.enabled​

Enables streaming mode.

Type: bool
Default: false

stream.reconnect​

Sets whether to re-establish the connection once it is lost.

Type: bool
Default: true

stream.scanner​

The scanner by which the stream of bytes consumed will be broken out into individual messages. Scanners are useful for processing large sources of data without holding the entirety of it within memory. For example, the csv scanner allows you to process individual CSV rows without loading the entire CSV file in memory at once.

Type: scanner
Default: {"lines":{}}

auto_replay_nacks​

Whether messages that are rejected (nacked) at the output level should be automatically replayed indefinitely, eventually resulting in back pressure if the cause of the rejections is persistent. If set to false these messages will instead be deleted. Disabling auto replays can greatly improve memory efficiency of high throughput streams as the original shape of the data can be discarded immediately upon consumption and mutation.

Type: bool
Default: true