# arthass/sftp-exporter architecture

> Architecture diagram of the GitHub repository arthass/sftp-exporter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arthass/sftp-exporter
- Repository: https://github.com/arthass/sftp-exporter

## Overview

sftp-exporter is a Prometheus exporter that reads configured SFTP targets and paths, connects over SSH/SFTP, and exposes connection, filesystem-capacity, and file-count/size metrics over HTTP. The primary flow is configuration and startup, Prometheus scraping /metrics, collection from SFTP, and returning metrics. The README also documents a Grafana dashboard. Source excerpts support the startup and collection wiring; the Grafana query relationship is shown as optional based on the documented dashboard capability.

Main entry points: [`pkg/collector/sftp_collector.go`](https://github.com/arthass/sftp-exporter/blob/master/pkg/collector/sftp_collector.go) (SFTP metrics collector), [`pkg/server/server.go`](https://github.com/arthass/sftp-exporter/blob/master/pkg/server/server.go) (HTTP server), [`cmd/root.go`](https://github.com/arthass/sftp-exporter/blob/master/cmd/root.go) (CLI and config), [`pkg/client/sftp_client.go`](https://github.com/arthass/sftp-exporter/blob/master/pkg/client/sftp_client.go) (SFTP connection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_configuration["Configuration and startup"]
  node_flags["CLI and config<br/>[root.go]"]
  node_config_keys["Configuration keys<br/>[viper_keys.go]"]
  node_entry["Program entry<br/>[main.go]"]
end

subgraph group_serving["HTTP and metrics serving"]
  node_server["HTTP server<br/>[server.go]"]
  node_metrics_endpoint["Metrics endpoint<br/>[server.go]"]
  node_health_endpoint["Health endpoint<br/>[server.go]"]
end

subgraph group_collection["SFTP collection"]
  node_collector["SFTP metrics collector<br/>[sftp_collector.go]"]
  node_filesystem_metrics["Filesystem capacity<br/>[sftp_collector.go]"]
  node_object_metrics["File count and size<br/>[sftp_collector.go]"]
  node_sftp_client["SFTP connection<br/>[sftp_client.go]"]
  node_ssh_auth["SSH authentication<br/>[ssh.go]"]
end

subgraph group_observability["Monitoring integrations"]
  node_prometheus(("Prometheus"))
  node_grafana(("Grafana"))
  node_dashboard["Grafana dashboard"]
end

node_operator(("Exporter operator"))
node_sftp_server(("SFTP server"))

node_operator -->|"sets options"| node_flags
node_flags -->|"binds settings"| node_config_keys
node_entry -->|"executes"| node_flags
node_flags -->|"starts"| node_server
node_server -->|"creates"| node_sftp_client
node_server -->|"registers"| node_collector
node_prometheus -->|"scrapes"| node_metrics_endpoint
node_metrics_endpoint -->|"collects metrics"| node_collector
node_server -->|"serves"| node_health_endpoint
node_collector -->|"connects and queries"| node_sftp_client
node_collector -->|"emits capacity"| node_filesystem_metrics
node_collector -->|"walks paths"| node_object_metrics
node_sftp_client -->|"opens SSH session"| node_ssh_auth
node_ssh_auth -->|"authenticates and dials"| node_sftp_server
node_sftp_client -->|"reads SFTP data"| node_sftp_server
node_grafana -.->|"queries metrics"| node_prometheus
node_grafana -.->|"uses dashboard"| node_dashboard

click node_flags "https://github.com/arthass/sftp-exporter/blob/master/cmd/root.go"
click node_config_keys "https://github.com/arthass/sftp-exporter/blob/master/pkg/constants/viperkeys/viper_keys.go"
click node_entry "https://github.com/arthass/sftp-exporter/blob/master/main.go"
click node_server "https://github.com/arthass/sftp-exporter/blob/master/pkg/server/server.go"
click node_metrics_endpoint "https://github.com/arthass/sftp-exporter/blob/master/pkg/server/server.go"
click node_health_endpoint "https://github.com/arthass/sftp-exporter/blob/master/pkg/server/server.go"
click node_collector "https://github.com/arthass/sftp-exporter/blob/master/pkg/collector/sftp_collector.go"
click node_filesystem_metrics "https://github.com/arthass/sftp-exporter/blob/master/pkg/collector/sftp_collector.go"
click node_object_metrics "https://github.com/arthass/sftp-exporter/blob/master/pkg/collector/sftp_collector.go"
click node_sftp_client "https://github.com/arthass/sftp-exporter/blob/master/pkg/client/sftp_client.go"
click node_ssh_auth "https://github.com/arthass/sftp-exporter/blob/master/pkg/client/ssh.go"
click node_dashboard "https://github.com/arthass/sftp-exporter/blob/master/grafana/SFTP-1621083257598.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_flags,node_config_keys,node_entry toneBlue
class node_server,node_metrics_endpoint,node_health_endpoint toneAmber
class node_collector,node_filesystem_metrics,node_object_metrics,node_sftp_client,node_ssh_auth,node_sftp_server toneMint
class node_prometheus,node_grafana,node_dashboard toneRose
class node_operator toneIndigo
```

## Components

### Configuration and startup

- [CLI and config](https://github.com/arthass/sftp-exporter/blob/master/cmd/root.go): `cmd/root.go`
- [Configuration keys](https://github.com/arthass/sftp-exporter/blob/master/pkg/constants/viperkeys/viper_keys.go): `pkg/constants/viperkeys/viper_keys.go`
- [Program entry](https://github.com/arthass/sftp-exporter/blob/master/main.go): `main.go`

### HTTP and metrics serving

- [HTTP server](https://github.com/arthass/sftp-exporter/blob/master/pkg/server/server.go): `pkg/server/server.go`
- [Metrics endpoint](https://github.com/arthass/sftp-exporter/blob/master/pkg/server/server.go): `pkg/server/server.go`
- [Health endpoint](https://github.com/arthass/sftp-exporter/blob/master/pkg/server/server.go): `pkg/server/server.go`

### SFTP collection

- [SFTP metrics collector](https://github.com/arthass/sftp-exporter/blob/master/pkg/collector/sftp_collector.go): `pkg/collector/sftp_collector.go`
- [Filesystem capacity](https://github.com/arthass/sftp-exporter/blob/master/pkg/collector/sftp_collector.go): `pkg/collector/sftp_collector.go`
- [File count and size](https://github.com/arthass/sftp-exporter/blob/master/pkg/collector/sftp_collector.go): `pkg/collector/sftp_collector.go`
- [SFTP connection](https://github.com/arthass/sftp-exporter/blob/master/pkg/client/sftp_client.go): `pkg/client/sftp_client.go`
- [SSH authentication](https://github.com/arthass/sftp-exporter/blob/master/pkg/client/ssh.go): `pkg/client/ssh.go`

### Monitoring integrations

- **Prometheus**
- **Grafana**
- [Grafana dashboard](https://github.com/arthass/sftp-exporter/blob/master/grafana/SFTP-1621083257598.json): `grafana/SFTP-1621083257598.json`

### Other components

- **Exporter operator**
- **SFTP server**

## Connections

- Exporter operator → CLI and config: sets options
- CLI and config → Configuration keys: binds settings
- Program entry → CLI and config: executes
- CLI and config → HTTP server: starts
- HTTP server → SFTP connection: creates
- HTTP server → SFTP metrics collector: registers
- Prometheus → Metrics endpoint: scrapes
- Metrics endpoint → SFTP metrics collector: collects metrics
- HTTP server → Health endpoint: serves
- SFTP metrics collector → SFTP connection: connects and queries
- SFTP metrics collector → Filesystem capacity: emits capacity
- SFTP metrics collector → File count and size: walks paths
- SFTP connection → SSH authentication: opens SSH session
- SSH authentication → SFTP server: authenticates and dials
- SFTP connection → SFTP server: reads SFTP data
- Grafana → Prometheus: queries metrics
- Grafana → Grafana dashboard: uses dashboard
