Skip to content

Commit

Permalink
Convert millis to seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
kekkker committed Dec 12, 2023
1 parent b4149e1 commit ee49b46
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
20 changes: 10 additions & 10 deletions collector/cluster_license.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,22 @@ var (
var (
licenseMaxNodes = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "cluster_license", "max_nodes"),
"The max amount of nodes allowed by the license",
"The max amount of nodes allowed by the license.",
defaultClusterLicenseLabels, nil,
)
licenseIssueDate = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "cluster_license", "issue_date_in_millis"),
"License issue date in milliseconds",
prometheus.BuildFQName(namespace, "cluster_license", "issue_date_seconds"),
"License issue date since unix epoch in seconds.",
defaultClusterLicenseLabels, nil,
)
licenseExpiryDate = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "cluster_license", "expiry_date_in_millis"),
"License expiry date in milliseconds",
prometheus.BuildFQName(namespace, "cluster_license", "expiry_date_seconds"),
"License expiry date since unix epoch in seconds.",
defaultClusterLicenseLabels, nil,
)
licenseStartDate = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "cluster_license", "start_date_in_millis"),
"License start date in milliseconds",
prometheus.BuildFQName(namespace, "cluster_license", "start_date_seconds"),
"License start date since unix epoch in seconds.",
defaultClusterLicenseLabels, nil,
)
)
Expand Down Expand Up @@ -137,21 +137,21 @@ func (c *ClusterLicense) Update(ctx context.Context, ch chan<- prometheus.Metric
ch <- prometheus.MustNewConstMetric(
licenseIssueDate,
prometheus.GaugeValue,
float64(clr.License.IssueDateInMillis),
float64(clr.License.IssueDateInMillis/1000),
defaultClusterLicenseLabelsValues(clr)...,
)

ch <- prometheus.MustNewConstMetric(
licenseExpiryDate,
prometheus.GaugeValue,
float64(clr.License.ExpiryDateInMillis),
float64(clr.License.ExpiryDateInMillis/1000),
defaultClusterLicenseLabelsValues(clr)...,
)

ch <- prometheus.MustNewConstMetric(
licenseStartDate,
prometheus.GaugeValue,
float64(clr.License.StartDateInMillis),
float64(clr.License.StartDateInMillis/1000),
defaultClusterLicenseLabelsValues(clr)...,
)

Expand Down
40 changes: 20 additions & 20 deletions collector/cluster_license_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,36 @@ func TestClusterLicense(t *testing.T) {
name: "basic",
file: "../fixtures/clusterlicense/basic.json",
want: `
# HELP elasticsearch_cluster_license_expiry_date_in_millis License expiry date in milliseconds
# TYPE elasticsearch_cluster_license_expiry_date_in_millis gauge
elasticsearch_cluster_license_expiry_date_in_millis{issued_to="redacted",issuer="elasticsearch",status="active",type="basic"} 0
# HELP elasticsearch_cluster_license_issue_date_in_millis License issue date in milliseconds
# TYPE elasticsearch_cluster_license_issue_date_in_millis gauge
elasticsearch_cluster_license_issue_date_in_millis{issued_to="redacted",issuer="elasticsearch",status="active",type="basic"} 1.702196247064e+12
# HELP elasticsearch_cluster_license_max_nodes The max amount of nodes allowed by the license
# HELP elasticsearch_cluster_license_expiry_date_seconds License expiry date since unix epoch in seconds.
# TYPE elasticsearch_cluster_license_expiry_date_seconds gauge
elasticsearch_cluster_license_expiry_date_seconds{issued_to="redacted",issuer="elasticsearch",status="active",type="basic"} 0
# HELP elasticsearch_cluster_license_issue_date_seconds License issue date since unix epoch in seconds.
# TYPE elasticsearch_cluster_license_issue_date_seconds gauge
elasticsearch_cluster_license_issue_date_seconds{issued_to="redacted",issuer="elasticsearch",status="active",type="basic"} 1.702196247e+09
# HELP elasticsearch_cluster_license_max_nodes The max amount of nodes allowed by the license.
# TYPE elasticsearch_cluster_license_max_nodes gauge
elasticsearch_cluster_license_max_nodes{issued_to="redacted",issuer="elasticsearch",status="active",type="basic"} 1000
# HELP elasticsearch_cluster_license_start_date_in_millis License start date in milliseconds
# TYPE elasticsearch_cluster_license_start_date_in_millis gauge
elasticsearch_cluster_license_start_date_in_millis{issued_to="redacted",issuer="elasticsearch",status="active",type="basic"} -1
# HELP elasticsearch_cluster_license_start_date_seconds License start date since unix epoch in seconds.
# TYPE elasticsearch_cluster_license_start_date_seconds gauge
elasticsearch_cluster_license_start_date_seconds{issued_to="redacted",issuer="elasticsearch",status="active",type="basic"} 0
`,
},
{
name: "platinum",
file: "../fixtures/clusterlicense/platinum.json",
want: `
# HELP elasticsearch_cluster_license_expiry_date_in_millis License expiry date in milliseconds
# TYPE elasticsearch_cluster_license_expiry_date_in_millis gauge
elasticsearch_cluster_license_expiry_date_in_millis{issued_to="redacted",issuer="API",status="active",type="platinum"} 1.714521599999e+12
# HELP elasticsearch_cluster_license_issue_date_in_millis License issue date in milliseconds
# TYPE elasticsearch_cluster_license_issue_date_in_millis gauge
elasticsearch_cluster_license_issue_date_in_millis{issued_to="redacted",issuer="API",status="active",type="platinum"} 1.6192224e+12
# HELP elasticsearch_cluster_license_max_nodes The max amount of nodes allowed by the license
# HELP elasticsearch_cluster_license_expiry_date_seconds License expiry date since unix epoch in seconds.
# TYPE elasticsearch_cluster_license_expiry_date_seconds gauge
elasticsearch_cluster_license_expiry_date_seconds{issued_to="redacted",issuer="API",status="active",type="platinum"} 1.714521599e+09
# HELP elasticsearch_cluster_license_issue_date_seconds License issue date since unix epoch in seconds.
# TYPE elasticsearch_cluster_license_issue_date_seconds gauge
elasticsearch_cluster_license_issue_date_seconds{issued_to="redacted",issuer="API",status="active",type="platinum"} 1.6192224e+09
# HELP elasticsearch_cluster_license_max_nodes The max amount of nodes allowed by the license.
# TYPE elasticsearch_cluster_license_max_nodes gauge
elasticsearch_cluster_license_max_nodes{issued_to="redacted",issuer="API",status="active",type="platinum"} 10
# HELP elasticsearch_cluster_license_start_date_in_millis License start date in milliseconds
# TYPE elasticsearch_cluster_license_start_date_in_millis gauge
elasticsearch_cluster_license_start_date_in_millis{issued_to="redacted",issuer="API",status="active",type="platinum"} 1.6192224e+12
# HELP elasticsearch_cluster_license_start_date_seconds License start date since unix epoch in seconds.
# TYPE elasticsearch_cluster_license_start_date_seconds gauge
elasticsearch_cluster_license_start_date_seconds{issued_to="redacted",issuer="API",status="active",type="platinum"} 1.6192224e+09
`,
},
}
Expand Down

0 comments on commit ee49b46

Please sign in to comment.