Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metric to track number ssh connect attempts #11240

Merged
merged 10 commits into from
Mar 24, 2022
1 change: 1 addition & 0 deletions docs/pages/setup/reference/metrics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Now you can see the monitoring information by visiting several endpoints:
| `teleport_build_info` | gauge | Teleport | Provides build information of Teleport including gitref (git describe --long --tags), Go version, and Teleport version. The value of this gauge will always be 1. |
| `teleport_cache_events` | counter | Teleport | Number of events received by a Teleport service cache. Teleport's Auth Service, Proxy Service, and other services cache incoming events related to their service. |
| `teleport_cache_stale_events` | counter | Teleport | Number of stale events received by a Teleport service cache. A high percentage of stale events can indicate a degraded backend. |
| `teleport_connect_to_node_attempts_total` | gauge | Teleport Proxy | Number of ssh connection attempts to a node. |
| `teleport_connected_resources` | gauge | Teleport Auth | Tracks the number and type of resources connected via keepalives. |
| `teleport_registered_servers` | gauge | Teleport Auth | The number of Teleport servers (a server consists of one or more Teleport services) that have connected to the Teleport cluster, including the Teleport version. After disconnecting, a Teleport server has a TTL of 10 minutes, so this value will include servers that have recently disconnected but have not reached their TTL. |
| `teleport_reverse_tunnels_connected` | gauge | Teleport Proxy | Number of reverse SSH tunnels connected to the Teleport Proxy Service by Teleport instances. |
Expand Down
11 changes: 10 additions & 1 deletion lib/srv/regular/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,15 @@ var ( // failedConnectingToNode counts failed attempts to connect to a node
},
)

prometheusCollectors = []prometheus.Collector{proxiedSessions, failedConnectingToNode}
connectingToNode = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: teleport.MetricNamespace,
Name: teleport.MetricConnectToNodeAttempts,
Help: "Number of ssh connection attempts to a node.",
rcanderson23 marked this conversation as resolved.
Show resolved Hide resolved
},
)

prometheusCollectors = []prometheus.Collector{proxiedSessions, failedConnectingToNode, connectingToNode}
)

// proxySubsys implements an SSH subsystem for proxying listening sockets from
Expand Down Expand Up @@ -405,6 +413,7 @@ func (t *proxySubsys) proxyToHost(
AddrNetwork: "tcp",
Addr: serverAddr,
}
connectingToNode.Inc()
conn, err := site.Dial(reversetunnel.DialParams{
From: remoteAddr,
To: toAddr,
Expand Down
3 changes: 3 additions & 0 deletions metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ const (
// MetricFailedLoginAttempts counts failed login attempts
MetricFailedLoginAttempts = "failed_login_attempts_total"

// MetricConnectToNodeAttempts counts ssh attempts
MetricConnectToNodeAttempts = "connect_to_node_attempts_total"

// MetricFailedConnectToNodeAttempts counts failed ssh attempts
MetricFailedConnectToNodeAttempts = "failed_connect_to_node_attempts_total"

Expand Down