Exec
Exec Source
The Exec source collects observability data by executing a command or process directly on the host system. It captures the process output and converts it into structured observability events that can be processed by the pipeline.
This source is commonly used for:
- Periodic system checks
- Custom script output collection
- Legacy tooling integration
- Lightweight metrics or diagnostic data extraction
Exec runs in a sidecar role, meaning it operates alongside the monitored workload or system component.
Execution Model
The Exec source runs external commands using one of two execution modes:
- Scheduled mode: The command is executed periodically at a fixed interval.
- Streaming mode: The command runs continuously until it exits and may be automatically restarted.
The execution mode determines process lifecycle management, restart behavior, and resource usage characteristics.
Command Configuration
command (required, [string])
Defines the command to execute and its arguments. Each element in the list represents a single argument passed to the process.
This approach avoids shell interpretation issues and ensures predictable execution behavior across environments.
working_directory (optional, string)
Specifies the directory in which the command is executed. If not set, the command runs in the default working directory of the worker process.
This is useful when executing scripts or binaries that rely on relative paths.
Environment Management
environment (optional, object)
Defines custom environment variables that are set or overridden when executing the command. If a variable already exists in the environment, its value is replaced for the lifetime of the process.
This enables:
- Credential injection
- Feature flag control
- Runtime configuration without modifying the command itself
clear_environment (optional, bool)
When enabled, clears all inherited environment variables before applying the custom environment configuration.
This is typically used for:
- Security hardening
- Ensuring deterministic execution
- Avoiding unintended dependencies on host-level environment variables
Default behavior preserves the existing environment.
Output Capture Behavior
include_stderr (optional, bool)
Controls whether data written to stderr is captured and emitted as events.
When enabled, both standard output and standard error streams are included, allowing error messages and diagnostic output to be observed alongside normal output.
maximum_buffer_size_bytes (optional, uint)
Defines the maximum amount of buffered output allowed before an event is emitted.
This setting protects the system from excessive memory usage caused by commands that produce large or unbounded output.
Execution Modes
Scheduled Mode
In scheduled mode, the command is executed repeatedly at fixed intervals.
- If a command execution exceeds the configured interval, it is forcibly terminated.
- Each execution is treated as an independent run.
- Suitable for periodic checks and polling-based data collection.
scheduled.exec_interval_secs (optional, uint)
Defines the interval between consecutive command executions, in seconds.
Streaming Mode
In streaming mode, the command is started once and runs continuously until it exits.
This mode is suitable for:
- Long-running processes
- Continuous output generators
- Tail-like or watch-style commands
streaming.respawn_on_exit (optional, bool)
Controls whether the command should be automatically restarted after it exits.
streaming.respawn_interval_secs (optional, uint)
Specifies the delay, in seconds, before restarting a command that has exited.
This prevents tight restart loops in the case of failing or misconfigured commands.
Decoding Configuration (decoding)
Controls how raw process output bytes are interpreted and converted into events.
The Exec source supports a wide range of codecs, allowing output to be parsed into logs, metrics, or traces depending on the selected format.
If no codec is specified, output is treated as raw bytes.
Multi-Signal Support
Certain codecs (such as native, native_json, and otlp) are capable of emitting:
- Logs
- Metrics
- Traces
The emitted signal type is determined dynamically based on the decoded payload.
Codec-Specific Notes
- Lossy decoding options allow invalid UTF-8 sequences to be replaced instead of failing the event.
- Avro decoding requires a schema definition and supports a limited subset of Avro logical types.
- Protobuf decoding may require a descriptor file and message type definition.
- VRL decoding executes a Vector Remap Language program and uses the resulting event as the final output.
Framing Configuration (framing)
Framing defines how the raw byte stream produced by the process is split into individual events.
This is especially important for commands that emit multiple logical events over a single stream.
Supported Framing Methods
- bytes
- newline_delimited
- character_delimited
- length_delimited
- varint_length_delimited
- octet_counting
- chunked_gelf
Each framing method supports optional size limits to prevent unbounded buffering when handling malformed or unexpected output.
Reliability and Delivery Semantics
The Exec source provides at-least-once delivery, meaning output may be re-emitted if downstream failures occur.
Because acknowledgements are not supported:
- Output is considered delivered once it is handed off to the pipeline
- Downstream reliability must be handled at the sink or global level
Common Use Cases
- Host-level diagnostics and health checks
- Custom metrics generation scripts
- Wrapping legacy CLI tools into observability pipelines
- Controlled execution of system inspection commands
The Exec source provides a flexible bridge between process-based tooling and modern observability pipelines.