nats

package
v1.30.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 14 Imported by: 9

README

NATS Output Plugin

This plugin writes to a (list of) specified NATS instance(s).

Global configuration options

In addition to the plugin-specific configuration settings, plugins support additional global and plugin configuration settings. These settings are used to modify metrics, tags, and field or create aliases and configure ordering, etc. See the CONFIGURATION.md for more details.

Secret-store support

This plugin supports secrets from secret-stores for the username and password option. See the secret-store documentation for more details on how to use them.

Configuration

# Send telegraf measurements to NATS
[[outputs.nats]]
  ## URLs of NATS servers
  servers = ["nats://localhost:4222"]

  ## Optional client name
  # name = ""

  ## Optional credentials
  # username = ""
  # password = ""

  ## Optional NATS 2.0 and NATS NGS compatible user credentials
  # credentials = "/etc/telegraf/nats.creds"

  ## NATS subject for producer messages
  ## For jetstream this is also the subject where messages will be published
  subject = "telegraf"

  ## Use Transport Layer Security
  # secure = false

  ## Optional TLS Config
  # tls_ca = "/etc/telegraf/ca.pem"
  # tls_cert = "/etc/telegraf/cert.pem"
  # tls_key = "/etc/telegraf/key.pem"
  ## Use TLS but skip chain & host verification
  # insecure_skip_verify = false

  ## Data format to output.
  ## Each data format has its own unique set of configuration options, read
  ## more about them here:
  ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md
  data_format = "influx"

  ## Jetstream specific configuration. If not nil, it will assume Jetstream context.
  ## Since this is a table, it should be present at the end of the plugin section. Else you can use inline table format.
  # [outputs.nats.jetstream]
    ## Name of the stream, required when using jetstream. Telegraf will
    ## use the union of the above subject and below the subjects array.
    # name = "" 
    # subjects = []
    
    ## Full jetstream create stream config, refer: https://docs.nats.io/nats-concepts/jetstream/streams
    # retention = "limits"
    # max_consumers = -1
    # max_msgs_per_subject = -1
    # max_msgs = -1
    # max_bytes = -1
    # max_age = 0
    # max_msg_size = -1
    # storage = "file"
    # discard = "old"
    # num_replicas = 1
    # duplicate_window = 120000000000
    # sealed = false
    # deny_delete = false
    # deny_purge = false
    # allow_rollup_hdrs = false
    # allow_direct = true
    # mirror_direct = false

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NATS

type NATS struct {
	Servers     []string      `toml:"servers"`
	Secure      bool          `toml:"secure"`
	Name        string        `toml:"name"`
	Username    config.Secret `toml:"username"`
	Password    config.Secret `toml:"password"`
	Credentials string        `toml:"credentials"`
	Subject     string        `toml:"subject"`
	Jetstream   *StreamConfig `toml:"jetstream"`
	tls.ClientConfig

	Log telegraf.Logger `toml:"-"`
	// contains filtered or unexported fields
}

func (*NATS) Close

func (n *NATS) Close() error

func (*NATS) Connect

func (n *NATS) Connect() error

func (*NATS) Init added in v1.30.0

func (n *NATS) Init() error

func (*NATS) SampleConfig

func (*NATS) SampleConfig() string

func (*NATS) SetSerializer

func (n *NATS) SetSerializer(serializer serializers.Serializer)

func (*NATS) Write

func (n *NATS) Write(metrics []telegraf.Metric) error

type StreamConfig added in v1.30.0

type StreamConfig struct {
	Name                 string                            `toml:"name"`
	Description          string                            `toml:"description"`
	Subjects             []string                          `toml:"subjects"`
	Retention            string                            `toml:"retention"`
	MaxConsumers         int                               `toml:"max_consumers"`
	MaxMsgs              int64                             `toml:"max_msgs"`
	MaxBytes             int64                             `toml:"max_bytes"`
	Discard              string                            `toml:"discard"`
	DiscardNewPerSubject bool                              `toml:"discard_new_per_subject"`
	MaxAge               config.Duration                   `toml:"max_age"`
	MaxMsgsPerSubject    int64                             `toml:"max_msgs_per_subject"`
	MaxMsgSize           int32                             `toml:"max_msg_size"`
	Storage              string                            `toml:"storage"`
	Replicas             int                               `toml:"num_replicas"`
	NoAck                bool                              `toml:"no_ack"`
	Template             string                            `toml:"template_owner"`
	Duplicates           config.Duration                   `toml:"duplicate_window"`
	Placement            *jetstream.Placement              `toml:"placement"`
	Mirror               *jetstream.StreamSource           `toml:"mirror"`
	Sources              []*jetstream.StreamSource         `toml:"sources"`
	Sealed               bool                              `toml:"sealed"`
	DenyDelete           bool                              `toml:"deny_delete"`
	DenyPurge            bool                              `toml:"deny_purge"`
	AllowRollup          bool                              `toml:"allow_rollup_hdrs"`
	Compression          string                            `toml:"compression"`
	FirstSeq             uint64                            `toml:"first_seq"`
	SubjectTransform     *jetstream.SubjectTransformConfig `toml:"subject_transform"`
	RePublish            *jetstream.RePublish              `toml:"republish"`
	AllowDirect          bool                              `toml:"allow_direct"`
	MirrorDirect         bool                              `toml:"mirror_direct"`
	ConsumerLimits       jetstream.StreamConsumerLimits    `toml:"consumer_limits"`
	Metadata             map[string]string                 `toml:"metadata"`
}

StreamConfig is the configuration for creating stream Almost a mirror of https://pkg.go.dev/github.com/nats-io/nats.go/jetstream#StreamConfig but with TOML tags

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL