Added "name" parameter to NATS output plugin (#8429)
This commit is contained in:
parent
4090c77275
commit
f5d5a51c21
|
|
@ -6,6 +6,10 @@ This plugin writes to a (list of) specified NATS instance(s).
|
|||
[[outputs.nats]]
|
||||
## URLs of NATS servers
|
||||
servers = ["nats://localhost:4222"]
|
||||
|
||||
## Optional client name
|
||||
# name = ""
|
||||
|
||||
## Optional credentials
|
||||
# username = ""
|
||||
# password = ""
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import (
|
|||
type NATS struct {
|
||||
Servers []string `toml:"servers"`
|
||||
Secure bool `toml:"secure"`
|
||||
Name string `toml:"name"`
|
||||
Username string `toml:"username"`
|
||||
Password string `toml:"password"`
|
||||
Credentials string `toml:"credentials"`
|
||||
|
|
@ -30,6 +31,9 @@ var sampleConfig = `
|
|||
## URLs of NATS servers
|
||||
servers = ["nats://localhost:4222"]
|
||||
|
||||
## Optional client name
|
||||
# name = ""
|
||||
|
||||
## Optional credentials
|
||||
# username = ""
|
||||
# password = ""
|
||||
|
|
@ -73,6 +77,10 @@ func (n *NATS) Connect() error {
|
|||
opts = append(opts, nats.UserInfo(n.Username, n.Password))
|
||||
}
|
||||
|
||||
if n.Name != "" {
|
||||
opts = append(opts, nats.Name(n.Name))
|
||||
}
|
||||
|
||||
if n.Secure {
|
||||
tlsConfig, err := n.ClientConfig.TLSConfig()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ func TestConnectAndWrite(t *testing.T) {
|
|||
s, _ := serializers.NewInfluxSerializer()
|
||||
n := &NATS{
|
||||
Servers: server,
|
||||
Name: "telegraf",
|
||||
Subject: "telegraf",
|
||||
serializer: s,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue