Skip to content

Commit 458945a

Browse files
committed
Introduce metric representing N+ license expiration date
1 parent af1f3a6 commit 458945a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

collector/nginx_plus.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ func NewNginxPlusCollector(nginxClient *plusclient.NginxClient, namespace string
283283
"ssl_handshakes": newGlobalMetric(namespace, "ssl_handshakes", "Successful SSL handshakes", constLabels),
284284
"ssl_handshakes_failed": newGlobalMetric(namespace, "ssl_handshakes_failed", "Failed SSL handshakes", constLabels),
285285
"ssl_session_reuses": newGlobalMetric(namespace, "ssl_session_reuses", "Session reuses during SSL handshake", constLabels),
286+
"license_active_till": newGlobalMetric(namespace, "license_expiration_timestamp_seconds", "License expiration date (expressed as Unix Epoch Time)", constLabels),
286287
},
287288
serverZoneMetrics: map[string]*prometheus.Desc{
288289
"processing": newServerZoneMetric(namespace, "processing", "Client requests that are currently being processed", variableLabelNames.ServerZoneVariableLabelNames, constLabels),
@@ -654,6 +655,14 @@ func (c *NginxPlusCollector) Collect(ch chan<- prometheus.Metric) {
654655
ch <- prometheus.MustNewConstMetric(c.totalMetrics["ssl_session_reuses"],
655656
prometheus.CounterValue, float64(stats.SSL.SessionReuses))
656657

658+
license, err := c.nginxClient.GetNginxLicense(context.TODO())
659+
if err != nil {
660+
c.logger.Warn("error getting license information", "error", err.Error())
661+
} else {
662+
ch <- prometheus.MustNewConstMetric(c.totalMetrics["license_active_till"],
663+
prometheus.GaugeValue, float64(license.ActiveTill))
664+
}
665+
657666
for name, zone := range stats.ServerZones {
658667
labelValues := []string{name}
659668
varLabelValues := c.getServerZoneLabelValues(name)

0 commit comments

Comments
 (0)