Skip to content

Introduce metric representing N+ license expiration date #1102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions collector/nginx_plus.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ func NewNginxPlusCollector(nginxClient *plusclient.NginxClient, namespace string
"ssl_handshakes": newGlobalMetric(namespace, "ssl_handshakes", "Successful SSL handshakes", constLabels),
"ssl_handshakes_failed": newGlobalMetric(namespace, "ssl_handshakes_failed", "Failed SSL handshakes", constLabels),
"ssl_session_reuses": newGlobalMetric(namespace, "ssl_session_reuses", "Session reuses during SSL handshake", constLabels),
"license_active_till": newGlobalMetric(namespace, "license_expiration_timestamp_seconds", "License expiration date (expressed as Unix Epoch Time)", constLabels),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would the license grace period be useful here too?

},
serverZoneMetrics: map[string]*prometheus.Desc{
"processing": newServerZoneMetric(namespace, "processing", "Client requests that are currently being processed", variableLabelNames.ServerZoneVariableLabelNames, constLabels),
Expand Down Expand Up @@ -654,6 +655,14 @@ func (c *NginxPlusCollector) Collect(ch chan<- prometheus.Metric) {
ch <- prometheus.MustNewConstMetric(c.totalMetrics["ssl_session_reuses"],
prometheus.CounterValue, float64(stats.SSL.SessionReuses))

license, err := c.nginxClient.GetNginxLicense(context.TODO())
if err != nil {
c.logger.Warn("error getting license information", "error", err.Error())
} else {
ch <- prometheus.MustNewConstMetric(c.totalMetrics["license_active_till"],
prometheus.GaugeValue, float64(license.ActiveTill))
}

for name, zone := range stats.ServerZones {
labelValues := []string{name}
varLabelValues := c.getServerZoneLabelValues(name)
Expand Down