Skip to content

Commit

Permalink
Merge pull request #10 from app-sre/rds_latestrestorabletime
Browse files Browse the repository at this point in the history
Add RDS latest restorable time metric
  • Loading branch information
jfchevrette authored Dec 3, 2019
2 parents 446907f + 2b8d1e6 commit 4daac7f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions rds.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type RDSExporter struct {
DBInstanceClass *prometheus.Desc
DBInstanceStatus *prometheus.Desc
EngineVersion *prometheus.Desc
LatestRestorableTime *prometheus.Desc
MaxConnections *prometheus.Desc
MaxConnectionsMappingError *prometheus.Desc

Expand Down Expand Up @@ -68,6 +69,12 @@ func NewRDSExporter(sess *session.Session) *RDSExporter {
[]string{"aws_region", "dbinstance_identifier", "engine", "engine_version"},
nil,
),
LatestRestorableTime: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "rds_latestrestorabletime"),
"Latest restorable time (UTC date timestamp).",
[]string{"aws_region", "dbinstance_identifier"},
nil,
),
MaxConnections: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "rds_maxconnections"),
"The DB's max_connections value",
Expand All @@ -86,8 +93,12 @@ func NewRDSExporter(sess *session.Session) *RDSExporter {
// Describe is used by the Prometheus client to return a description of the metrics
func (e *RDSExporter) Describe(ch chan<- *prometheus.Desc) {
ch <- e.AllocatedStorage
ch <- e.DBInstanceClass
ch <- e.DBInstanceStatus
ch <- e.EngineVersion
ch <- e.LatestRestorableTime
ch <- e.MaxConnections
ch <- e.MaxConnectionsMappingError
}

// Collect is used by the Prometheus client to collect and return the metrics values
Expand Down Expand Up @@ -138,5 +149,6 @@ func (e *RDSExporter) Collect(ch chan<- prometheus.Metric) {
ch <- prometheus.MustNewConstMetric(e.DBInstanceStatus, prometheus.GaugeValue, 1, *e.sess.Config.Region, *instance.DBInstanceIdentifier, *instance.DBInstanceStatus)
ch <- prometheus.MustNewConstMetric(e.EngineVersion, prometheus.GaugeValue, 1, *e.sess.Config.Region, *instance.DBInstanceIdentifier, *instance.Engine, *instance.EngineVersion)
ch <- prometheus.MustNewConstMetric(e.DBInstanceClass, prometheus.GaugeValue, 1, *e.sess.Config.Region, *instance.DBInstanceIdentifier, *instance.DBInstanceClass)
ch <- prometheus.MustNewConstMetric(e.LatestRestorableTime, prometheus.CounterValue, float64(instance.LatestRestorableTime.Unix()), *e.sess.Config.Region, *instance.DBInstanceIdentifier)
}
}

0 comments on commit 4daac7f

Please sign in to comment.