Prometheus metrics exporter for SFTP.
python sftp-exporter.py <path_to_config>path_to_config should be a path to a
configuration YAML file at the same host.
By default, exporter listens on 127.0.0.1:9339.
Pass --host or --port parameters to change
listen interface or port respectively.
docker run -v <path_to_config>:/config.yml \
-it quay.io/verygoodsecurity/sftp-exporter:dev-2.0.0Configuration file should contain list of SFTP
check configurations under the single key checks
checks:
- host: sftp1.my.org
port: 4822
...
- host: sftp2.my.org
port: 4822Available properties for SFTP check configuration:
hostA host where SFTP service is listeningportPort of SFTP service (defaults to 22 if not passed)usernameUsername to authenticate with (defaults tosftp)passwordOptional password to authenticate withclient_key_fileOptional path to local file containing private SSH key to authenticate withtimeoutTimeout between checking SFTP (900by default)foldersList of folders to check files in (defaults to single item/)patternsList of patterns to check files in (defaults to single pattern*)validate_known_hostsWhether to validate known hosts or notcheckerCheck algorithm identifier to be used.
Following checker algorithms are available for use:
Default checker algorithm is noop, that only lists files in each SFTP folder,
Checker algorithm identified as put_get_del will perform sequence of operations in each folder,
An algorithm named attributes will export mtime,atime and size for each file.
Sometimes either folder name or file name in SFTP can contain date inside, so check folders or patterns should change over time. In this case, following parameters could be set to "true" to trigger smart date handling:
smart_folder_date-- enables smart date for folderssmart_pattern_date-- enables smart date for patterns Then, pythonstrftimemodifiers can be put intofoldersorpatternsto be replaced with today's date and time values.
For example,
checks:
- smart_pattern_date: true
patterns:
- "*%Y%m%d*"when called on 31 May, 2021 will match all files that have
20210531 in the file name.
If you need base date to be set to other values than today, use
- base_pattern_date: yesterday
- base_folder_date: '2 days ago'
to set base date to other day when templating.
Base date values are parsed with dateparser.
sftp_host_up -- when the SFTP host have been successfully accessed for the last time
Dimensions:
hostHost of SFTP server that is being monitoredusernameName of user used for connectionstateState of connection, can be one ofOk,DNSError,SFTPError
sftp_put_file_up -- when the put check have been done successfully for the last time
Dimensions:
hostHost of SFTP server that is being monitoredfolderFolder that have been checked for write-abilityusernameUsername that have been logging instateState of write-ability, one ofOk,Error
sftp_get_file_up -- when the get check have been done successfully for the last time
Dimensions:
hostHost of SFTP server that is being monitoredfolderFolder that have been checked for read-abilityusernameUsername that have been logging instateState of write-ability, one ofOk,Corrupted,Error
sftp_del_file_up -- when the remove check have been done successfully for the last time
Dimensions:
hostHost of SFTP server that is being monitoredfolderFolder that have been checked for remove-abilityusernameUsername that have been logging instateState of write-ability, one ofOk,Error
sftp_last_seen_timestamp -- when the file was spotted on SFTP server last time
Dimensions:
folderFolder name where file was spottedfileName of the file have been spottedhostHost of SFTP server that housed a file
sftp_file_modified_timestamp -- mtime attribute as reported by SFTP server
Dimensions:
folderFolder name where file was spottedfileName of the file have been spottedhostHost of SFTP server that housed a file
sftp_file_access_timestamp -- atime attribute as reported by SFTP server
Dimensions:
folderFolder name where file was spottedfileName of the file have been spottedhostHost of SFTP server that housed a file
sftp_file_size -- size attribute as reported by SFTP server
Dimensions:
folderFolder name where file was spottedfileName of the file have been spottedhostHost of SFTP server that housed a file
MIT.