-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Snowbridge v3 #1068
Snowbridge v3 #1068
Changes from all commits
ebaf07b
3f76934
7a3a620
8e78b66
eab9e75
e70d52b
0f8b114
68a262a
e24272d
12be3ad
287fb04
bebbbf5
b73d218
908514d
2a7f0bd
0736699
999ba71
fd73446
04c5b82
21b3dfa
1891e62
28d27e9
1325cf2
8eecc26
505d2fd
f7f54d7
ef64719
daa0d10
db0747f
2bf5a1c
ceb3b0a
c4f1b60
8eb52ff
7061cda
1c5e29a
34a19ce
517aa14
1716b58
d4acb56
54e733e
44f5717
e082a4f
4f43a8f
3d68f5e
e50b3ad
1ff1ea1
1b1a8ad
05ef247
24a9ac4
6d2e9d7
f227c4a
87d9542
978f37f
40ad623
9f4ef97
7f1566a
b2fc01c
602bbaf
be8d75a
199c958
fdc8abd
8b97b0d
df3704e
bfb1db0
89e985e
b5915eb
ca58174
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
title: "3.X.X upgrade guide" | ||
sidebar_position: 400 | ||
--- | ||
|
||
## Breaking Changes | ||
|
||
The below breaking changes were made in version 3.0.0. All other functionality is backwards compatible. | ||
|
||
### Lua support removed | ||
|
||
Support for Lua transformations has been removed. If you are running a Lua transformation, you can port the logic to [Javascript](/docs/destinations/forwarding-events/snowbridge/configuration/transformations/custom-scripts/javascript-configuration/index.md) or [JQ](/docs/destinations/forwarding-events/snowbridge/configuration/transformations/builtin/jq.md). | ||
|
||
## HTTP target: non-JSON data no longer supported | ||
|
||
We never intended to support non-JSON data, but prior to version 3.0.0, the request body was simply populated with whatever bytes were found in the message data, regardless of whether it is valid JSON. | ||
|
||
From version 3.0.0 onwards, only valid JSON will work, otherwise the message will be considered invalid and sent to the failure target. | ||
|
||
## HTTP target: request batching | ||
|
||
Many HTTP APIs allow sending several events in a single request by putting them into a JSON array. Since version 3.0.0, if the Snowbridge source provides data in batches, the HTTP target will batch events in this way. | ||
|
||
As a consequence, even when the source provides events in a single event batch, it will now be placed into an array of one element. For example, prior to version 3.0.0, a request body might look like this: | ||
|
||
``` | ||
{"foo": "bar"} | ||
``` | ||
|
||
But it will now look like this: | ||
|
||
``` | ||
[{"foo": "bar"}] | ||
``` | ||
|
||
As of version 3.0.0, the SQS source provides events in batches of up to ten, and the Kinesis, Kafka, and Pubsub and Stdin sources provide events in single-event batches. This behavior will likely change in a future version. | ||
|
||
You can preserve the previous behavior and ensure that requests are always single-event non-array objects, even with a batching source. To do so, set `request_max_messages` to 1, and provide this template (as long as your data is valid JSON): | ||
|
||
```go reference | ||
https://github.com/snowplow/snowbridge/blob/master/assets/docs/configuration/targets/http-template-unwrap-example.file | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
title: "Retry behavior (beta)" | ||
description: "Configure retry behaviour." | ||
--- | ||
|
||
:::note | ||
This feature was added in version 3.0.0 | ||
|
||
This feature is in beta status because we may make breaking changes in future versions. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't this the case with all our stuff? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No we typically try to aim for stable support, in this case we will likely break the configuration soon. |
||
::: | ||
|
||
This feature allows you to configure the retry behavior when the target encounters a failure in sending the data. There are two types of failure you can define: | ||
|
||
A **transient failure** is a failure which we expect to succeed again on retry. For example, some temporary network error, or when we encounter throttling. Typically, you would configure a short backoff for this type of failure. When we encounter a transient failure, we keep processing the rest of the data as normal, under the expectation that everything is operating as normal. The failed data is retried after a backoff. | ||
|
||
A **setup failure** is one we don't expect to be immediately resolved, for example an incorrect address, or an invalid API Key. Typically, you would configure a long backoff for this type of failure, under the assumption that the issue needs to be fixed with either a configuration change or a change to the target itself (e.g. permissions need to be granted). Setup errors will be retried 5 times before the app crashes. | ||
|
||
As of version 3.0.0, only the http target can be configured to return setup errors, via the response rules feature - see [the http target configuration section](/docs/destinations/forwarding-events/snowbridge/configuration/targets/http/index.md). For all other targets, all errors returned will be considered transient, and behavior can be configured using the `transient` block of the retry configuration. | ||
|
||
Retries will be attempted with an exponential backoff. In other words, on each subsequent failure, the backoff time will double. You can configure transient failures to be retried indefinitely by setting `max_attempts` to 0. | ||
|
||
## Configuration options | ||
|
||
```hcl reference | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this github codeblock link says "See full example on Github", but it's the exact same thing as shown on the page, there's no more to it. Upsetting. Do you know of an example where there is actually more to see there? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the configuration docs contain a minimal example and an example which contains every possible option. There is no more to see - the message you're referring to I don't know anything about, it must be something to do with the plugin we use to embed the examples from the repo |
||
https://github.com/snowplow/snowbridge/blob/master/assets/docs/configuration/retry-example.hcl | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
title: "Kafka Source" | ||
title: "Kafka" | ||
description: "Read data from a Kafka topic." | ||
--- | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
title: "Kinesis Source" | ||
title: "Kinesis" | ||
description: "Read data from a Kinesis stream." | ||
--- | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
title: "PubSub Source" | ||
title: "PubSub" | ||
description: "Read data from a PubSub topic." | ||
--- | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
title: "SQS Source" | ||
title: "SQS" | ||
description: "Read data from an SQS queue." | ||
--- | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
title: "EventHub Target" | ||
title: "EventHub" | ||
description: "Write data to an EventHub." | ||
--- | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,84 @@ | ||
--- | ||
title: "HTTP Target" | ||
title: "HTTP" | ||
description: "Send data over HTTP." | ||
--- | ||
|
||
:::note | ||
Version 3.0.0 makes breaking changes to the http target. Details on migrating can be found [in the migration guide](/docs/destinations/forwarding-events/snowbridge/3-X-X-upgrade-guide/index.md) | ||
::: | ||
|
||
## Basic Authentication | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the page is called HTTP target, but it starts by talking about basicauth. What's the connection? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Basicauth is a means of authorising http. Every source and target section starts with a description of how to do auth - which was how @stanch wanted it when we first wrote the docs |
||
|
||
Where basicauth is used, it may be configured using the `basic_auth_username` and `basic_auth_password` options. Where an authorisation header is used, it may be set via the `headers` option. | ||
Where basicauth is used, it may be configured using the `basic_auth_username` and `basic_auth_password` options. Where an authorization header is used, it may be set via the `headers` option. | ||
|
||
we recommend using environment variables for sensitive values - which can be done via HCL's native `env.MY_ENV_VAR` format (as seen below). | ||
We recommend using environment variables for sensitive values - which can be done via HCL's native `env.MY_ENV_VAR` format (as seen below). | ||
|
||
TLS may be configured by providing the `key_file`, `cert_file` and `ca_file` options with paths to the relevant TLS files. | ||
|
||
## OAuth2 | ||
|
||
Snowbridge supports sending authorized requests to OAuth2 - compliant HTTP targets. This can be enabled in by setting `oauth2_client_id `, `oauth2_client_secret`, `oauth2_refresh_token` (these 3 are long-lived credentials used to generate short-lived bearer access tokens) and `oauth2_token_url`(which is the URL of authorization server providing access tokens). | ||
Snowbridge supports sending authorized requests to OAuth2-compliant HTTP targets. This can be enabled by setting `oauth2_client_id`, `oauth2_client_secret`, `oauth2_refresh_token` (these three are long-lived credentials used to generate short-lived bearer access tokens), and `oauth2_token_url` (which is the URL of the authorization server providing access tokens). | ||
|
||
Like in the case of basic authentication, we recommend using environment variables for sensitive values. | ||
|
||
## Dynamic headers | ||
|
||
:::note | ||
This feature was added in version 2.3.0 | ||
::: | ||
|
||
When enabled, this feature attaches a header to the data according to what your transformation provides in the `HTTPHeaders` field of `engineProtocol`. Data is batched independently per each dynamic header value before requests are sent. | ||
|
||
## Request templating | ||
|
||
:::note | ||
This feature was added in version 3.0.0 | ||
::: | ||
|
||
This feature allows you to provide a [Golang text template](https://pkg.go.dev/text/template) to construct a request body from a batch of data. This feature should be useful in constructing requests to send to an API, for example. | ||
|
||
Input data must be valid JSON, any message that fails to be marshaled to JSON will be treated as invalid and sent to the failure target. Equally, if an attempt to template a batch of data results in an error, then all messages in the batch will be considered invalid and sent to the failure target. | ||
|
||
Where the dynamic headers feature is enabled, data is split into batches according to the provided header value, and the templater will operate on each batch separately. | ||
|
||
### Helper functions | ||
|
||
In addition to all base functions available in the Go text/template package, the following custom functions are available for convenience: | ||
|
||
`prettyPrint` - Because the input to the templater is a Go data structure, simply providing a reference to an object field won't output it as JSON. `prettyPrint` converts the data to prettified JSON. Use it wherever you expect a JSON object in the output. This is compatible with any data type, but it shouldn't be necessary if the data is not an object. | ||
|
||
`env` - Allows you to set and refer to an env var in your template. Use it when your request body must contain sensitive data, for example an API key. | ||
|
||
### Template example | ||
|
||
The following example provides an API key via environment variable, and iterates the batch to provide JSON-formatted data one by one into a new key, inserting a comma before all but the first event. | ||
|
||
```hcl reference | ||
https://github.com/snowplow/snowbridge/blob/master/assets/docs/configuration/targets/http-template-full-example.file | ||
``` | ||
|
||
## Response rules (beta) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like these sections are quite chunky and should be in subpages There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does that make sense here? Leaving aside that we already have so many layers of sub-pages, these all describe the features which are documented in the example configuration below - and we can't link to a subpage from the example configuration. I'm not sure it makes sense to list the options here and then expect the user to go find the link to the subpage which explains what the option is. Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I disagree, we already have too many subpages. I don't like that there's already a subpage for GTM SS example which hardly fills the page, I'd prefer it to be merged into this one. The problem on this page isn't that there's a decent amount of info imo, it's that there's no intro explaining the context. Also lets get some bullet points up in this page There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a configuration reference page, like this one. It lists configuration options, and those that aren’t self-evident have an explanation - none of our similar pages have introductions like that. If there’s an argument to be made to change that, can I kindly suggest that we treat it as out of scope of this PR please? It documents a release that happened 3 months ago, when the PR was opened. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's fair! |
||
|
||
:::note | ||
This feature was added in version 3.0.0 | ||
|
||
This feature is in beta status because we may make breaking changes in future versions. | ||
::: | ||
|
||
Response rules allow you to configure how the app deals with failures in sending the data. You can configure a response code and an optional string match on the response body to determine how a failure response is handled. Response codes between 200 and 299 are considered successful, and are not handled by this feature. | ||
|
||
There are three categories of failure: | ||
|
||
`invalid` means that the data is considered incompatible with the target for some reason. For example, you may have defined a mapping for a given API, but the event happens to have null data for a required field. In this instance, retrying the data won't fix the issue, so you would configure an invalid response rule, identifying which responses indicate this scenario. | ||
|
||
Data that matches an invalid response rule is sent to the failure target. | ||
|
||
`setup` means that this error is not retryable, but is something which can only be resolved by a change in configuration or a change to the target. An example of this is an authentication failure - retrying will fix the issue, the resolution is to grant the appropriate permissions, or provide the correct API key. | ||
|
||
Data that matches a setup response rule is handled by a retry as determined in the `setup` configuration block of [retry configuration](/docs/destinations/forwarding-events/snowbridge/configuration/retries/index.md). | ||
|
||
`transient` errors are everything else - we assume that the issue is temporary and retrying will resolve the problem. An example of this is being throttled by an API because too much data is being sent at once. There is no explicit configuration for transient - rather, anything that is not configured as one of the other types is considered transient. | ||
|
||
## Configuration options | ||
|
||
Here is an example of the minimum required configuration: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
title: "Kafka Target" | ||
title: "Kafka" | ||
description: "Write data to a Kafka topic." | ||
--- | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
title: "Kinesis Target" | ||
title: "Kinesis" | ||
description: "Write data to a Kinesis stream." | ||
--- | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
title: "PubSub Target" | ||
title: "PubSub" | ||
description: "Write data to a Pubsub topic." | ||
--- | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
title: "SQS Target" | ||
title: "SQS" | ||
description: "Write data to an SQS queue." | ||
--- | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's a typo on line 65, "bahaviour"