metrics

package
v1.10.0-beta.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ProcessedCerts    int64
	ProcessedPrecerts int64
	Metrics           = LogMetrics{/* contains filtered or unexported fields */}
)
View Source
var Prometheus = NewPrometheusExporter()

Functions

func GetLogOperators added in v1.9.0

func GetLogOperators() map[string][]string

GetLogOperators returns a map of operator names to a list of CT logs.

func GetProcessedCerts added in v1.9.0

func GetProcessedCerts() int64

GetProcessedCerts returns the total number of processed certificates.

func GetProcessedPrecerts added in v1.9.0

func GetProcessedPrecerts() int64

GetProcessedPrecerts returns the total number of processed precertificates.

Types

type CTCertIndex added in v1.9.0

type CTCertIndex map[string]uint64

CTCertIndex is a map of CT log urls to the last processed certficate index on the said log.

type CTMetrics added in v1.9.0

type CTMetrics map[string]OperatorMetric

CTMetrics is a map of operator names to a map of CT log urls to the number of certs processed by said log.

func GetCertMetrics added in v1.9.0

func GetCertMetrics() CTMetrics

GetCertMetrics returns a copy of the internal metrics map.

type LogMetrics added in v1.9.0

type LogMetrics struct {
	// contains filtered or unexported fields
}

LogMetrics is a struct that holds a map of metrics for each CT log grouped by operator. Metrics can be accessed and written concurrently through the Get, Set and Inc methods.

func (*LogMetrics) Get added in v1.9.0

func (m *LogMetrics) Get(operator, url string) int64

Get the metric for a given operator and ct url.

func (*LogMetrics) GetAllCTIndexes added in v1.9.0

func (m *LogMetrics) GetAllCTIndexes() CTCertIndex

GetAllCTIndexes returns a copy of the internal CT index map.

func (*LogMetrics) GetCTIndex added in v1.9.0

func (m *LogMetrics) GetCTIndex(url string) uint64

GetCTIndex returns the last cert index processed for a given CT url.

func (*LogMetrics) GetCTMetrics added in v1.9.0

func (m *LogMetrics) GetCTMetrics() CTMetrics

GetCTMetrics returns a copy of the internal metrics map.

func (*LogMetrics) Inc added in v1.9.0

func (m *LogMetrics) Inc(operator, url string, index uint64)

Inc the metric for a given operator and ct url.

func (*LogMetrics) Init added in v1.9.0

func (m *LogMetrics) Init(operator, url string)

Init initializes the internal metrics map with the given operator names and CT log urls if it doesn't exist yet.

func (*LogMetrics) LoadCTIndex added in v1.9.0

func (m *LogMetrics) LoadCTIndex(ctIndexFilePath string)

LoadCTIndex loads the last cert index processed for each CT url if it exists.

func (*LogMetrics) OperatorLogMapping added in v1.9.0

func (m *LogMetrics) OperatorLogMapping() OperatorLogs

OperatorLogMapping returns a map of operator names to a list of CT logs.

func (*LogMetrics) SaveCertIndexes added in v1.9.0

func (m *LogMetrics) SaveCertIndexes(ctIndexFilePath string) error

SaveCertIndexes saves the index of CTLogs to a file.

func (*LogMetrics) SaveCertIndexesAtInterval added in v1.9.0

func (m *LogMetrics) SaveCertIndexesAtInterval(ctx context.Context, interval time.Duration, ctIndexFilePath string)

SaveCertIndexesAtInterval saves the index of CTLogs at given intervals. We first create a temp file and write the index data to it. Only then do we move the temp file to the actual permanent index file. This prevents the last good index file from being clobbered if the program was shutdown/killed in-between the write operation.

func (*LogMetrics) Set added in v1.9.0

func (m *LogMetrics) Set(operator, url string, value int64)

Set the metric for a given operator and ct url.

func (*LogMetrics) SetCTIndex added in v1.9.0

func (m *LogMetrics) SetCTIndex(url string, index uint64)

SetCTIndex sets the index for a given CT url.

type OperatorLogs added in v1.9.0

type OperatorLogs map[string][]string

OperatorLogs is a map of operator names to a list of CT log urls, operated by said operator.

type OperatorMetric added in v1.9.0

type OperatorMetric map[string]int64

OperatorMetric is a map of CT log urls to the number of certs processed by said log.

type PrometheusExporter added in v1.9.0

type PrometheusExporter struct {
	// contains filtered or unexported fields
}

PrometheusExporter is holds the metrics for the Prometheus exporter. It also provides helper functions to register new metrics and write the metrics data to an http response.

func NewPrometheusExporter added in v1.9.0

func NewPrometheusExporter() *PrometheusExporter

NewPrometheusExporter creates a new PrometheusExporter and registers the default metrics for the number of processed certificates.

func (*PrometheusExporter) RegisterClient added in v1.9.0

func (pm *PrometheusExporter) RegisterClient(id string, skippedCertsCallback func() float64)

RegisterClient registers a new gauge metric for the client with the given name.

func (*PrometheusExporter) RegisterGaugeMetric added in v1.9.0

func (pm *PrometheusExporter) RegisterGaugeMetric(label string, callback func() float64)

RegisterGaugeMetric is a helper function that registers a new gauge metric with a float64 callback function.

func (*PrometheusExporter) RegisterGaugeMetricInt added in v1.9.0

func (pm *PrometheusExporter) RegisterGaugeMetricInt(label string, callback func() int64)

RegisterGaugeMetricInt is a helper function that registers a new gauge metric with an int64 callback function.

func (*PrometheusExporter) RegisterLog added in v1.9.0

func (pm *PrometheusExporter) RegisterLog(operatorName, url string)

RegisterLog registers a new gauge metric for the given CT log. The metric will be named "certstreamservergo_certs_by_log_total{url=\"<url>\",operator=\"<operatorName>\"}" and will call the given callback function to get the current value of the metric.

func (*PrometheusExporter) UnregisterClient added in v1.9.0

func (pm *PrometheusExporter) UnregisterClient(id string)

UnregisterClient unregisters the metric for the client with the given name.

func (*PrometheusExporter) UnregisterMetric added in v1.9.0

func (pm *PrometheusExporter) UnregisterMetric(label string)

UnregisterMetric unregisters a metric with a given label.

func (*PrometheusExporter) Write added in v1.9.0

func (pm *PrometheusExporter) Write(w io.Writer, exposeProcessMetrics bool)

Write is a callback function that is called by a webserver in order to write metrics data to the http response.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL