Documentation
¶
Overview ¶
Package metrics defines the Prometheus metrics of the operator and registers them with controller-runtime's registry, so the manager's /metrics endpoint serves them next to the controller_runtime_* and xpki metrics. Every metric is registered once in init(). The package remembers the issuer and profile labels last observed for each Certificate, so that a Certificate that moves to another issuer or profile does not leave a stale expiration series behind. The functions are safe for concurrent use by the reconcile workers.
metrics.ObserveCertificate(cert.Namespace, cert.Name, issuer, profile, ready, notAfter, renewal) metrics.ForgetCertificate(req.Namespace, req.Name) // the Certificate is gone
Index ¶
Constants ¶
const ( ResultSuccess = "success" ResultPolicyViolation = "policy_violation" ResultError = "error" )
Values of the result label of IssuanceTotal.
Variables ¶
var ( // CertificateExpiration is kubeca_certificate_expiration_timestamp_seconds. CertificateExpiration = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Name: "kubeca_certificate_expiration_timestamp_seconds", Help: "notAfter of the certificate stored for a Certificate, as a Unix time.", }, []string{"namespace", "name", "issuer", "profile"}) // CertificateRenewal is kubeca_certificate_renewal_timestamp_seconds. CertificateRenewal = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Name: "kubeca_certificate_renewal_timestamp_seconds", Help: "Time the Certificate controller will renew the certificate, as a Unix time.", }, []string{"namespace", "name"}) // CertificateReady is kubeca_certificate_ready. CertificateReady = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Name: "kubeca_certificate_ready", Help: "1 when the Certificate's Ready condition is True, else 0.", }, []string{"namespace", "name"}) // IssuanceTotal is kubeca_issuance_total. IssuanceTotal = prometheus.NewCounterVec(prometheus.CounterOpts{ Name: "kubeca_issuance_total", Help: "Issuance attempts of the Certificate controller by issuer, profile, trigger and result.", }, []string{"issuer", "profile", "trigger", "result"}) // IssuanceDuration is kubeca_issuance_duration_seconds. IssuanceDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Name: "kubeca_issuance_duration_seconds", Help: "Time from the issuance decision to the Secret write, in seconds.", Buckets: prometheus.DefBuckets, }, []string{"issuer", "profile"}) // ClusterIssuerCAExpiration is kubeca_clusterissuer_ca_expiration_timestamp_seconds. ClusterIssuerCAExpiration = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Name: "kubeca_clusterissuer_ca_expiration_timestamp_seconds", Help: "notAfter of the issuing certificate of a ClusterIssuer, as a Unix time.", }, []string{"issuer"}) )
Functions ¶
func ForgetCertificate ¶
func ForgetCertificate(namespace, name string)
ForgetCertificate drops the gauges of a deleted Certificate.
func ObserveCertificate ¶
func ObserveCertificate(namespace, name, issuer, profile string, ready bool, notAfter, renewal time.Time)
ObserveCertificate records the gauges of one Certificate. A zero notAfter or renewal (nothing issued yet) deletes that series, and an expiration series set earlier under another issuer or profile is deleted so that the old notAfter does not keep firing expiry alerts.
Types ¶
This section is empty.