Add external_dns_controller_last_reconcile_timestamp_seconds metric

This commit is contained in:
Philippe M. Chiasson 2023-01-25 21:24:41 -05:00
parent 8862af9377
commit 8389939f18
No known key found for this signature in database
GPG Key ID: EA867265DF46B214
2 changed files with 13 additions and 0 deletions

View File

@ -72,6 +72,14 @@ var (
Help: "Timestamp of last successful sync with the DNS provider", Help: "Timestamp of last successful sync with the DNS provider",
}, },
) )
lastReconcileTimestamp = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: "external_dns",
Subsystem: "controller",
Name: "last_reconcile_timestamp_seconds",
Help: "Timestamp of last attempted sync with the DNS provider",
},
)
controllerNoChangesTotal = prometheus.NewCounter( controllerNoChangesTotal = prometheus.NewCounter(
prometheus.CounterOpts{ prometheus.CounterOpts{
Namespace: "external_dns", Namespace: "external_dns",
@ -126,6 +134,7 @@ func init() {
prometheus.MustRegister(sourceEndpointsTotal) prometheus.MustRegister(sourceEndpointsTotal)
prometheus.MustRegister(registryEndpointsTotal) prometheus.MustRegister(registryEndpointsTotal)
prometheus.MustRegister(lastSyncTimestamp) prometheus.MustRegister(lastSyncTimestamp)
prometheus.MustRegister(lastReconcileTimestamp)
prometheus.MustRegister(deprecatedRegistryErrors) prometheus.MustRegister(deprecatedRegistryErrors)
prometheus.MustRegister(deprecatedSourceErrors) prometheus.MustRegister(deprecatedSourceErrors)
prometheus.MustRegister(controllerNoChangesTotal) prometheus.MustRegister(controllerNoChangesTotal)
@ -161,6 +170,8 @@ type Controller struct {
// RunOnce runs a single iteration of a reconciliation loop. // RunOnce runs a single iteration of a reconciliation loop.
func (c *Controller) RunOnce(ctx context.Context) error { func (c *Controller) RunOnce(ctx context.Context) error {
lastReconcileTimestamp.SetToCurrentTime()
records, err := c.Registry.Records(ctx) records, err := c.Registry.Records(ctx)
if err != nil { if err != nil {
registryErrorsTotal.Inc() registryErrorsTotal.Inc()
@ -235,6 +246,7 @@ func (c *Controller) RunOnce(ctx context.Context) error {
} }
lastSyncTimestamp.SetToCurrentTime() lastSyncTimestamp.SetToCurrentTime()
return nil return nil
} }

View File

@ -181,6 +181,7 @@ Here is the full list of available metrics provided by ExternalDNS:
| Name | Description | Type | | Name | Description | Type |
| --------------------------------------------------- | ------------------------------------------------------- | ------- | | --------------------------------------------------- | ------------------------------------------------------- | ------- |
| external_dns_controller_last_sync_timestamp_seconds | Timestamp of last successful sync with the DNS provider | Gauge | | external_dns_controller_last_sync_timestamp_seconds | Timestamp of last successful sync with the DNS provider | Gauge |
| external_dns_controller_last_reconcile_timestamp_seconds | Timestamp of last attempted sync with the DNS provider | Gauge |
| external_dns_registry_endpoints_total | Number of Endpoints in all sources | Gauge | | external_dns_registry_endpoints_total | Number of Endpoints in all sources | Gauge |
| external_dns_registry_errors_total | Number of Registry errors | Counter | | external_dns_registry_errors_total | Number of Registry errors | Counter |
| external_dns_source_endpoints_total | Number of Endpoints in the registry | Gauge | | external_dns_source_endpoints_total | Number of Endpoints in the registry | Gauge |