| 16 | } |
| 17 | |
| 18 | func newSSHServerMetrics(registerer prometheus.Registerer) *sshServerMetrics { |
| 19 | failedConnectionsTotal := prometheus.NewCounter(prometheus.CounterOpts{ |
| 20 | Namespace: "agent", Subsystem: "ssh_server", Name: "failed_connections_total", |
| 21 | }) |
| 22 | registerer.MustRegister(failedConnectionsTotal) |
| 23 | |
| 24 | sftpConnectionsTotal := prometheus.NewCounter(prometheus.CounterOpts{ |
| 25 | Namespace: "agent", Subsystem: "ssh_server", Name: "sftp_connections_total", |
| 26 | }) |
| 27 | registerer.MustRegister(sftpConnectionsTotal) |
| 28 | |
| 29 | sftpServerErrors := prometheus.NewCounter(prometheus.CounterOpts{ |
| 30 | Namespace: "agent", Subsystem: "ssh_server", Name: "sftp_server_errors_total", |
| 31 | }) |
| 32 | registerer.MustRegister(sftpServerErrors) |
| 33 | |
| 34 | x11HandlerErrors := prometheus.NewCounterVec( |
| 35 | prometheus.CounterOpts{ |
| 36 | Namespace: "agent", |
| 37 | Subsystem: "x11_handler", |
| 38 | Name: "errors_total", |
| 39 | }, |
| 40 | []string{"error_type"}, |
| 41 | ) |
| 42 | registerer.MustRegister(x11HandlerErrors) |
| 43 | |
| 44 | sessionsTotal := prometheus.NewCounterVec( |
| 45 | prometheus.CounterOpts{ |
| 46 | Namespace: "agent", |
| 47 | Subsystem: "sessions", |
| 48 | Name: "total", |
| 49 | }, |
| 50 | []string{"magic_type", "pty"}, |
| 51 | ) |
| 52 | registerer.MustRegister(sessionsTotal) |
| 53 | |
| 54 | sessionErrors := prometheus.NewCounterVec( |
| 55 | prometheus.CounterOpts{ |
| 56 | Namespace: "agent", |
| 57 | Subsystem: "sessions", |
| 58 | Name: "errors_total", |
| 59 | }, |
| 60 | []string{"magic_type", "pty", "error_type"}, |
| 61 | ) |
| 62 | registerer.MustRegister(sessionErrors) |
| 63 | |
| 64 | return &sshServerMetrics{ |
| 65 | failedConnectionsTotal: failedConnectionsTotal, |
| 66 | sftpConnectionsTotal: sftpConnectionsTotal, |
| 67 | sftpServerErrors: sftpServerErrors, |
| 68 | x11HandlerErrors: x11HandlerErrors, |
| 69 | sessionsTotal: sessionsTotal, |
| 70 | sessionErrors: sessionErrors, |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | func magicTypeMetricLabel(magicType MagicSessionType) string { |
| 75 | switch magicType { |