forked from TrueCloudLab/frostfs-s3-gw
[#153] Add labels in metrics of total bytes
Signed-off-by: Marina Biryukova <m.biryukova@yadro.com>
This commit is contained in:
parent
6b109eee92
commit
52b89d3497
2 changed files with 18 additions and 23 deletions
|
@ -117,19 +117,13 @@ var appMetricsDesc = map[string]map[string]Description{
|
||||||
Help: "Total number of s3 errors in current FrostFS S3 Gate instance",
|
Help: "Total number of s3 errors in current FrostFS S3 Gate instance",
|
||||||
VariableLabels: []string{"api"},
|
VariableLabels: []string{"api"},
|
||||||
},
|
},
|
||||||
txBytesTotalMetric: Description{
|
bytesTotalMetric: Description{
|
||||||
Type: dto.MetricType_GAUGE,
|
Type: dto.MetricType_GAUGE,
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Subsystem: statisticSubsystem,
|
Subsystem: statisticSubsystem,
|
||||||
Name: txBytesTotalMetric,
|
Name: bytesTotalMetric,
|
||||||
Help: "Total number of bytes sent by current FrostFS S3 Gate instance",
|
Help: "Total number of bytes sent/received by current FrostFS S3 Gate instance",
|
||||||
},
|
VariableLabels: []string{"direction"},
|
||||||
rxBytesTotalMetric: Description{
|
|
||||||
Type: dto.MetricType_GAUGE,
|
|
||||||
Namespace: namespace,
|
|
||||||
Subsystem: statisticSubsystem,
|
|
||||||
Name: rxBytesTotalMetric,
|
|
||||||
Help: "Total number of bytes received by current FrostFS S3 Gate instance",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,7 @@ type (
|
||||||
currentS3RequestsDesc *prometheus.Desc
|
currentS3RequestsDesc *prometheus.Desc
|
||||||
totalS3RequestsDesc *prometheus.Desc
|
totalS3RequestsDesc *prometheus.Desc
|
||||||
totalS3ErrorsDesc *prometheus.Desc
|
totalS3ErrorsDesc *prometheus.Desc
|
||||||
txBytesTotalDesc *prometheus.Desc
|
bytesTotalDesc *prometheus.Desc
|
||||||
rxBytesTotalDesc *prometheus.Desc
|
|
||||||
}
|
}
|
||||||
|
|
||||||
APIStatMetrics struct {
|
APIStatMetrics struct {
|
||||||
|
@ -47,8 +46,12 @@ const (
|
||||||
requestsCurrentMetric = "requests_current"
|
requestsCurrentMetric = "requests_current"
|
||||||
requestsTotalMetric = "requests_total"
|
requestsTotalMetric = "requests_total"
|
||||||
errorsTotalMetric = "errors_total"
|
errorsTotalMetric = "errors_total"
|
||||||
txBytesTotalMetric = "tx_bytes_total"
|
bytesTotalMetric = "bytes_total"
|
||||||
rxBytesTotalMetric = "rx_bytes_total"
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
INDirection = "IN"
|
||||||
|
OUTDirection = "OUT"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newAPIStatMetrics() *APIStatMetrics {
|
func newAPIStatMetrics() *APIStatMetrics {
|
||||||
|
@ -132,8 +135,7 @@ func newHTTPStats() *httpStats {
|
||||||
currentS3RequestsDesc: newDesc(appMetricsDesc[statisticSubsystem][requestsCurrentMetric]),
|
currentS3RequestsDesc: newDesc(appMetricsDesc[statisticSubsystem][requestsCurrentMetric]),
|
||||||
totalS3RequestsDesc: newDesc(appMetricsDesc[statisticSubsystem][requestsTotalMetric]),
|
totalS3RequestsDesc: newDesc(appMetricsDesc[statisticSubsystem][requestsTotalMetric]),
|
||||||
totalS3ErrorsDesc: newDesc(appMetricsDesc[statisticSubsystem][errorsTotalMetric]),
|
totalS3ErrorsDesc: newDesc(appMetricsDesc[statisticSubsystem][errorsTotalMetric]),
|
||||||
txBytesTotalDesc: newDesc(appMetricsDesc[statisticSubsystem][txBytesTotalMetric]),
|
bytesTotalDesc: newDesc(appMetricsDesc[statisticSubsystem][bytesTotalMetric]),
|
||||||
rxBytesTotalDesc: newDesc(appMetricsDesc[statisticSubsystem][rxBytesTotalMetric]),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,8 +143,7 @@ func (s *httpStats) Describe(desc chan<- *prometheus.Desc) {
|
||||||
desc <- s.currentS3RequestsDesc
|
desc <- s.currentS3RequestsDesc
|
||||||
desc <- s.totalS3RequestsDesc
|
desc <- s.totalS3RequestsDesc
|
||||||
desc <- s.totalS3ErrorsDesc
|
desc <- s.totalS3ErrorsDesc
|
||||||
desc <- s.txBytesTotalDesc
|
desc <- s.bytesTotalDesc
|
||||||
desc <- s.rxBytesTotalDesc
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpStats) Collect(ch chan<- prometheus.Metric) {
|
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)
|
// Network Sent/Received Bytes (Outbound)
|
||||||
ch <- prometheus.MustNewConstMetric(s.txBytesTotalDesc, prometheus.CounterValue, float64(s.getInputBytes()))
|
ch <- prometheus.MustNewConstMetric(s.bytesTotalDesc, prometheus.CounterValue, float64(s.getInputBytes()), INDirection)
|
||||||
ch <- prometheus.MustNewConstMetric(s.rxBytesTotalDesc, prometheus.CounterValue, float64(s.getOutputBytes()))
|
ch <- prometheus.MustNewConstMetric(s.bytesTotalDesc, prometheus.CounterValue, float64(s.getOutputBytes()), OUTDirection)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inc increments the api stats counter.
|
// Inc increments the api stats counter.
|
||||||
|
|
Loading…
Reference in a new issue