|
|
|
@ -9,64 +9,34 @@ import (
|
|
|
|
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// New initializes and returns a new [Meter].
|
|
|
|
|
func New() (m *Meter) {
|
|
|
|
|
m = new(Meter)
|
|
|
|
|
|
|
|
|
|
m.signatures.ssh = prometheus.NewCounterVec(
|
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
|
Namespace: "step_ca",
|
|
|
|
|
Subsystem: "ssh",
|
|
|
|
|
Name: "signatures_total",
|
|
|
|
|
Help: "Number of SSH CSRs signed",
|
|
|
|
|
m = &Meter{
|
|
|
|
|
x509: signatures{
|
|
|
|
|
signed: newCounterVec("x509", "signed_total", "Number of X509 CSRs signed",
|
|
|
|
|
"provisioner",
|
|
|
|
|
),
|
|
|
|
|
renewed: newCounterVec("x509", "renewed_total", "Number of X509 certificates renewed",
|
|
|
|
|
"provisioner",
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
[]string{
|
|
|
|
|
"provider",
|
|
|
|
|
ssh: signatures{
|
|
|
|
|
signed: newCounterVec("ssh", "signed_total", "Number of SSH CSRs signed",
|
|
|
|
|
"provisioner",
|
|
|
|
|
),
|
|
|
|
|
renewed: newCounterVec("ssh", "renewed_total", "Number of SSH certificates renewed",
|
|
|
|
|
"provisioner",
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
m.renewals.ssh = prometheus.NewCounterVec(
|
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
|
Namespace: "step_ca",
|
|
|
|
|
Subsystem: "ssh",
|
|
|
|
|
Name: "renewals_total",
|
|
|
|
|
Help: "Number of SSH renewals",
|
|
|
|
|
},
|
|
|
|
|
[]string{
|
|
|
|
|
"provider",
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
m.signatures.x509 = prometheus.NewCounterVec(
|
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
|
Namespace: "step_ca",
|
|
|
|
|
Subsystem: "x509",
|
|
|
|
|
Name: "signatures_total",
|
|
|
|
|
Help: "Number of X509 CSRs signed",
|
|
|
|
|
},
|
|
|
|
|
[]string{
|
|
|
|
|
"provider",
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
m.renewals.x509 = prometheus.NewCounterVec(
|
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
|
Namespace: "step_ca",
|
|
|
|
|
Subsystem: "x509",
|
|
|
|
|
Name: "renewals_total",
|
|
|
|
|
Help: "Number of X509 renewals",
|
|
|
|
|
},
|
|
|
|
|
[]string{
|
|
|
|
|
"provider",
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reg := prometheus.NewRegistry()
|
|
|
|
|
|
|
|
|
|
reg.MustRegister(
|
|
|
|
|
m.signatures.ssh,
|
|
|
|
|
m.signatures.x509,
|
|
|
|
|
m.renewals.ssh,
|
|
|
|
|
m.renewals.x509,
|
|
|
|
|
m.x509.renewed,
|
|
|
|
|
m.x509.signed,
|
|
|
|
|
m.ssh.signed,
|
|
|
|
|
m.ssh.renewed,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
h := promhttp.HandlerFor(reg, promhttp.HandlerOpts{
|
|
|
|
@ -86,23 +56,40 @@ func New() (m *Meter) {
|
|
|
|
|
type Meter struct {
|
|
|
|
|
http.Handler
|
|
|
|
|
|
|
|
|
|
signatures struct {
|
|
|
|
|
x509 *prometheus.CounterVec // X509 CSRs signed
|
|
|
|
|
ssh *prometheus.CounterVec // SSH CSRs signed
|
|
|
|
|
}
|
|
|
|
|
x509 signatures
|
|
|
|
|
ssh signatures
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renewals struct {
|
|
|
|
|
x509 *prometheus.CounterVec // X509 renewals
|
|
|
|
|
ssh *prometheus.CounterVec // SSH renewals
|
|
|
|
|
}
|
|
|
|
|
type signatures struct {
|
|
|
|
|
signed *prometheus.CounterVec
|
|
|
|
|
renewed *prometheus.CounterVec
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// X509Signed implements [authority.Meter] for [Meter].
|
|
|
|
|
func (m *Meter) X509Signed(provisioner string) {
|
|
|
|
|
m.x509.signed.WithLabelValues(provisioner).Inc()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// X509Renewed implements [authority.Meter] for [Meter].
|
|
|
|
|
func (m *Meter) X509Renewed(provisioner string) {
|
|
|
|
|
m.x509.renewed.WithLabelValues(provisioner).Inc()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SSHSigned implements [authority.Meter] for [Meter].
|
|
|
|
|
func (m *Meter) SSHSigned(provisioner string) {
|
|
|
|
|
m.ssh.signed.WithLabelValues(provisioner).Inc()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// X509Signatures implements [authority.Meter] for [Meter].
|
|
|
|
|
func (m *Meter) X509Signatures(provisioner string) {
|
|
|
|
|
m.signatures.x509.WithLabelValues(provisioner).Inc()
|
|
|
|
|
// SSHRenewed implements [authority.Meter] for [Meter].
|
|
|
|
|
func (m *Meter) SSHRenewed(provisioner string) {
|
|
|
|
|
m.ssh.renewed.WithLabelValues(provisioner).Inc()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SSHSignatures implements [authority.Meter] for [Meter].
|
|
|
|
|
func (m *Meter) SSHSignatures(provisioner string) {
|
|
|
|
|
m.signatures.ssh.WithLabelValues(provisioner).Inc()
|
|
|
|
|
func newCounterVec(subsystem, name, help string, labels ...string) *prometheus.CounterVec {
|
|
|
|
|
return prometheus.NewCounterVec(prometheus.CounterOpts{
|
|
|
|
|
Namespace: "step_ca",
|
|
|
|
|
Subsystem: subsystem,
|
|
|
|
|
Name: name,
|
|
|
|
|
Help: help,
|
|
|
|
|
}, labels)
|
|
|
|
|
}
|
|
|
|
|