From 4b4cbf051631eac692dda96ffffa781d3efa22db Mon Sep 17 00:00:00 2001 From: Takeshi NAMAO Date: Wed, 7 Feb 2024 18:07:11 +0900 Subject: [PATCH 1/6] =?UTF-8?q?Sora=20=E3=83=A9=E3=82=A4=E3=82=BB=E3=83=B3?= =?UTF-8?q?=E3=82=B9=E6=9C=9F=E9=99=90=E3=81=AE=E3=82=BF=E3=82=A4=E3=83=A0?= =?UTF-8?q?=E3=82=B9=E3=82=BF=E3=83=B3=E3=83=97=E3=81=A8=E3=82=B7=E3=82=B9?= =?UTF-8?q?=E3=83=86=E3=83=A0=E6=99=82=E9=96=93=E3=82=92=E3=83=A1=E3=83=88?= =?UTF-8?q?=E3=83=AA=E3=82=AF=E3=82=B9=E3=81=AB=E8=BF=BD=E5=8A=A0=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- collector/collector.go | 27 +++++++++++++++++++++++++-- collector/license.go | 36 +++++++++++++++++++++++++++++------- main.go | 7 +++++-- 3 files changed, 59 insertions(+), 11 deletions(-) diff --git a/collector/collector.go b/collector/collector.go index 1a99b56..301d33c 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -14,12 +14,17 @@ import ( "github.com/prometheus/client_golang/prometheus" ) +var ( + freezedTimeSeconds = float64(time.Date(2024, 1, 7, 17, 41, 31, 312389, time.UTC).UnixNano()) / 1e9 +) + type Collector struct { mutex sync.RWMutex logger log.Logger timeout time.Duration URI string skipSslVerify bool + freezeTimeSeconds bool enableSoraClientMetrics bool enableSoraConnectionErrorMetrics bool enableErlangVMMetrics bool @@ -27,6 +32,8 @@ type Collector struct { soraUp *prometheus.Desc soraVersionInfo *prometheus.Desc + soraTimeSeconds *prometheus.Desc + ConnectionMetrics WebhookMetrics ClientMetrics @@ -40,6 +47,7 @@ type CollectorOptions struct { URI string SkipSslVerify bool Timeout time.Duration + FreezeTimeSeconds bool Logger log.Logger EnableSoraClientMetrics bool EnableSoraConnectionErrorMetrics bool @@ -62,13 +70,19 @@ func NewCollector(options *CollectorOptions) *Collector { skipSslVerify: options.SkipSslVerify, logger: options.Logger, + // for testing + freezeTimeSeconds: options.FreezeTimeSeconds, + enableSoraClientMetrics: options.EnableSoraClientMetrics, enableSoraConnectionErrorMetrics: options.EnableSoraConnectionErrorMetrics, enableErlangVMMetrics: options.EnableErlangVMMetrics, EnableSoraClusterMetrics: options.EnableSoraClusterMetrics, - soraUp: newDesc("up", "Whether the last scrape of metrics from Sora was able to connect to the server (1 for yes, 0 for no)."), - soraVersionInfo: newDescWithLabel("version_info", "sora version info.", []string{"version"}), + soraUp: newDesc("up", "Whether the last scrape of metrics from Sora was able to connect to the server (1 for yes, 0 for no)."), + soraVersionInfo: newDescWithLabel("version_info", "sora version info.", []string{"version"}), + // same as node expoter's node_time_seconds + soraTimeSeconds: newDesc("time_seconds", "HELP time_seconds System time in seconds since epoch."), + ConnectionMetrics: connectionMetrics, WebhookMetrics: webhookMetrics, ClientMetrics: clientMetrics, @@ -175,6 +189,14 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) { ch <- newGauge(c.soraUp, 1) ch <- newGauge(c.soraVersionInfo, 1, report.SoraVersion) + + if c.freezeTimeSeconds { + ch <- newGauge(c.soraTimeSeconds, freezedTimeSeconds) + } else { + nowSec := float64(time.Now().UnixNano()) / 1e9 + ch <- newGauge(c.soraTimeSeconds, nowSec) + } + c.LicenseMetrics.Collect(ch, licenseInfo) c.ConnectionMetrics.Collect(ch, report.soraConnectionReport) c.WebhookMetrics.Collect(ch, report.soraWebhookReport) @@ -196,6 +218,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) { func (c *Collector) Describe(ch chan<- *prometheus.Desc) { ch <- c.soraUp ch <- c.soraVersionInfo + ch <- c.soraTimeSeconds c.LicenseMetrics.Describe(ch) c.ConnectionMetrics.Describe(ch) c.WebhookMetrics.Describe(ch) diff --git a/collector/license.go b/collector/license.go index 0606b35..f554f4f 100644 --- a/collector/license.go +++ b/collector/license.go @@ -1,25 +1,32 @@ package collector -import "github.com/prometheus/client_golang/prometheus" +import ( + "time" + + "github.com/prometheus/client_golang/prometheus" +) var ( licenseMetrics = LicenseMetrics{ - licenseInfo: newDescWithLabel("license_info", "sora license info.", []string{"expired_at", "product_name", "serial_code", "type"}), - licenseMaxConnections: newDesc("license_max_connections", "sora license file's max_connections."), - licenseMaxNodes: newDesc("license_max_nodes", "sora license file's max_nodes."), + licenseInfo: newDescWithLabel("license_info", "sora license info.", []string{"expired_at", "product_name", "serial_code", "type"}), + licenseMaxConnections: newDesc("license_max_connections", "sora license file's max_connections."), + licenseMaxNodes: newDesc("license_max_nodes", "sora license file's max_nodes."), + licenseExpiredAtTimestampSeconds: newDesc("license_expired_at_timestamp_seconds", "sora license file's expired at."), } ) type LicenseMetrics struct { - licenseInfo *prometheus.Desc - licenseMaxConnections *prometheus.Desc - licenseMaxNodes *prometheus.Desc + licenseInfo *prometheus.Desc + licenseMaxConnections *prometheus.Desc + licenseMaxNodes *prometheus.Desc + licenseExpiredAtTimestampSeconds *prometheus.Desc } func (m *LicenseMetrics) Describe(ch chan<- *prometheus.Desc) { ch <- m.licenseInfo ch <- m.licenseMaxConnections ch <- m.licenseMaxNodes + ch <- m.licenseExpiredAtTimestampSeconds } func (m *LicenseMetrics) Collect(ch chan<- prometheus.Metric, info soraLicenseInfo) { @@ -28,4 +35,19 @@ func (m *LicenseMetrics) Collect(ch chan<- prometheus.Metric, info soraLicenseIn if info.MaxNodes != nil { ch <- newGauge(m.licenseMaxNodes, float64(*info.MaxNodes)) } + + expiredAtSec := expiredAtToSecondSinceEpoch(info.ExpiredAt) + ch <- newGauge(m.licenseExpiredAtTimestampSeconds, expiredAtSec) +} + +func expiredAtToSecondSinceEpoch(expiredAt string) float64 { + // expiredAt: "2024-12" + expiredAtTime, err := time.Parse("2006-01", expiredAt) + if err != nil { + return 0 + } + + // 期限翌月の 1 日 0 時 0 分0 秒の 1 秒前 + expiredTimestamp := time.Date(expiredAtTime.Year(), expiredAtTime.Month()+1, 1, 0, 0, 0, 0, time.UTC).Add(-time.Second) + return float64(expiredTimestamp.UnixNano()) / 1e9 } diff --git a/main.go b/main.go index ea3c774..c6be469 100644 --- a/main.go +++ b/main.go @@ -86,6 +86,7 @@ type handler struct { soraAPIURL string soraSkipSslVeirfy bool soraTimeout time.Duration + soraFreezeTimeSeconds bool enableSoraClientMetrics bool enableSoraConnectionErrorMetrics bool enableErlangVMMetrics bool @@ -94,7 +95,7 @@ type handler struct { func newHandler( includeExporterMetrics bool, maxRequests int, logger log.Logger, - soraAPIURL string, soraSkipSslVeirfy bool, soraTimeout time.Duration, + soraAPIURL string, soraSkipSslVeirfy bool, soraTimeout time.Duration, soraFreezeTimeSeconds bool, enableSoraClientMetrics bool, enableSoraConnectionErrorMetrics bool, enableErlangVMMetrics bool, enableSoraClusterMetrics bool) *handler { h := &handler{ @@ -105,6 +106,7 @@ func newHandler( soraAPIURL: soraAPIURL, soraSkipSslVeirfy: soraSkipSslVeirfy, soraTimeout: soraTimeout, + soraFreezeTimeSeconds: soraFreezeTimeSeconds, enableSoraClientMetrics: enableSoraClientMetrics, enableSoraConnectionErrorMetrics: enableSoraConnectionErrorMetrics, enableErlangVMMetrics: enableErlangVMMetrics, @@ -132,6 +134,7 @@ func (h *handler) innerHandler() http.Handler { URI: h.soraAPIURL, SkipSslVerify: h.soraSkipSslVeirfy, Timeout: h.soraTimeout, + FreezeTimeSeconds: h.soraFreezeTimeSeconds, Logger: h.logger, EnableSoraClientMetrics: h.enableSoraClientMetrics, EnableSoraConnectionErrorMetrics: h.enableSoraConnectionErrorMetrics, @@ -185,7 +188,7 @@ func main() { }) soraHandler := newHandler( !*disableExporterMetrics, *maxRequests, logger, - *soraAPIURL, *soraSkipSslVeirfy, *soraTimeout, + *soraAPIURL, *soraSkipSslVeirfy, *soraTimeout, false, *enableSoraClientMetrics, *enableSoraConnectionErrorMetrics, *enableErlangVMMetrics, *enableSoraClusterMetrics) http.Handle(*metricsPath, soraHandler) From 0e62b424eb2e0684778278bfe196b1d87299bed5 Mon Sep 17 00:00:00 2001 From: Takeshi NAMAO Date: Wed, 7 Feb 2024 18:09:51 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B3?= =?UTF-8?q?=E3=83=BC=E3=83=89=E3=82=92=E3=83=A9=E3=82=A4=E3=82=BB=E3=83=B3?= =?UTF-8?q?=E3=82=B9=E6=9C=9F=E9=99=90=E3=81=A8=E3=82=B7=E3=82=B9=E3=83=86?= =?UTF-8?q?=E3=83=A0=E6=99=82=E9=96=93=E3=81=AB=E5=AF=BE=E5=BF=9C=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main_test.go | 8 ++++++++ test/maximum.metrics | 6 ++++++ test/minimum.metrics | 6 ++++++ test/sora_client_enabled.metrics | 6 ++++++ test/sora_cluster_metrics_enabled.metrics | 6 ++++++ test/sora_connection_error_enabled.metrics | 6 ++++++ test/sora_erlang_vm_enabled.metrics | 6 ++++++ 7 files changed, 44 insertions(+) diff --git a/main_test.go b/main_test.go index 1516b87..a43c6e5 100644 --- a/main_test.go +++ b/main_test.go @@ -280,6 +280,7 @@ func TestInvalidConfig(t *testing.T) { URI: s.URL, SkipSslVerify: true, Timeout: timeout, + FreezeTimeSeconds: true, Logger: log.NewNopLogger(), EnableSoraClientMetrics: true, EnableSoraConnectionErrorMetrics: true, @@ -298,6 +299,7 @@ func TestMaximumMetrics(t *testing.T) { URI: s.URL, SkipSslVerify: true, Timeout: timeout, + FreezeTimeSeconds: true, Logger: log.NewNopLogger(), EnableSoraClientMetrics: true, EnableSoraConnectionErrorMetrics: true, @@ -316,6 +318,7 @@ func TestSoraErlangVMEnabledMetrics(t *testing.T) { URI: s.URL, SkipSslVerify: true, Timeout: timeout, + FreezeTimeSeconds: true, Logger: log.NewNopLogger(), EnableSoraClientMetrics: false, EnableSoraConnectionErrorMetrics: false, @@ -334,6 +337,7 @@ func TestSoraClientEnabledMetrics(t *testing.T) { URI: s.URL, SkipSslVerify: true, Timeout: timeout, + FreezeTimeSeconds: true, Logger: log.NewNopLogger(), EnableSoraClientMetrics: true, EnableSoraConnectionErrorMetrics: false, @@ -352,6 +356,7 @@ func TestSoraConnectionErrorEnabledMetrics(t *testing.T) { URI: s.URL, SkipSslVerify: true, Timeout: timeout, + FreezeTimeSeconds: true, Logger: log.NewNopLogger(), EnableSoraClientMetrics: false, EnableSoraConnectionErrorMetrics: true, @@ -395,6 +400,7 @@ func TestMinimumMetrics(t *testing.T) { URI: s.URL, SkipSslVerify: true, Timeout: timeout, + FreezeTimeSeconds: true, Logger: log.NewNopLogger(), EnableSoraClientMetrics: false, EnableSoraConnectionErrorMetrics: false, @@ -413,6 +419,7 @@ func TestSoraClusterEnabledMetrics(t *testing.T) { URI: s.URL, SkipSslVerify: true, Timeout: timeout, + FreezeTimeSeconds: true, Logger: log.NewNopLogger(), EnableSoraClientMetrics: false, EnableSoraConnectionErrorMetrics: false, @@ -432,6 +439,7 @@ func TestSoraClusterEnabledMetricsCurrentJsonData(t *testing.T) { URI: s.URL, SkipSslVerify: true, Timeout: timeout, + FreezeTimeSeconds: true, Logger: log.NewNopLogger(), EnableSoraClientMetrics: false, EnableSoraConnectionErrorMetrics: false, diff --git a/test/maximum.metrics b/test/maximum.metrics index fc7d4fa..1f72329 100644 --- a/test/maximum.metrics +++ b/test/maximum.metrics @@ -147,6 +147,9 @@ sora_erlang_vm_wall_clock_wallclock_time_since_last_call 9090 # TYPE sora_event_webhook_total counter sora_event_webhook_total{state="failed"} 94 sora_event_webhook_total{state="successful"} 97 +# HELP sora_license_expired_at_timestamp_seconds sora license file's expired at. +# TYPE sora_license_expired_at_timestamp_seconds gauge +sora_license_expired_at_timestamp_seconds 1.759276799e+09 # HELP sora_license_info sora license info. # TYPE sora_license_info gauge sora_license_info{expired_at="2025-09",product_name="Sora",serial_code="EXPORTER-SRA-E001-202509-N10-100",type="Experimental"} 1 @@ -174,6 +177,9 @@ sora_session_webhook_total{state="successful"} 98 # TYPE sora_successful_auth_webhook_total counter sora_successful_auth_webhook_total{state="allowed"} 91 sora_successful_auth_webhook_total{state="denied"} 92 +# HELP sora_time_seconds HELP time_seconds System time in seconds since epoch. +# TYPE sora_time_seconds gauge +sora_time_seconds 1.7046492910003123e+09 # HELP sora_turn_connections_total The total number of connections with TURN. # TYPE sora_turn_connections_total counter sora_turn_connections_total{proto="tcp"} 2 diff --git a/test/minimum.metrics b/test/minimum.metrics index 4a1a988..6d19caa 100644 --- a/test/minimum.metrics +++ b/test/minimum.metrics @@ -22,6 +22,9 @@ sora_duration_seconds_total 1412 # TYPE sora_event_webhook_total counter sora_event_webhook_total{state="failed"} 94 sora_event_webhook_total{state="successful"} 97 +# HELP sora_license_expired_at_timestamp_seconds sora license file's expired at. +# TYPE sora_license_expired_at_timestamp_seconds gauge +sora_license_expired_at_timestamp_seconds 1.759276799e+09 # HELP sora_license_info sora license info. # TYPE sora_license_info gauge sora_license_info{expired_at="2025-09",product_name="Sora",serial_code="EXPORTER-SRA-E001-202509-N10-100",type="Experimental"} 1 @@ -46,6 +49,9 @@ sora_session_webhook_total{state="successful"} 98 # TYPE sora_successful_auth_webhook_total counter sora_successful_auth_webhook_total{state="allowed"} 91 sora_successful_auth_webhook_total{state="denied"} 92 +# HELP sora_time_seconds HELP time_seconds System time in seconds since epoch. +# TYPE sora_time_seconds gauge +sora_time_seconds 1.7046492910003123e+09 # HELP sora_turn_connections_total The total number of connections with TURN. # TYPE sora_turn_connections_total counter sora_turn_connections_total{proto="tcp"} 444 diff --git a/test/sora_client_enabled.metrics b/test/sora_client_enabled.metrics index 34fb87e..f324866 100644 --- a/test/sora_client_enabled.metrics +++ b/test/sora_client_enabled.metrics @@ -48,6 +48,9 @@ sora_duration_seconds_total 1412 # TYPE sora_event_webhook_total counter sora_event_webhook_total{state="failed"} 94 sora_event_webhook_total{state="successful"} 97 +# HELP sora_license_expired_at_timestamp_seconds sora license file's expired at. +# TYPE sora_license_expired_at_timestamp_seconds gauge +sora_license_expired_at_timestamp_seconds 1.759276799e+09 # HELP sora_license_info sora license info. # TYPE sora_license_info gauge sora_license_info{expired_at="2025-09",product_name="Sora",serial_code="EXPORTER-SRA-E001-202509-N10-100",type="Experimental"} 1 @@ -75,6 +78,9 @@ sora_session_webhook_total{state="successful"} 98 # TYPE sora_successful_auth_webhook_total counter sora_successful_auth_webhook_total{state="allowed"} 91 sora_successful_auth_webhook_total{state="denied"} 92 +# HELP sora_time_seconds HELP time_seconds System time in seconds since epoch. +# TYPE sora_time_seconds gauge +sora_time_seconds 1.7046492910003123e+09 # HELP sora_turn_connections_total The total number of connections with TURN. # TYPE sora_turn_connections_total counter sora_turn_connections_total{proto="tcp"} 2 diff --git a/test/sora_cluster_metrics_enabled.metrics b/test/sora_cluster_metrics_enabled.metrics index 757e071..7697d50 100644 --- a/test/sora_cluster_metrics_enabled.metrics +++ b/test/sora_cluster_metrics_enabled.metrics @@ -36,6 +36,9 @@ sora_duration_seconds_total 1412 # TYPE sora_event_webhook_total counter sora_event_webhook_total{state="failed"} 94 sora_event_webhook_total{state="successful"} 97 +# HELP sora_license_expired_at_timestamp_seconds sora license file's expired at. +# TYPE sora_license_expired_at_timestamp_seconds gauge +sora_license_expired_at_timestamp_seconds 1.759276799e+09 # HELP sora_license_info sora license info. # TYPE sora_license_info gauge sora_license_info{expired_at="2025-09",product_name="Sora",serial_code="EXPORTER-SRA-E001-202509-N10-100",type="Experimental"} 1 @@ -63,6 +66,9 @@ sora_session_webhook_total{state="successful"} 98 # TYPE sora_successful_auth_webhook_total counter sora_successful_auth_webhook_total{state="allowed"} 91 sora_successful_auth_webhook_total{state="denied"} 92 +# HELP sora_time_seconds HELP time_seconds System time in seconds since epoch. +# TYPE sora_time_seconds gauge +sora_time_seconds 1.7046492910003123e+09 # HELP sora_turn_connections_total The total number of connections with TURN. # TYPE sora_turn_connections_total counter sora_turn_connections_total{proto="tcp"} 2 diff --git a/test/sora_connection_error_enabled.metrics b/test/sora_connection_error_enabled.metrics index 99ac654..704a691 100644 --- a/test/sora_connection_error_enabled.metrics +++ b/test/sora_connection_error_enabled.metrics @@ -26,6 +26,9 @@ sora_duration_seconds_total 1412 # TYPE sora_event_webhook_total counter sora_event_webhook_total{state="failed"} 94 sora_event_webhook_total{state="successful"} 97 +# HELP sora_license_expired_at_timestamp_seconds sora license file's expired at. +# TYPE sora_license_expired_at_timestamp_seconds gauge +sora_license_expired_at_timestamp_seconds 1.759276799e+09 # HELP sora_license_info sora license info. # TYPE sora_license_info gauge sora_license_info{expired_at="2025-09",product_name="Sora",serial_code="EXPORTER-SRA-E001-202509-N10-100",type="Experimental"} 1 @@ -53,6 +56,9 @@ sora_session_webhook_total{state="successful"} 98 # TYPE sora_successful_auth_webhook_total counter sora_successful_auth_webhook_total{state="allowed"} 91 sora_successful_auth_webhook_total{state="denied"} 92 +# HELP sora_time_seconds HELP time_seconds System time in seconds since epoch. +# TYPE sora_time_seconds gauge +sora_time_seconds 1.7046492910003123e+09 # HELP sora_turn_connections_total The total number of connections with TURN. # TYPE sora_turn_connections_total counter sora_turn_connections_total{proto="tcp"} 2 diff --git a/test/sora_erlang_vm_enabled.metrics b/test/sora_erlang_vm_enabled.metrics index 9b4e0df..e9f667b 100644 --- a/test/sora_erlang_vm_enabled.metrics +++ b/test/sora_erlang_vm_enabled.metrics @@ -103,6 +103,9 @@ sora_erlang_vm_wall_clock_wallclock_time_since_last_call 9090 # TYPE sora_event_webhook_total counter sora_event_webhook_total{state="failed"} 94 sora_event_webhook_total{state="successful"} 97 +# HELP sora_license_expired_at_timestamp_seconds sora license file's expired at. +# TYPE sora_license_expired_at_timestamp_seconds gauge +sora_license_expired_at_timestamp_seconds 1.759276799e+09 # HELP sora_license_info sora license info. # TYPE sora_license_info gauge sora_license_info{expired_at="2025-09",product_name="Sora",serial_code="EXPORTER-SRA-E001-202509-N10-100",type="Experimental"} 1 @@ -130,6 +133,9 @@ sora_session_webhook_total{state="successful"} 98 # TYPE sora_successful_auth_webhook_total counter sora_successful_auth_webhook_total{state="allowed"} 91 sora_successful_auth_webhook_total{state="denied"} 92 +# HELP sora_time_seconds HELP time_seconds System time in seconds since epoch. +# TYPE sora_time_seconds gauge +sora_time_seconds 1.7046492910003123e+09 # HELP sora_turn_connections_total The total number of connections with TURN. # TYPE sora_turn_connections_total counter sora_turn_connections_total{proto="tcp"} 2 From 795f3e9326bf8253830f6b20a5606ebdc37260ee Mon Sep 17 00:00:00 2001 From: Takeshi NAMAO Date: Thu, 8 Feb 2024 11:40:33 +0900 Subject: [PATCH 3/6] =?UTF-8?q?metrics=20=E3=81=AE=20HELP=20=E3=81=AE?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E3=82=92=E4=BF=AE=E6=AD=A3=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- collector/collector.go | 2 +- collector/license.go | 2 +- test/maximum.metrics | 4 ++-- test/minimum.metrics | 4 ++-- test/sora_client_enabled.metrics | 4 ++-- test/sora_cluster_metrics_enabled.metrics | 4 ++-- test/sora_connection_error_enabled.metrics | 4 ++-- test/sora_erlang_vm_enabled.metrics | 4 ++-- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/collector/collector.go b/collector/collector.go index 301d33c..e0774af 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -81,7 +81,7 @@ func NewCollector(options *CollectorOptions) *Collector { soraUp: newDesc("up", "Whether the last scrape of metrics from Sora was able to connect to the server (1 for yes, 0 for no)."), soraVersionInfo: newDescWithLabel("version_info", "sora version info.", []string{"version"}), // same as node expoter's node_time_seconds - soraTimeSeconds: newDesc("time_seconds", "HELP time_seconds System time in seconds since epoch."), + soraTimeSeconds: newDesc("time_seconds", "System time in seconds since epoch."), ConnectionMetrics: connectionMetrics, WebhookMetrics: webhookMetrics, diff --git a/collector/license.go b/collector/license.go index f554f4f..8cdfaa0 100644 --- a/collector/license.go +++ b/collector/license.go @@ -11,7 +11,7 @@ var ( licenseInfo: newDescWithLabel("license_info", "sora license info.", []string{"expired_at", "product_name", "serial_code", "type"}), licenseMaxConnections: newDesc("license_max_connections", "sora license file's max_connections."), licenseMaxNodes: newDesc("license_max_nodes", "sora license file's max_nodes."), - licenseExpiredAtTimestampSeconds: newDesc("license_expired_at_timestamp_seconds", "sora license file's expired at."), + licenseExpiredAtTimestampSeconds: newDesc("license_expired_at_timestamp_seconds", "sora license file's expire seconds since epoch."), } ) diff --git a/test/maximum.metrics b/test/maximum.metrics index 1f72329..8361fee 100644 --- a/test/maximum.metrics +++ b/test/maximum.metrics @@ -147,7 +147,7 @@ sora_erlang_vm_wall_clock_wallclock_time_since_last_call 9090 # TYPE sora_event_webhook_total counter sora_event_webhook_total{state="failed"} 94 sora_event_webhook_total{state="successful"} 97 -# HELP sora_license_expired_at_timestamp_seconds sora license file's expired at. +# HELP sora_license_expired_at_timestamp_seconds sora license file's expire seconds since epoch. # TYPE sora_license_expired_at_timestamp_seconds gauge sora_license_expired_at_timestamp_seconds 1.759276799e+09 # HELP sora_license_info sora license info. @@ -177,7 +177,7 @@ sora_session_webhook_total{state="successful"} 98 # TYPE sora_successful_auth_webhook_total counter sora_successful_auth_webhook_total{state="allowed"} 91 sora_successful_auth_webhook_total{state="denied"} 92 -# HELP sora_time_seconds HELP time_seconds System time in seconds since epoch. +# HELP sora_time_seconds System time in seconds since epoch. # TYPE sora_time_seconds gauge sora_time_seconds 1.7046492910003123e+09 # HELP sora_turn_connections_total The total number of connections with TURN. diff --git a/test/minimum.metrics b/test/minimum.metrics index 6d19caa..6be8558 100644 --- a/test/minimum.metrics +++ b/test/minimum.metrics @@ -22,7 +22,7 @@ sora_duration_seconds_total 1412 # TYPE sora_event_webhook_total counter sora_event_webhook_total{state="failed"} 94 sora_event_webhook_total{state="successful"} 97 -# HELP sora_license_expired_at_timestamp_seconds sora license file's expired at. +# HELP sora_license_expired_at_timestamp_seconds sora license file's expire seconds since epoch. # TYPE sora_license_expired_at_timestamp_seconds gauge sora_license_expired_at_timestamp_seconds 1.759276799e+09 # HELP sora_license_info sora license info. @@ -49,7 +49,7 @@ sora_session_webhook_total{state="successful"} 98 # TYPE sora_successful_auth_webhook_total counter sora_successful_auth_webhook_total{state="allowed"} 91 sora_successful_auth_webhook_total{state="denied"} 92 -# HELP sora_time_seconds HELP time_seconds System time in seconds since epoch. +# HELP sora_time_seconds System time in seconds since epoch. # TYPE sora_time_seconds gauge sora_time_seconds 1.7046492910003123e+09 # HELP sora_turn_connections_total The total number of connections with TURN. diff --git a/test/sora_client_enabled.metrics b/test/sora_client_enabled.metrics index f324866..d49c2b5 100644 --- a/test/sora_client_enabled.metrics +++ b/test/sora_client_enabled.metrics @@ -48,7 +48,7 @@ sora_duration_seconds_total 1412 # TYPE sora_event_webhook_total counter sora_event_webhook_total{state="failed"} 94 sora_event_webhook_total{state="successful"} 97 -# HELP sora_license_expired_at_timestamp_seconds sora license file's expired at. +# HELP sora_license_expired_at_timestamp_seconds sora license file's expire seconds since epoch. # TYPE sora_license_expired_at_timestamp_seconds gauge sora_license_expired_at_timestamp_seconds 1.759276799e+09 # HELP sora_license_info sora license info. @@ -78,7 +78,7 @@ sora_session_webhook_total{state="successful"} 98 # TYPE sora_successful_auth_webhook_total counter sora_successful_auth_webhook_total{state="allowed"} 91 sora_successful_auth_webhook_total{state="denied"} 92 -# HELP sora_time_seconds HELP time_seconds System time in seconds since epoch. +# HELP sora_time_seconds System time in seconds since epoch. # TYPE sora_time_seconds gauge sora_time_seconds 1.7046492910003123e+09 # HELP sora_turn_connections_total The total number of connections with TURN. diff --git a/test/sora_cluster_metrics_enabled.metrics b/test/sora_cluster_metrics_enabled.metrics index 7697d50..03d77e5 100644 --- a/test/sora_cluster_metrics_enabled.metrics +++ b/test/sora_cluster_metrics_enabled.metrics @@ -36,7 +36,7 @@ sora_duration_seconds_total 1412 # TYPE sora_event_webhook_total counter sora_event_webhook_total{state="failed"} 94 sora_event_webhook_total{state="successful"} 97 -# HELP sora_license_expired_at_timestamp_seconds sora license file's expired at. +# HELP sora_license_expired_at_timestamp_seconds sora license file's expire seconds since epoch. # TYPE sora_license_expired_at_timestamp_seconds gauge sora_license_expired_at_timestamp_seconds 1.759276799e+09 # HELP sora_license_info sora license info. @@ -66,7 +66,7 @@ sora_session_webhook_total{state="successful"} 98 # TYPE sora_successful_auth_webhook_total counter sora_successful_auth_webhook_total{state="allowed"} 91 sora_successful_auth_webhook_total{state="denied"} 92 -# HELP sora_time_seconds HELP time_seconds System time in seconds since epoch. +# HELP sora_time_seconds System time in seconds since epoch. # TYPE sora_time_seconds gauge sora_time_seconds 1.7046492910003123e+09 # HELP sora_turn_connections_total The total number of connections with TURN. diff --git a/test/sora_connection_error_enabled.metrics b/test/sora_connection_error_enabled.metrics index 704a691..0b816d8 100644 --- a/test/sora_connection_error_enabled.metrics +++ b/test/sora_connection_error_enabled.metrics @@ -26,7 +26,7 @@ sora_duration_seconds_total 1412 # TYPE sora_event_webhook_total counter sora_event_webhook_total{state="failed"} 94 sora_event_webhook_total{state="successful"} 97 -# HELP sora_license_expired_at_timestamp_seconds sora license file's expired at. +# HELP sora_license_expired_at_timestamp_seconds sora license file's expire seconds since epoch. # TYPE sora_license_expired_at_timestamp_seconds gauge sora_license_expired_at_timestamp_seconds 1.759276799e+09 # HELP sora_license_info sora license info. @@ -56,7 +56,7 @@ sora_session_webhook_total{state="successful"} 98 # TYPE sora_successful_auth_webhook_total counter sora_successful_auth_webhook_total{state="allowed"} 91 sora_successful_auth_webhook_total{state="denied"} 92 -# HELP sora_time_seconds HELP time_seconds System time in seconds since epoch. +# HELP sora_time_seconds System time in seconds since epoch. # TYPE sora_time_seconds gauge sora_time_seconds 1.7046492910003123e+09 # HELP sora_turn_connections_total The total number of connections with TURN. diff --git a/test/sora_erlang_vm_enabled.metrics b/test/sora_erlang_vm_enabled.metrics index e9f667b..45b94e5 100644 --- a/test/sora_erlang_vm_enabled.metrics +++ b/test/sora_erlang_vm_enabled.metrics @@ -103,7 +103,7 @@ sora_erlang_vm_wall_clock_wallclock_time_since_last_call 9090 # TYPE sora_event_webhook_total counter sora_event_webhook_total{state="failed"} 94 sora_event_webhook_total{state="successful"} 97 -# HELP sora_license_expired_at_timestamp_seconds sora license file's expired at. +# HELP sora_license_expired_at_timestamp_seconds sora license file's expire seconds since epoch. # TYPE sora_license_expired_at_timestamp_seconds gauge sora_license_expired_at_timestamp_seconds 1.759276799e+09 # HELP sora_license_info sora license info. @@ -133,7 +133,7 @@ sora_session_webhook_total{state="successful"} 98 # TYPE sora_successful_auth_webhook_total counter sora_successful_auth_webhook_total{state="allowed"} 91 sora_successful_auth_webhook_total{state="denied"} 92 -# HELP sora_time_seconds HELP time_seconds System time in seconds since epoch. +# HELP sora_time_seconds System time in seconds since epoch. # TYPE sora_time_seconds gauge sora_time_seconds 1.7046492910003123e+09 # HELP sora_turn_connections_total The total number of connections with TURN. From 8964b063e64c4129cf213cddd1607d407b7352d1 Mon Sep 17 00:00:00 2001 From: Takeshi NAMAO Date: Thu, 8 Feb 2024 11:40:49 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=E5=A4=89=E6=95=B0=E3=81=AB=E3=82=B3?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- collector/collector.go | 1 + 1 file changed, 1 insertion(+) diff --git a/collector/collector.go b/collector/collector.go index e0774af..ccdb70c 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -15,6 +15,7 @@ import ( ) var ( + // for testing freezedTimeSeconds = float64(time.Date(2024, 1, 7, 17, 41, 31, 312389, time.UTC).UnixNano()) / 1e9 ) From 53c3e08f5b3924a59b500ffd7f2ce95bda89a31a Mon Sep 17 00:00:00 2001 From: Takeshi NAMAO Date: Thu, 8 Feb 2024 11:54:40 +0900 Subject: [PATCH 5/6] =?UTF-8?q?=E5=A4=89=E6=9B=B4=E5=B1=A5=E6=AD=B4?= =?UTF-8?q?=E3=81=AB=E8=BF=BD=E8=A8=98=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index c9c7448..8f209b9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,16 @@ # CHANGES +## develop + +- [ADD] `sora_license_expired_at_timestamp_seconds` メトリクスを追加する + - Sora のライセンス期限を epoch 秒に変換したものを返す + - 仮にライセンスの期限が 2024 年 1 月の場合は、`2024-01-31T23:59:59Z` の epoch 秒になる + - @tnamao +- [ADD] `sora_time_seconds` メトリクスを追加する + - これは `Node exporter` の `node_time_seconds` と同じもので、exporter が起動しているサーバーのシステム時間を epoch 秒で返す + - `sora_license_expired_at_timestamp_seconds` と組み合わせてライセンスの期限を監視することを想定している + - @tnamao + ## 2024.1.0 - [FIX] Sora 2023.2.0 で `ListClusterNodes` API の `include_all_known_nodes` のデフォルト値が変更で panic が起こす問題に対応する From 6940429f82bbdda31b973e4ad5ed4f282d960f97 Mon Sep 17 00:00:00 2001 From: Takeshi NAMAO Date: Thu, 8 Feb 2024 12:12:20 +0900 Subject: [PATCH 6/6] =?UTF-8?q?=E5=A4=89=E6=9B=B4=E5=B1=A5=E6=AD=B4?= =?UTF-8?q?=E3=81=AB=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3=E3=82=92?= =?UTF-8?q?=E5=8F=8D=E6=98=A0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 8f209b9..cc43c36 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,6 @@ # CHANGES -## develop +## 2024.2.0 - [ADD] `sora_license_expired_at_timestamp_seconds` メトリクスを追加する - Sora のライセンス期限を epoch 秒に変換したものを返す