Documentation

Exec Input Plugin

This plugin executes the given commands on every interval and parses metrics from their output in any one of the supported data formats. This plugin can be used to poll for custom metrics from any source.

Introduced in: Telegraf v0.1.5 Tags: system OS support: all

Global configuration options

Plugins support additional global and plugin configuration settings for tasks such as modifying metrics, tags, and fields, creating aliases, and configuring plugin ordering. See CONFIGURATION.md for more details.

Configuration

# Read metrics from one or more commands that can output to stdout
[[inputs.exec]]
  ## Commands array
  commands = []

  ## 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 each command to complete.
  # timeout = "5s"

  ## Measurement name suffix
  ## Used for separating different commands
  # name_suffix = ""

  ## Ignore Error Code
  ## If set to true, a non-zero error code in not considered an error and the
  ## plugin will continue to parse the output.
  # ignore_error = false

  ## Log all messages sent to stderr
  # log_stderr = false

  ## Data format
  ## By default, exec expects JSON. This was done for historical reasons and is
  ## different than other inputs that use the influx line protocol. 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_INPUT.md
  # data_format = "json"

Glob patterns in the command option are matched on every run, so adding new scripts that match the pattern will cause them to be picked up immediately.

Logging

When setting log_stderr to true, the called command may write log messages to stderr, which Telegraf will log line-wise using the configured logging facility. By default, the error level will be used. Use the known prefixes E!, W!, I!, D! or T! to log with the error, warning, info, debug or trace log-level, respectively.

Example

This script produces static values, since no timestamp is specified the values are at the current time. Ensure that int values are followed with i for proper parsing.

#!/bin/sh
echo 'example,tag1=a,tag2=b i=42i,j=43i,k=44i'

It can be paired with the following configuration and will be run at the interval of the agent.

[[inputs.exec]]
  commands = ["sh /tmp/test.sh"]
  timeout = "5s"
  data_format = "influx"

Troubleshooting

My script works when I run it by hand, but not when Telegraf is running as a service

This may be related to the Telegraf service running as a different user. The official packages run Telegraf as the telegraf user and group on Linux systems.

With a PowerShell on Windows, the output of the script appears to be truncated

You may need to set a variable in your script to increase the number of columns available for output:

$host.UI.RawUI.BufferSize = new-object System.Management.Automation.Host.Size(1024,50)

Metrics

Example Output


Was this page helpful?

Thank you for your feedback!


InfluxDB 3.9: Performance upgrade preview

InfluxDB 3 Enterprise 3.9 includes a beta of major performance upgrades with faster single-series queries, wide-and-sparse table support, and more.

InfluxDB 3 Enterprise 3.9 includes a beta of major performance and feature updates.

Key improvements:

  • Faster single-series queries
  • Consistent resource usage
  • Wide-and-sparse table support
  • Automatic distinct value caches for reduced latency with metadata queries

Preview features are subject to breaking changes.

For more information, see:

Telegraf Enterprise now in public beta

Get early access to the Telegraf Controller and provide feedback to help shape the future of Telegraf Enterprise.

See the Blog Post

The upcoming Telegraf Enterprise offering is for organizations running Telegraf at scale and is comprised of two key components:

  • Telegraf Controller: A control plane (UI + API) that centralizes Telegraf configuration management and agent health visibility.
  • Telegraf Enterprise Support: Official support for Telegraf Controller and Telegraf plugins.

Join the Telegraf Enterprise beta to get early access to the Telegraf Controller and provide feedback to help shape the future of Telegraf Enterprise.

For more information:

Telegraf Controller v0.0.6-beta now available

Telegraf Controller v0.0.6-beta is now available with new features, improvements, and bug fixes.

View the release notes
Download Telegraf Controller v0.0.6-beta

InfluxDB Docker latest tag changing to InfluxDB 3 Core

On May 27, 2026, the latest tag for InfluxDB Docker images will point to InfluxDB 3 Core. To avoid unexpected upgrades, use specific version tags in your Docker deployments.

If using Docker to install and run InfluxDB, the latest tag will point to InfluxDB 3 Core. To avoid unexpected upgrades, use specific version tags in your Docker deployments. For example, if using Docker to run InfluxDB v2, replace the latest version tag with a specific version tag in your Docker pull command–for example:

docker pull influxdb:2