Move prober metric GaugeOpts into prober.go to reduce copy-n-paste.
Signed-off-by: SuperQ superq@gmail.com
Help: "Response HealthCheck response",
}, []string{"serving_status"})
- probeSSLEarliestCertExpiryGauge = prometheus.NewGauge(prometheus.GaugeOpts{
- Name: "probe_ssl_earliest_cert_expiry",
- Help: helpSSLEarliestCertExpiry,
- })
+ probeSSLEarliestCertExpiryGauge = prometheus.NewGauge(sslEarliestCertExpiryGaugeOpts)
- probeTLSVersion = prometheus.NewGaugeVec(prometheus.GaugeOpts{
- Name: "probe_tls_version_info",
- Help: helpProbeTLSInfo,
- },
+ probeTLSVersion = prometheus.NewGaugeVec(
+ probeTLSInfoGaugeOpts,
[]string{"version"},
)
Help: "Response HTTP status code",
})
- probeSSLEarliestCertExpiryGauge = prometheus.NewGauge(prometheus.GaugeOpts{
- Name: "probe_ssl_earliest_cert_expiry",
- Help: helpSSLEarliestCertExpiry,
- })
+ probeSSLEarliestCertExpiryGauge = prometheus.NewGauge(sslEarliestCertExpiryGaugeOpts)
- probeSSLLastChainExpiryTimestampSeconds = prometheus.NewGauge(prometheus.GaugeOpts{
- Name: "probe_ssl_last_chain_expiry_timestamp_seconds",
- Help: helpSSLChainExpiryInTimeStamp,
- })
+ probeSSLLastChainExpiryTimestampSeconds = prometheus.NewGauge(sslChainExpiryInTimeStampGaugeOpts)
probeSSLLastInformation = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
)
probeTLSVersion = prometheus.NewGaugeVec(
- prometheus.GaugeOpts{
- Name: "probe_tls_version_info",
- Help: helpProbeTLSInfo,
- },
+ probeTLSInfoGaugeOpts,
[]string{"version"},
)
helpSSLChainExpiryInTimeStamp = "Returns last SSL chain expiry in timestamp"
helpProbeTLSInfo = "Returns the TLS version used or NaN when unknown"
)
+
+var (
+ sslEarliestCertExpiryGaugeOpts = prometheus.GaugeOpts{
+ Name: "probe_ssl_earliest_cert_expiry",
+ Help: helpSSLEarliestCertExpiry,
+ }
+
+ sslChainExpiryInTimeStampGaugeOpts = prometheus.GaugeOpts{
+ Name: "probe_ssl_last_chain_expiry_timestamp_seconds",
+ Help: helpSSLChainExpiryInTimeStamp,
+ }
+
+ probeTLSInfoGaugeOpts = prometheus.GaugeOpts{
+ Name: "probe_tls_version_info",
+ Help: helpProbeTLSInfo,
+ }
+)
}
func ProbeTCP(ctx context.Context, target string, module config.Module, registry *prometheus.Registry, logger log.Logger) bool {
- probeSSLEarliestCertExpiry := prometheus.NewGauge(prometheus.GaugeOpts{
- Name: "probe_ssl_earliest_cert_expiry",
- Help: helpSSLEarliestCertExpiry,
- })
- probeSSLLastChainExpiryTimestampSeconds := prometheus.NewGauge(prometheus.GaugeOpts{
- Name: "probe_ssl_last_chain_expiry_timestamp_seconds",
- Help: helpSSLChainExpiryInTimeStamp,
- })
+ probeSSLEarliestCertExpiry := prometheus.NewGauge(sslEarliestCertExpiryGaugeOpts)
+ probeSSLLastChainExpiryTimestampSeconds := prometheus.NewGauge(sslChainExpiryInTimeStampGaugeOpts)
probeSSLLastInformation := prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "probe_ssl_last_chain_info",
[]string{"fingerprint_sha256", "subject", "issuer", "subjectalternative"},
)
probeTLSVersion := prometheus.NewGaugeVec(
- prometheus.GaugeOpts{
- Name: "probe_tls_version_info",
- Help: helpProbeTLSInfo,
- },
+ probeTLSInfoGaugeOpts,
[]string{"version"},
)
probeFailedDueToRegex := prometheus.NewGauge(prometheus.GaugeOpts{