NATS JetStream
Introduction
Core NATS delivers messages only to subscribers connected at the moment of publication. NATS JetStream adds a persistence layer on top, giving you at-least-once delivery.
Setting up JetStream
First, connect to NATS server, for this example we'll use localhost connection:
nats context add localhost --description "Localhost"
Then, create a log stream for FlowG:
nats stream add FLOWG --subjects "flowg" --storage file --retention limits --defaults
Setting up the FlowG pipeline
First, let's create a "JetStream Forwarder" named jetstream, with the
following configuration:
Forwarder TypeJetStream
Servershttp://localhost:4222
Subjectflowg
BodytoJSON(log)
Message ID
Expected StreamFLOWG
Publish Timeout0
Auth modeNONE
TLS Insecure Skip Verify
Then, create a pipeline that forwards logs received via Syslog to the jetstream
forwarder:
SourceSYSLOG
Forwarderjetstream
And that's it!
Testing
You can test the setup by sending a log to the pipeline using the logger
command:
logger -n localhost -P 5514 -t myapp1 'hello world'
You can then find your logs using nats CLI interface, with command:
nats stream get FLOWG 1