Skip to content

Testing the `nats` sink

Pavlos Rontidis edited this page Aug 14, 2023 · 6 revisions

Setup

docker run -p 4222:4222 -p 8222:8222 -p 6222:6222 --name nats-server -ti nats:latest

Test that the server is running on macOS:

nc localhost 4222
# Output:
# INFO {"server_id":"NBOAIIDAPL46IQ37FTZMNSKZT4FONUNK6AAVH4HF4KYRVRXDUDSRUYXV","server_name":"NBOAIIDAPL46IQ37FTZMNSKZT4FONUNK6AAVH4HF4KYRVRXDUDSRUYXV","version":"2.9.21","proto":1,"git_commit":"b2e7725","go":"go1.19.12","host":"0.0.0.0","port":4222,"headers":true,"max_payload":1048576,"client_id":4,"client_ip":"172.17.0.1","cluster":"my_cluster"}


# if you do not have 'nc':
# telnet localhost 4222 

For more complex setups, please check this page.

Config

[sources.demo_logs]
type = "demo_logs"
format = "json"
interval = 1

[sinks.my_nats_sink]
type = "nats"
inputs = [ "demo_logs" ]
subject = "protocol"
url = "nats://localhost:4222"
encoding.codec = "json"