Created
December 19, 2022 16:09
-
-
Save choult/e2b5fef750fc26064e62d2a543b4534f to your computer and use it in GitHub Desktop.
This Benthos config demonstrates the consumption of Mastodon HTTP Server-Sent Events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input: | |
broker: | |
copies: 1 | |
inputs: | |
- http_client: | |
url: "https://mas.to/api/v1/streaming/public" | |
stream: | |
enabled: true | |
reconnect: true | |
codec: lines | |
max_buffer: 100000000 | |
processors: | |
- mapping: | | |
root = if content().string().has_prefix(":") { deleted() } | |
batching: | |
count: 2 | |
pipeline: | |
processors: | |
- grok: | |
expressions: | |
- '%{HTTPSSE}' | |
pattern_definitions: | |
HTTPSSE: "%{NOTSPACE:key}: %{GREEDYDATA:value}" | |
- archive: | |
format: json_array | |
- mapping: | | |
root.event = this."0".value | |
root.data = this."1".value.parse_json() | |
output: | |
stdout: | |
codec: lines |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment