# raphaelthomas/ssh_transport_exporter architecture

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

- Interactive diagram: https://gitdiagram.com/raphaelthomas/ssh_transport_exporter
- Repository: https://github.com/raphaelthomas/ssh_transport_exporter

## Overview

ssh_transport_exporter is a credential-less Prometheus exporter that probes only the SSH transport layer. Prometheus sends a target to the HTTP probe endpoint; the endpoint selects a configured module, normalizes and authorizes the target, then invokes the collector and returns probe metrics. The collector runs the transport probe, which observes DNS/TCP connection, SSH version exchange, host-key verification, and key exchange. Configuration builds target policies and known_hosts callbacks. The graph follows the excerpts and README; unsampled wiring is omitted where evidence does not establish a relationship.

Main entry points: [`internal/probehttp/probehttp.go`](https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/probehttp/probehttp.go) (Probe HTTP endpoint), [`internal/config/module.go`](https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/config/module.go) (Module loading), [`internal/collector/collector.go`](https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/collector/collector.go) (Probe collector), [`main.go`](https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/main.go) (Exporter lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Exporter runtime"]
  node_main["Exporter lifecycle<br/>[main.go]"]
  node_endpoint["Probe HTTP endpoint<br/>[probehttp.go]"]
end

subgraph group_policy["Probe configuration"]
  node_module_config["Module loading<br/>[module.go]"]
  node_target_policy["Target policy<br/>[target.go]"]
  node_config_file["Config parsing<br/>[config.go]"]
  node_knownhosts["Host-key database<br/>[knownhosts.go]"]
  node_pattern_match["Pattern matching<br/>[match.go]"]
end

subgraph group_transport["SSH transport probe"]
  node_ssh_probe["Transport probe<br/>[probe.go]"]
end

subgraph group_metrics["Prometheus metrics"]
  node_collector["Probe collector<br/>[collector.go]"]
  node_metric_output["Probe metrics<br/>[collector.go]"]
end

node_prometheus(("Prometheus"))
node_ssh_target(("SSH target"))

node_prometheus -->|"requests probe"| node_endpoint
node_main -->|"registers route"| node_endpoint
node_main -->|"loads modules"| node_module_config
node_config_file -->|"parses config"| node_module_config
node_module_config -->|"builds matchers"| node_target_policy
node_module_config -->|"loads host keys"| node_knownhosts
node_knownhosts -->|"matches patterns"| node_pattern_match
node_endpoint -->|"checks target"| node_target_policy
node_endpoint -->|"registers collector"| node_collector
node_collector -->|"runs probe"| node_ssh_probe
node_ssh_probe -->|"probes transport"| node_ssh_target
node_collector -->|"emits metrics"| node_metric_output

click node_main "https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/main.go"
click node_endpoint "https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/probehttp/probehttp.go"
click node_module_config "https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/config/module.go"
click node_target_policy "https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/config/target.go"
click node_config_file "https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/config/config.go"
click node_knownhosts "https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/knownhosts/knownhosts.go"
click node_pattern_match "https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/match/match.go"
click node_collector "https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/collector/collector.go"
click node_ssh_probe "https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/probe/probe.go"
click node_metric_output "https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/collector/collector.go"

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_main,node_endpoint toneBlue
class node_module_config,node_target_policy,node_config_file,node_knownhosts,node_pattern_match toneAmber
class node_ssh_probe toneMint
class node_collector,node_metric_output toneRose
class node_prometheus,node_ssh_target toneIndigo
```

## Components

### Exporter runtime

- [Exporter lifecycle](https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/main.go): `main.go`
- [Probe HTTP endpoint](https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/probehttp/probehttp.go): `internal/probehttp/probehttp.go`

### Probe configuration

- [Module loading](https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/config/module.go): `internal/config/module.go`
- [Target policy](https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/config/target.go): `internal/config/target.go`
- [Config parsing](https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/config/config.go): `internal/config/config.go`
- [Host-key database](https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/knownhosts/knownhosts.go): `internal/knownhosts/knownhosts.go`
- [Pattern matching](https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/match/match.go): `internal/match/match.go`

### SSH transport probe

- [Transport probe](https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/probe/probe.go): `internal/probe/probe.go`

### Prometheus metrics

- [Probe collector](https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/collector/collector.go): `internal/collector/collector.go`
- [Probe metrics](https://github.com/raphaelthomas/ssh_transport_exporter/blob/main/internal/collector/collector.go): `internal/collector/collector.go`

### Other components

- **Prometheus**
- **SSH target**

## Connections

- Prometheus → Probe HTTP endpoint: requests probe (evidence: `README.md`)
- Exporter lifecycle → Probe HTTP endpoint: registers route (evidence: `main.go`)
- Exporter lifecycle → Module loading: loads modules (evidence: `main.go`)
- Config parsing → Module loading: parses config (evidence: `internal/config/module.go`)
- Module loading → Target policy: builds matchers (evidence: `internal/config/module.go`)
- Module loading → Host-key database: loads host keys (evidence: `internal/config/module.go`)
- Host-key database → Pattern matching: matches patterns (evidence: `internal/knownhosts/knownhosts.go`)
- Probe HTTP endpoint → Target policy: checks target (evidence: `internal/probehttp/probehttp.go`)
- Probe HTTP endpoint → Probe collector: registers collector (evidence: `internal/probehttp/probehttp.go`)
- Probe collector → Transport probe: runs probe (evidence: `internal/collector/collector.go`)
- Transport probe → SSH target: probes transport (evidence: `README.md`)
- Probe collector → Probe metrics: emits metrics (evidence: `internal/collector/collector.go`)
