exec

package
v1.32.3 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: MIT Imports: 14 Imported by: 1

README

Executable Output Plugin

This plugin writes metrics to an external application via stdin. The command will be executed on each write creating a new process. Metrics are passed in one of the supported data formats.

The executable and the individual parameters must be defined as a list. All outputs of the executable to stderr will be logged in the Telegraf log.

[!TIP] For better performance consider execd which runs continuously.

⭐ Telegraf v1.12.0 🏷️ system 💻 all

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.

Configuration

# Send metrics to command as input over stdin
[[outputs.exec]]
  ## Command to ingest metrics via stdin.
  command = ["tee", "-a", "/dev/null"]

  ## Environment variables
  ## Array of "key=value" pairs to pass as environment variables
  ## e.g. "KEY=value", "USERNAME=John Doe",
  ## "LD_LIBRARY_PATH=/opt/custom/lib64:/usr/local/libs"
  # environment = []

  ## Timeout for command to complete.
  # timeout = "5s"

  ## Whether the command gets executed once per metric, or once per metric batch
  ## The serializer will also run in batch mode when this is true.
  # use_batch_format = true

  ## 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"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandRunner

type CommandRunner struct {
	// contains filtered or unexported fields
}

CommandRunner runs a command with the ability to kill the process before the timeout.

func (*CommandRunner) Run

func (c *CommandRunner) Run(timeout time.Duration, command, environments []string, buffer io.Reader) error

Run runs the command.

type Exec

type Exec struct {
	Command        []string        `toml:"command"`
	Environment    []string        `toml:"environment"`
	Timeout        config.Duration `toml:"timeout"`
	UseBatchFormat bool            `toml:"use_batch_format"`
	Log            telegraf.Logger `toml:"-"`
	// contains filtered or unexported fields
}

Exec defines the exec output plugin.

func (*Exec) Close

func (e *Exec) Close() error

Close satisfies the Output interface.

func (*Exec) Connect

func (e *Exec) Connect() error

Connect satisfies the Output interface.

func (*Exec) Init added in v1.18.1

func (e *Exec) Init() error

func (*Exec) SampleConfig

func (*Exec) SampleConfig() string

func (*Exec) SetSerializer

func (e *Exec) SetSerializer(serializer serializers.Serializer)

SetSerializer sets the serializer for the output.

func (*Exec) Write

func (e *Exec) Write(metrics []telegraf.Metric) error

Write writes the metrics to the configured command.

type Runner

type Runner interface {
	Run(time.Duration, []string, []string, io.Reader) error
}

Runner provides an interface for running exec.Cmd.

Jump to

Keyboard shortcuts

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