diff --git a/metrics/desc.go b/metrics/desc.go index 70eda00..3354da1 100644 --- a/metrics/desc.go +++ b/metrics/desc.go @@ -117,19 +117,13 @@ var appMetricsDesc = map[string]map[string]Description{ Help: "Total number of s3 errors in current FrostFS S3 Gate instance", VariableLabels: []string{"api"}, }, - txBytesTotalMetric: Description{ - Type: dto.MetricType_GAUGE, - Namespace: namespace, - Subsystem: statisticSubsystem, - Name: txBytesTotalMetric, - Help: "Total number of bytes sent by current FrostFS S3 Gate instance", - }, - rxBytesTotalMetric: Description{ - Type: dto.MetricType_GAUGE, - Namespace: namespace, - Subsystem: statisticSubsystem, - Name: rxBytesTotalMetric, - Help: "Total number of bytes received by current FrostFS S3 Gate instance", + bytesTotalMetric: Description{ + Type: dto.MetricType_GAUGE, + Namespace: namespace, + Subsystem: statisticSubsystem, + Name: bytesTotalMetric, + Help: "Total number of bytes sent/received by current FrostFS S3 Gate instance", + VariableLabels: []string{"direction"}, }, }, } diff --git a/metrics/stats.go b/metrics/stats.go index aaa218d..7f23c62 100644 --- a/metrics/stats.go +++ b/metrics/stats.go @@ -28,8 +28,7 @@ type ( currentS3RequestsDesc *prometheus.Desc totalS3RequestsDesc *prometheus.Desc totalS3ErrorsDesc *prometheus.Desc - txBytesTotalDesc *prometheus.Desc - rxBytesTotalDesc *prometheus.Desc + bytesTotalDesc *prometheus.Desc } APIStatMetrics struct { @@ -47,8 +46,12 @@ const ( requestsCurrentMetric = "requests_current" requestsTotalMetric = "requests_total" errorsTotalMetric = "errors_total" - txBytesTotalMetric = "tx_bytes_total" - rxBytesTotalMetric = "rx_bytes_total" + bytesTotalMetric = "bytes_total" +) + +const ( + INDirection = "IN" + OUTDirection = "OUT" ) func newAPIStatMetrics() *APIStatMetrics { @@ -132,8 +135,7 @@ func newHTTPStats() *httpStats { currentS3RequestsDesc: newDesc(appMetricsDesc[statisticSubsystem][requestsCurrentMetric]), totalS3RequestsDesc: newDesc(appMetricsDesc[statisticSubsystem][requestsTotalMetric]), totalS3ErrorsDesc: newDesc(appMetricsDesc[statisticSubsystem][errorsTotalMetric]), - txBytesTotalDesc: newDesc(appMetricsDesc[statisticSubsystem][txBytesTotalMetric]), - rxBytesTotalDesc: newDesc(appMetricsDesc[statisticSubsystem][rxBytesTotalMetric]), + bytesTotalDesc: newDesc(appMetricsDesc[statisticSubsystem][bytesTotalMetric]), } } @@ -141,8 +143,7 @@ func (s *httpStats) Describe(desc chan<- *prometheus.Desc) { desc <- s.currentS3RequestsDesc desc <- s.totalS3RequestsDesc desc <- s.totalS3ErrorsDesc - desc <- s.txBytesTotalDesc - desc <- s.rxBytesTotalDesc + desc <- s.bytesTotalDesc } func (s *httpStats) Collect(ch chan<- prometheus.Metric) { @@ -159,8 +160,8 @@ func (s *httpStats) Collect(ch chan<- prometheus.Metric) { } // Network Sent/Received Bytes (Outbound) - ch <- prometheus.MustNewConstMetric(s.txBytesTotalDesc, prometheus.CounterValue, float64(s.getInputBytes())) - ch <- prometheus.MustNewConstMetric(s.rxBytesTotalDesc, prometheus.CounterValue, float64(s.getOutputBytes())) + ch <- prometheus.MustNewConstMetric(s.bytesTotalDesc, prometheus.CounterValue, float64(s.getInputBytes()), INDirection) + ch <- prometheus.MustNewConstMetric(s.bytesTotalDesc, prometheus.CounterValue, float64(s.getOutputBytes()), OUTDirection) } // Inc increments the api stats counter.