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]]
|
[[outputs.nats]]
|
||||||
## URLs of NATS servers
|
## URLs of NATS servers
|
||||||
servers = ["nats://localhost:4222"]
|
servers = ["nats://localhost:4222"]
|
||||||
|
|
||||||
|
## Optional client name
|
||||||
|
# name = ""
|
||||||
|
|
||||||
## Optional credentials
|
## Optional credentials
|
||||||
# username = ""
|
# username = ""
|
||||||
# password = ""
|
# password = ""
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import (
|
||||||
type NATS struct {
|
type NATS struct {
|
||||||
Servers []string `toml:"servers"`
|
Servers []string `toml:"servers"`
|
||||||
Secure bool `toml:"secure"`
|
Secure bool `toml:"secure"`
|
||||||
|
Name string `toml:"name"`
|
||||||
Username string `toml:"username"`
|
Username string `toml:"username"`
|
||||||
Password string `toml:"password"`
|
Password string `toml:"password"`
|
||||||
Credentials string `toml:"credentials"`
|
Credentials string `toml:"credentials"`
|
||||||
|
|
@ -30,6 +31,9 @@ var sampleConfig = `
|
||||||
## URLs of NATS servers
|
## URLs of NATS servers
|
||||||
servers = ["nats://localhost:4222"]
|
servers = ["nats://localhost:4222"]
|
||||||
|
|
||||||
|
## Optional client name
|
||||||
|
# name = ""
|
||||||
|
|
||||||
## Optional credentials
|
## Optional credentials
|
||||||
# username = ""
|
# username = ""
|
||||||
# password = ""
|
# password = ""
|
||||||
|
|
@ -73,6 +77,10 @@ func (n *NATS) Connect() error {
|
||||||
opts = append(opts, nats.UserInfo(n.Username, n.Password))
|
opts = append(opts, nats.UserInfo(n.Username, n.Password))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if n.Name != "" {
|
||||||
|
opts = append(opts, nats.Name(n.Name))
|
||||||
|
}
|
||||||
|
|
||||||
if n.Secure {
|
if n.Secure {
|
||||||
tlsConfig, err := n.ClientConfig.TLSConfig()
|
tlsConfig, err := n.ClientConfig.TLSConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ func TestConnectAndWrite(t *testing.T) {
|
||||||
s, _ := serializers.NewInfluxSerializer()
|
s, _ := serializers.NewInfluxSerializer()
|
||||||
n := &NATS{
|
n := &NATS{
|
||||||
Servers: server,
|
Servers: server,
|
||||||
|
Name: "telegraf",
|
||||||
Subject: "telegraf",
|
Subject: "telegraf",
|
||||||
serializer: s,
|
serializer: s,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue