Sshcheck Receiver
contrib
Maintainers: @ishaish103
Source: opentelemetry-collector-contrib
Supported Telemetry
Overview
Prerequisites
Ifignore_host_key is not set then host key validation requires the agent either have a known_hosts file at a path specified by setting known_hosts or at default paths indicated by ssh man pages: $HOME/.ssh/known_hosts or /etc/ssh/known_hosts.
Configuration
The following settings are required:endpointusernamepasswordorkey_file
password or key_file must be set. But if both are set then password is treated as the passphrase and the key is assumed to be encrypted.
The following settings are optional:
collection_interval(default =60s): This receiver collects metrics on an interval. Valid time units arens,us(orµs),ms,s,m,h.known_hosts(default = ssh defaults): The path to the known_hosts file. If this isn’t set then default locations are checked at$HOME/.ssh/known_hostsand/etc/ssh/known_hosts.ignore_host_key(default = false): Can override conventional ssh security for use cases like tests where authentication via the known_hosts file isn’t required.
Example Configuration
Basic SSH check with password authentication:Advanced Configuration
Timeout Configuration
Thetimeout option controls how long the receiver waits for an SSH connection to establish. The default is 10s. This timeout applies to both SSH and SFTP connection attempts.
SFTP Check Configuration
SFTP checks can be enabled in two ways:- Using the
check_sftpoption (enables SFTP status and duration metrics):
- By enabling SFTP metrics individually:
check_sftp is enabled or SFTP metrics are individually enabled, the receiver will attempt to establish an SFTP connection after a successful SSH connection. Note that SFTP checks require a successful SSH connection first (see Limitations section).
Metric Enable/Disable Configuration
Individual metrics can be enabled or disabled using themetrics configuration section. By default, all SSH metrics are enabled and all SFTP metrics are disabled.
Known Hosts Configuration
Theknown_hosts option specifies the path to the SSH known_hosts file for host key validation. If not specified, the receiver checks default locations:
$HOME/.ssh/known_hosts/etc/ssh/known_hosts
Security Considerations
Theignore_host_key option disables host key validation. This should only be used in test environments as it makes the connection vulnerable to man-in-the-middle attacks.
known_hosts or ensure the host key is in the default known_hosts locations.
Limitations and Warnings
Security
- Authentication: Passwords in configuration files should be stored securely. Consider using environment variables or secret management systems. Key file authentication is recommended for production use.
Performance
-
Connection Overhead: Each check creates a new SSH connection. The
collection_intervalshould be configured based on your monitoring needs and the impact on the SSH server. More frequent checks (e.g., every 10 seconds) will create more connections. -
Timeout Behavior: If a connection times out, it will be retried on the next collection interval. Ensure your
timeoutvalue is appropriate for your network conditions.
Feature Gates
This receiver does not currently use any feature gates. All functionality is available through configuration options.Metrics
This receiver produces the following metrics:| Metric Name | Type | Description | Unit | Enabled by Default |
|---|---|---|---|---|
sshcheck.duration | Gauge | Measures the duration of SSH connection | ms | Yes |
sshcheck.status | Sum | 1 if SSH client successfully connected, otherwise 0 | 1 | Yes |
sshcheck.error | Sum | Records errors occurring during SSH check | {error} | Yes |
sshcheck.sftp_duration | Gauge | Measures SFTP request duration | ms | No |
sshcheck.sftp_status | Sum | 1 if SFTP server replied to request, otherwise 0 | 1 | No |
sshcheck.sftp_error | Sum | Records errors occurring during SFTP check | {error} | No |
Resource Attributes
The receiver adds the following resource attribute:ssh.endpoint: The full SSH endpoint being monitored (disabled by default, can be enabled in metadata.yaml)
Detailed Metric Documentation
Complete details about the metrics produced by this receiver, including attributes, types, and units, can be found in documentation.md and metadata.yaml.Metrics
| Metric Name | Description | Unit | Type | Attributes |
|---|---|---|---|---|
✅ sshcheck.duration | Measures the duration of SSH connection. | ms | Gauge | |
✅ sshcheck.error | Records errors occurring during SSH check. | {error} | UpDownCounter | error.message |
❌ sshcheck.sftp_duration | Measures SFTP request duration. | ms | Gauge | |
❌ sshcheck.sftp_error | Records errors occurring during SFTP check. | {error} | UpDownCounter | error.message |
❌ sshcheck.sftp_status | 1 if the SFTP server replied to request, otherwise 0. | 1 | UpDownCounter | |
✅ sshcheck.status | 1 if the SSH client successfully connected, otherwise 0. | 1 | UpDownCounter |
Attributes
| Attribute Name | Description | Type | Values |
|---|---|---|---|
error.message | Error message recorded during check | string |
Resource Attributes
| Attribute Name | Description | Type | Enabled |
|---|---|---|---|
ssh.endpoint | Full SSH endpoint | string | ❌ |
Configuration
Example Configuration
Last generated: 2026-04-13