Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat(outputs.nats): add nkey seed authentication support
  • Loading branch information
IfrKohn committed Nov 14, 2025
commit 199dc8f874958a773bbf06f78ef2ad8f47738f12
3 changes: 3 additions & 0 deletions plugins/outputs/nats/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ to use them.
## Optional NATS 2.0 and NATS NGS compatible user credentials
# credentials = "/etc/telegraf/nats.creds"

## Optional authentication with nkey seed file (NATS 2.0)
# nkey_seed = "/etc/telegraf/seed.txt"

## NATS subject for producer messages.
## This field can be a static string or a Go template, see README for details.
## Incompatible with `use_batch_format
Expand Down
9 changes: 9 additions & 0 deletions plugins/outputs/nats/nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type NATS struct {
Username config.Secret `toml:"username"`
Password config.Secret `toml:"password"`
Credentials string `toml:"credentials"`
NkeySeed string `toml:"nkey_seed"`
Subject string `toml:"subject"`
UseBatchFormat bool `toml:"use_batch_format"`
Jetstream *StreamConfig `toml:"jetstream"`
Expand Down Expand Up @@ -120,6 +121,14 @@ func (n *NATS) Connect() error {
opts = append(opts, nats.UserCredentials(n.Credentials))
}

if n.NkeySeed != "" {
opt, err := nats.NkeyOptionFromSeed(n.NkeySeed)
if err != nil {
return err
}
opts = append(opts, opt)
}

if n.Name != "" {
opts = append(opts, nats.Name(n.Name))
}
Expand Down
3 changes: 3 additions & 0 deletions plugins/outputs/nats/sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
## Optional NATS 2.0 and NATS NGS compatible user credentials
# credentials = "/etc/telegraf/nats.creds"

## Optional authentication with nkey seed file (NATS 2.0)
# nkey_seed = "/etc/telegraf/seed.txt"

## NATS subject for producer messages.
## This field can be a static string or a Go template, see README for details.
## Incompatible with `use_batch_format
Expand Down
Loading