sshexec

Executes a shell command on a remote host using an SSH profile. Runs the command after all previous pipeline stages have completed.

Command properties

ItemDescription
Command typeTransforming
Required permissionAdministrator
License usageN/A
Parallel executionNot supported
Distributed executionNot supported

Syntax

sshexec PROFILE COMMAND

Target

PROFILE
SSH profile name. Specify an SSH connection profile registered in the system.
COMMAND
Shell command to execute on the remote host. You can use query parameters (${}) to construct the command dynamically.

Error codes

Parse errors
Error codeMessageDescription
no-permission(dynamic message)The user does not have administrator permission.
missing-options(dynamic message)The profile name or command is not specified.
invalid-ssh-profile(dynamic message)The specified SSH profile is not registered.
Runtime errors

N/A

Description

The sshexec command connects to the remote host via SSH after all previous pipeline stages complete, then executes the specified shell command. The command execution result is not included in the query output.

If an error occurs during command execution, the error is logged and the connection is terminated.

This command requires administrator permission.

Examples

  1. Execute a script on a remote server

    table duration=1d WEB_APACHE
    | stats count by src_ip
    | outputcsv /tmp/report.csv src_ip, count
    | sshexec myprofile /opt/scripts/process_report.sh
    

    Aggregates web server access logs, saves them as CSV, then connects to the remote server using the myprofile SSH profile to run a post-processing script.

  2. Execute a dynamic command using query parameters

    set target_dir="/data/reports"
    | sshexec myprofile ls ${target_dir}
    

    Inserts the query parameter target_dir into the command to list the specified directory on the remote server.