2021-04-18 15:41:13 -04:00
|
|
|
// Copyright (c) 2015-2021 MinIO, Inc.
|
|
|
|
//
|
|
|
|
// This file is part of MinIO Object Storage stack
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2021-01-18 23:35:38 -05:00
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
2021-01-22 21:30:16 -05:00
|
|
|
"runtime"
|
2021-01-18 23:35:38 -05:00
|
|
|
"strings"
|
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/minio/minio/cmd/logger"
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
|
|
dto "github.com/prometheus/client_model/go"
|
2021-01-22 21:30:16 -05:00
|
|
|
"github.com/prometheus/procfs"
|
2021-01-18 23:35:38 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// MetricNamespace is top level grouping of metrics to create the metric name.
|
|
|
|
type MetricNamespace string
|
|
|
|
|
|
|
|
// MetricSubsystem is the sub grouping for metrics within a namespace.
|
|
|
|
type MetricSubsystem string
|
|
|
|
|
|
|
|
const (
|
|
|
|
bucketMetricNamespace MetricNamespace = "minio_bucket"
|
|
|
|
clusterMetricNamespace MetricNamespace = "minio_cluster"
|
|
|
|
healMetricNamespace MetricNamespace = "minio_heal"
|
|
|
|
interNodeMetricNamespace MetricNamespace = "minio_inter_node"
|
|
|
|
nodeMetricNamespace MetricNamespace = "minio_node"
|
2021-04-03 12:03:42 -04:00
|
|
|
minioMetricNamespace MetricNamespace = "minio"
|
2021-01-18 23:35:38 -05:00
|
|
|
s3MetricNamespace MetricNamespace = "minio_s3"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2021-03-31 02:19:36 -04:00
|
|
|
cacheSubsystem MetricSubsystem = "cache"
|
|
|
|
capacityRawSubsystem MetricSubsystem = "capacity_raw"
|
|
|
|
capacityUsableSubsystem MetricSubsystem = "capacity_usable"
|
|
|
|
diskSubsystem MetricSubsystem = "disk"
|
|
|
|
fileDescriptorSubsystem MetricSubsystem = "file_descriptor"
|
|
|
|
goRoutines MetricSubsystem = "go_routine"
|
|
|
|
ioSubsystem MetricSubsystem = "io"
|
|
|
|
nodesSubsystem MetricSubsystem = "nodes"
|
|
|
|
objectsSubsystem MetricSubsystem = "objects"
|
|
|
|
processSubsystem MetricSubsystem = "process"
|
|
|
|
replicationSubsystem MetricSubsystem = "replication"
|
|
|
|
requestsSubsystem MetricSubsystem = "requests"
|
|
|
|
requestsRejectedSubsystem MetricSubsystem = "requests_rejected"
|
|
|
|
timeSubsystem MetricSubsystem = "time"
|
|
|
|
trafficSubsystem MetricSubsystem = "traffic"
|
|
|
|
softwareSubsystem MetricSubsystem = "software"
|
|
|
|
sysCallSubsystem MetricSubsystem = "syscall"
|
|
|
|
usageSubsystem MetricSubsystem = "usage"
|
2021-01-18 23:35:38 -05:00
|
|
|
)
|
|
|
|
|
2021-01-22 21:30:16 -05:00
|
|
|
// MetricName are the individual names for the metric.
|
|
|
|
type MetricName string
|
2021-01-18 23:35:38 -05:00
|
|
|
|
|
|
|
const (
|
2021-03-31 02:19:36 -04:00
|
|
|
authTotal MetricName = "auth_total"
|
|
|
|
canceledTotal MetricName = "canceled_total"
|
|
|
|
errorsTotal MetricName = "errors_total"
|
|
|
|
headerTotal MetricName = "header_total"
|
|
|
|
healTotal MetricName = "heal_total"
|
|
|
|
hitsTotal MetricName = "hits_total"
|
|
|
|
inflightTotal MetricName = "inflight_total"
|
|
|
|
invalidTotal MetricName = "invalid_total"
|
|
|
|
limitTotal MetricName = "limit_total"
|
|
|
|
missedTotal MetricName = "missed_total"
|
|
|
|
waitingTotal MetricName = "waiting_total"
|
|
|
|
objectTotal MetricName = "object_total"
|
|
|
|
offlineTotal MetricName = "offline_total"
|
|
|
|
onlineTotal MetricName = "online_total"
|
|
|
|
openTotal MetricName = "open_total"
|
|
|
|
readTotal MetricName = "read_total"
|
|
|
|
timestampTotal MetricName = "timestamp_total"
|
|
|
|
writeTotal MetricName = "write_total"
|
|
|
|
total MetricName = "total"
|
2021-05-06 02:03:40 -04:00
|
|
|
freeInodes MetricName = "free_inodes"
|
2021-01-22 21:30:16 -05:00
|
|
|
|
2021-04-03 12:03:42 -04:00
|
|
|
failedCount MetricName = "failed_count"
|
2021-01-22 21:30:16 -05:00
|
|
|
failedBytes MetricName = "failed_bytes"
|
|
|
|
freeBytes MetricName = "free_bytes"
|
|
|
|
pendingBytes MetricName = "pending_bytes"
|
2021-04-03 12:03:42 -04:00
|
|
|
pendingCount MetricName = "pending_count"
|
2021-01-22 21:30:16 -05:00
|
|
|
readBytes MetricName = "read_bytes"
|
|
|
|
rcharBytes MetricName = "rchar_bytes"
|
|
|
|
receivedBytes MetricName = "received_bytes"
|
|
|
|
sentBytes MetricName = "sent_bytes"
|
|
|
|
totalBytes MetricName = "total_bytes"
|
|
|
|
usedBytes MetricName = "used_bytes"
|
|
|
|
writeBytes MetricName = "write_bytes"
|
|
|
|
wcharBytes MetricName = "wchar_bytes"
|
|
|
|
|
|
|
|
usagePercent MetricName = "update_percent"
|
|
|
|
|
|
|
|
commitInfo MetricName = "commit_info"
|
|
|
|
usageInfo MetricName = "usage_info"
|
|
|
|
versionInfo MetricName = "version_info"
|
2021-01-18 23:35:38 -05:00
|
|
|
|
|
|
|
sizeDistribution = "size_distribution"
|
2021-03-24 17:19:52 -04:00
|
|
|
ttfbDistribution = "ttfb_seconds_distribution"
|
2021-01-18 23:35:38 -05:00
|
|
|
|
|
|
|
lastActivityTime = "last_activity_nano_seconds"
|
2021-02-02 02:02:18 -05:00
|
|
|
startTime = "starttime_seconds"
|
2021-03-21 00:23:27 -04:00
|
|
|
upTime = "uptime_seconds"
|
2021-05-04 13:17:10 -04:00
|
|
|
memory = "resident_memory_bytes"
|
|
|
|
cpu = "cpu_total_seconds"
|
2021-01-18 23:35:38 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
serverName = "server"
|
|
|
|
)
|
|
|
|
|
2021-03-19 03:04:29 -04:00
|
|
|
// MetricType for the types of metrics supported
|
|
|
|
type MetricType string
|
2021-01-18 23:35:38 -05:00
|
|
|
|
|
|
|
const (
|
|
|
|
gaugeMetric = "gaugeMetric"
|
|
|
|
counterMetric = "counterMetric"
|
|
|
|
histogramMetric = "histogramMetric"
|
|
|
|
)
|
|
|
|
|
|
|
|
// MetricDescription describes the metric
|
|
|
|
type MetricDescription struct {
|
|
|
|
Namespace MetricNamespace `json:"MetricNamespace"`
|
|
|
|
Subsystem MetricSubsystem `json:"Subsystem"`
|
2021-01-22 21:30:16 -05:00
|
|
|
Name MetricName `json:"MetricName"`
|
2021-01-18 23:35:38 -05:00
|
|
|
Help string `json:"Help"`
|
2021-03-19 03:04:29 -04:00
|
|
|
Type MetricType `json:"Type"`
|
2021-01-18 23:35:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Metric captures the details for a metric
|
|
|
|
type Metric struct {
|
|
|
|
Description MetricDescription `json:"Description"`
|
|
|
|
StaticLabels map[string]string `json:"StaticLabels"`
|
|
|
|
Value float64 `json:"Value"`
|
|
|
|
VariableLabels map[string]string `json:"VariableLabels"`
|
|
|
|
HistogramBucketLabel string `json:"HistogramBucketLabel"`
|
|
|
|
Histogram map[string]uint64 `json:"Histogram"`
|
|
|
|
}
|
|
|
|
|
2021-03-19 03:04:29 -04:00
|
|
|
func (m *Metric) copyMetric() Metric {
|
|
|
|
metric := Metric{
|
|
|
|
Description: m.Description,
|
|
|
|
Value: m.Value,
|
|
|
|
HistogramBucketLabel: m.HistogramBucketLabel,
|
|
|
|
StaticLabels: make(map[string]string),
|
|
|
|
VariableLabels: make(map[string]string),
|
|
|
|
Histogram: make(map[string]uint64),
|
|
|
|
}
|
|
|
|
for k, v := range m.StaticLabels {
|
|
|
|
metric.StaticLabels[k] = v
|
|
|
|
}
|
|
|
|
for k, v := range m.VariableLabels {
|
|
|
|
metric.VariableLabels[k] = v
|
|
|
|
}
|
|
|
|
for k, v := range m.Histogram {
|
|
|
|
metric.Histogram[k] = v
|
|
|
|
}
|
|
|
|
return metric
|
|
|
|
}
|
|
|
|
|
2021-01-18 23:35:38 -05:00
|
|
|
// MetricsGroup are a group of metrics that are initialized together.
|
|
|
|
type MetricsGroup struct {
|
2021-03-19 03:04:29 -04:00
|
|
|
id string
|
|
|
|
cacheInterval time.Duration
|
|
|
|
cachedRead func(ctx context.Context, mg *MetricsGroup) []Metric
|
|
|
|
read func(ctx context.Context) []Metric
|
|
|
|
}
|
|
|
|
|
|
|
|
var metricsGroupCache = make(map[string]*timedValue)
|
|
|
|
var cacheLock sync.Mutex
|
|
|
|
|
|
|
|
func cachedRead(ctx context.Context, mg *MetricsGroup) (metrics []Metric) {
|
|
|
|
cacheLock.Lock()
|
|
|
|
defer cacheLock.Unlock()
|
|
|
|
v, ok := metricsGroupCache[mg.id]
|
|
|
|
if !ok {
|
|
|
|
interval := mg.cacheInterval
|
|
|
|
if interval == 0 {
|
|
|
|
interval = 30 * time.Second
|
|
|
|
}
|
|
|
|
v = &timedValue{}
|
|
|
|
v.Once.Do(func() {
|
|
|
|
v.Update = func() (interface{}, error) {
|
|
|
|
c := mg.read(ctx)
|
|
|
|
return c, nil
|
|
|
|
}
|
|
|
|
v.TTL = interval
|
|
|
|
})
|
|
|
|
metricsGroupCache[mg.id] = v
|
|
|
|
}
|
|
|
|
c, err := v.Get()
|
|
|
|
if err != nil {
|
|
|
|
return []Metric{}
|
|
|
|
}
|
|
|
|
m := c.([]Metric)
|
|
|
|
for i := range m {
|
|
|
|
metrics = append(metrics, m[i].copyMetric())
|
|
|
|
}
|
|
|
|
return metrics
|
2021-01-18 23:35:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// MetricsGenerator are functions that generate metric groups.
|
|
|
|
type MetricsGenerator func() MetricsGroup
|
|
|
|
|
|
|
|
// GetGlobalGenerators gets all the generators the report global metrics pre calculated.
|
|
|
|
func GetGlobalGenerators() []MetricsGenerator {
|
|
|
|
g := []MetricsGenerator{
|
|
|
|
getBucketUsageMetrics,
|
|
|
|
getMinioHealingMetrics,
|
|
|
|
getNodeHealthMetrics,
|
|
|
|
getClusterStorageMetrics,
|
|
|
|
}
|
|
|
|
return g
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetAllGenerators gets all the metric generators.
|
|
|
|
func GetAllGenerators() []MetricsGenerator {
|
|
|
|
g := GetGlobalGenerators()
|
|
|
|
g = append(g, GetGeneratorsForPeer()...)
|
|
|
|
return g
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetGeneratorsForPeer - gets the generators to report to peer.
|
|
|
|
func GetGeneratorsForPeer() []MetricsGenerator {
|
|
|
|
g := []MetricsGenerator{
|
2021-01-22 21:30:16 -05:00
|
|
|
getCacheMetrics,
|
|
|
|
getGoMetrics,
|
|
|
|
getHTTPMetrics,
|
2021-01-18 23:35:38 -05:00
|
|
|
getLocalStorageMetrics,
|
2021-01-22 21:30:16 -05:00
|
|
|
getMinioProcMetrics,
|
2021-01-18 23:35:38 -05:00
|
|
|
getMinioVersionMetrics,
|
|
|
|
getNetworkMetrics,
|
|
|
|
getS3TTFBMetric,
|
|
|
|
}
|
|
|
|
return g
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetSingleNodeGenerators gets the metrics that are local
|
|
|
|
func GetSingleNodeGenerators() []MetricsGenerator {
|
|
|
|
g := []MetricsGenerator{
|
|
|
|
getNodeHealthMetrics,
|
|
|
|
getCacheMetrics,
|
|
|
|
getHTTPMetrics,
|
|
|
|
getNetworkMetrics,
|
|
|
|
getMinioVersionMetrics,
|
|
|
|
getS3TTFBMetric,
|
|
|
|
}
|
|
|
|
return g
|
|
|
|
}
|
|
|
|
|
|
|
|
func getClusterCapacityTotalBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: clusterMetricNamespace,
|
|
|
|
Subsystem: capacityRawSubsystem,
|
|
|
|
Name: totalBytes,
|
|
|
|
Help: "Total capacity online in the cluster.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getClusterCapacityFreeBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: clusterMetricNamespace,
|
|
|
|
Subsystem: capacityRawSubsystem,
|
|
|
|
Name: freeBytes,
|
|
|
|
Help: "Total free capacity online in the cluster.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getClusterCapacityUsageBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: clusterMetricNamespace,
|
|
|
|
Subsystem: capacityUsableSubsystem,
|
|
|
|
Name: totalBytes,
|
|
|
|
Help: "Total usable capacity online in the cluster.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getClusterCapacityUsageFreeBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: clusterMetricNamespace,
|
|
|
|
Subsystem: capacityUsableSubsystem,
|
|
|
|
Name: freeBytes,
|
|
|
|
Help: "Total free usable capacity online in the cluster.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func getNodeDiskUsedBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: nodeMetricNamespace,
|
|
|
|
Subsystem: diskSubsystem,
|
|
|
|
Name: usedBytes,
|
|
|
|
Help: "Total storage used on a disk.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getNodeDiskFreeBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: nodeMetricNamespace,
|
|
|
|
Subsystem: diskSubsystem,
|
|
|
|
Name: freeBytes,
|
|
|
|
Help: "Total storage available on a disk.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
2021-03-03 14:18:41 -05:00
|
|
|
func getClusterDisksOfflineTotalMD() MetricDescription {
|
2021-01-18 23:35:38 -05:00
|
|
|
return MetricDescription{
|
|
|
|
Namespace: clusterMetricNamespace,
|
|
|
|
Subsystem: diskSubsystem,
|
|
|
|
Name: offlineTotal,
|
|
|
|
Help: "Total disks offline.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-03 14:18:41 -05:00
|
|
|
func getClusterDisksOnlineTotalMD() MetricDescription {
|
2021-01-18 23:35:38 -05:00
|
|
|
return MetricDescription{
|
|
|
|
Namespace: clusterMetricNamespace,
|
|
|
|
Subsystem: diskSubsystem,
|
|
|
|
Name: onlineTotal,
|
|
|
|
Help: "Total disks online.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-03 14:18:41 -05:00
|
|
|
func getClusterDisksTotalMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: clusterMetricNamespace,
|
|
|
|
Subsystem: diskSubsystem,
|
|
|
|
Name: total,
|
|
|
|
Help: "Total disks.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-06 02:03:40 -04:00
|
|
|
func getClusterDisksFreeInodes() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: clusterMetricNamespace,
|
|
|
|
Subsystem: diskSubsystem,
|
|
|
|
Name: freeInodes,
|
|
|
|
Help: "Total free inodes.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-18 23:35:38 -05:00
|
|
|
func getNodeDiskTotalBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: nodeMetricNamespace,
|
|
|
|
Subsystem: diskSubsystem,
|
|
|
|
Name: totalBytes,
|
|
|
|
Help: "Total storage on a disk.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
2021-04-03 12:03:42 -04:00
|
|
|
func getUsageLastScanActivityMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: minioMetricNamespace,
|
|
|
|
Subsystem: usageSubsystem,
|
|
|
|
Name: lastActivityTime,
|
|
|
|
Help: "Time elapsed (in nano seconds) since last scan activity. This is set to 0 until first scan cycle",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-18 23:35:38 -05:00
|
|
|
func getBucketUsageTotalBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: bucketMetricNamespace,
|
|
|
|
Subsystem: usageSubsystem,
|
|
|
|
Name: totalBytes,
|
|
|
|
Help: "Total bucket size in bytes",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getBucketUsageObjectsTotalMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: bucketMetricNamespace,
|
|
|
|
Subsystem: usageSubsystem,
|
|
|
|
Name: objectTotal,
|
|
|
|
Help: "Total number of objects",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getBucketRepPendingBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: bucketMetricNamespace,
|
|
|
|
Subsystem: replicationSubsystem,
|
|
|
|
Name: pendingBytes,
|
|
|
|
Help: "Total bytes pending to replicate.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getBucketRepFailedBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: bucketMetricNamespace,
|
|
|
|
Subsystem: replicationSubsystem,
|
|
|
|
Name: failedBytes,
|
|
|
|
Help: "Total number of bytes failed at least once to replicate.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getBucketRepSentBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: bucketMetricNamespace,
|
|
|
|
Subsystem: replicationSubsystem,
|
|
|
|
Name: sentBytes,
|
|
|
|
Help: "Total number of bytes replicated to the target bucket.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getBucketRepReceivedBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: bucketMetricNamespace,
|
|
|
|
Subsystem: replicationSubsystem,
|
|
|
|
Name: receivedBytes,
|
|
|
|
Help: "Total number of bytes replicated to this bucket from another source bucket.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
2021-04-03 12:03:42 -04:00
|
|
|
func getBucketRepPendingOperationsMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: bucketMetricNamespace,
|
|
|
|
Subsystem: replicationSubsystem,
|
|
|
|
Name: pendingCount,
|
|
|
|
Help: "Total number of objects pending replication",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getBucketRepFailedOperationsMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: bucketMetricNamespace,
|
|
|
|
Subsystem: replicationSubsystem,
|
|
|
|
Name: failedCount,
|
|
|
|
Help: "Total number of objects which failed replication",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
2021-01-18 23:35:38 -05:00
|
|
|
func getBucketObjectDistributionMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: bucketMetricNamespace,
|
|
|
|
Subsystem: objectsSubsystem,
|
|
|
|
Name: sizeDistribution,
|
|
|
|
Help: "Distribution of object sizes in the bucket, includes label for the bucket name.",
|
|
|
|
Type: histogramMetric,
|
|
|
|
}
|
|
|
|
}
|
2021-03-01 15:31:33 -05:00
|
|
|
func getInternodeFailedRequests() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: interNodeMetricNamespace,
|
|
|
|
Subsystem: trafficSubsystem,
|
|
|
|
Name: errorsTotal,
|
|
|
|
Help: "Total number of failed internode calls.",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-18 23:35:38 -05:00
|
|
|
func getInterNodeSentBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: interNodeMetricNamespace,
|
|
|
|
Subsystem: trafficSubsystem,
|
|
|
|
Name: sentBytes,
|
|
|
|
Help: "Total number of bytes sent to the other peer nodes.",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getInterNodeReceivedBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: interNodeMetricNamespace,
|
|
|
|
Subsystem: trafficSubsystem,
|
|
|
|
Name: receivedBytes,
|
|
|
|
Help: "Total number of bytes received from other peer nodes.",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getS3SentBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: s3MetricNamespace,
|
|
|
|
Subsystem: trafficSubsystem,
|
|
|
|
Name: sentBytes,
|
|
|
|
Help: "Total number of s3 bytes sent",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getS3ReceivedBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: s3MetricNamespace,
|
|
|
|
Subsystem: trafficSubsystem,
|
|
|
|
Name: receivedBytes,
|
|
|
|
Help: "Total number of s3 bytes received.",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getS3RequestsInFlightMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: s3MetricNamespace,
|
|
|
|
Subsystem: requestsSubsystem,
|
|
|
|
Name: inflightTotal,
|
2021-02-20 03:21:55 -05:00
|
|
|
Help: "Total number of S3 requests currently in flight",
|
2021-02-04 15:26:58 -05:00
|
|
|
Type: gaugeMetric,
|
2021-01-18 23:35:38 -05:00
|
|
|
}
|
|
|
|
}
|
2021-02-20 03:21:55 -05:00
|
|
|
func getS3RequestsInQueueMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: s3MetricNamespace,
|
|
|
|
Subsystem: requestsSubsystem,
|
|
|
|
Name: waitingTotal,
|
|
|
|
Help: "Number of S3 requests in the waiting queue",
|
2021-03-24 12:06:37 -04:00
|
|
|
Type: gaugeMetric,
|
2021-02-20 03:21:55 -05:00
|
|
|
}
|
|
|
|
}
|
2021-01-18 23:35:38 -05:00
|
|
|
func getS3RequestsTotalMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: s3MetricNamespace,
|
|
|
|
Subsystem: requestsSubsystem,
|
|
|
|
Name: total,
|
|
|
|
Help: "Total number S3 requests",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getS3RequestsErrorsMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: s3MetricNamespace,
|
|
|
|
Subsystem: requestsSubsystem,
|
|
|
|
Name: errorsTotal,
|
|
|
|
Help: "Total number S3 requests with errors",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
2021-03-24 13:25:27 -04:00
|
|
|
func getS3RequestsCanceledMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: s3MetricNamespace,
|
|
|
|
Subsystem: requestsSubsystem,
|
|
|
|
Name: canceledTotal,
|
|
|
|
Help: "Total number S3 requests that were canceled from the client while processing",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
2021-03-31 02:19:36 -04:00
|
|
|
func getS3RejectedAuthRequestsTotalMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: s3MetricNamespace,
|
|
|
|
Subsystem: requestsRejectedSubsystem,
|
|
|
|
Name: authTotal,
|
|
|
|
Help: "Total number S3 requests rejected for auth failure.",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getS3RejectedHeaderRequestsTotalMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: s3MetricNamespace,
|
|
|
|
Subsystem: requestsRejectedSubsystem,
|
|
|
|
Name: headerTotal,
|
|
|
|
Help: "Total number S3 requests rejected for invalid header.",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getS3RejectedTimestampRequestsTotalMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: s3MetricNamespace,
|
|
|
|
Subsystem: requestsRejectedSubsystem,
|
|
|
|
Name: timestampTotal,
|
|
|
|
Help: "Total number S3 requests rejected for invalid timestamp.",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getS3RejectedInvalidRequestsTotalMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: s3MetricNamespace,
|
|
|
|
Subsystem: requestsRejectedSubsystem,
|
|
|
|
Name: invalidTotal,
|
|
|
|
Help: "Total number S3 invalid requests.",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
2021-01-18 23:35:38 -05:00
|
|
|
func getCacheHitsTotalMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: minioNamespace,
|
|
|
|
Subsystem: cacheSubsystem,
|
|
|
|
Name: hitsTotal,
|
|
|
|
Help: "Total number of disk cache hits",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getCacheHitsMissedTotalMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: minioNamespace,
|
|
|
|
Subsystem: cacheSubsystem,
|
|
|
|
Name: missedTotal,
|
|
|
|
Help: "Total number of disk cache misses",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getCacheUsagePercentMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: minioNamespace,
|
|
|
|
Subsystem: minioNamespace,
|
|
|
|
Name: usagePercent,
|
|
|
|
Help: "Total percentage cache usage",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getCacheUsageInfoMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: minioNamespace,
|
|
|
|
Subsystem: cacheSubsystem,
|
|
|
|
Name: usageInfo,
|
|
|
|
Help: "Total percentage cache usage, value of 1 indicates high and 0 low, label level is set as well",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getCacheUsedBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: minioNamespace,
|
|
|
|
Subsystem: cacheSubsystem,
|
|
|
|
Name: usedBytes,
|
|
|
|
Help: "Current cache usage in bytes",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getCacheTotalBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: minioNamespace,
|
|
|
|
Subsystem: cacheSubsystem,
|
|
|
|
Name: totalBytes,
|
|
|
|
Help: "Total size of cache disk in bytes",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getCacheSentBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: minioNamespace,
|
|
|
|
Subsystem: cacheSubsystem,
|
|
|
|
Name: sentBytes,
|
|
|
|
Help: "Total number of bytes served from cache",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getHealObjectsTotalMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: healMetricNamespace,
|
|
|
|
Subsystem: objectsSubsystem,
|
|
|
|
Name: total,
|
|
|
|
Help: "Objects scanned in current self healing run",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getHealObjectsHealTotalMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: healMetricNamespace,
|
|
|
|
Subsystem: objectsSubsystem,
|
|
|
|
Name: healTotal,
|
|
|
|
Help: "Objects healed in current self healing run",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
2021-03-24 13:25:27 -04:00
|
|
|
|
2021-01-18 23:35:38 -05:00
|
|
|
func getHealObjectsFailTotalMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: healMetricNamespace,
|
|
|
|
Subsystem: objectsSubsystem,
|
|
|
|
Name: errorsTotal,
|
|
|
|
Help: "Objects for which healing failed in current self healing run",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getHealLastActivityTimeMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: healMetricNamespace,
|
|
|
|
Subsystem: timeSubsystem,
|
|
|
|
Name: lastActivityTime,
|
|
|
|
Help: "Time elapsed (in nano seconds) since last self healing activity. This is set to -1 until initial self heal activity",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getNodeOnlineTotalMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: clusterMetricNamespace,
|
|
|
|
Subsystem: nodesSubsystem,
|
|
|
|
Name: onlineTotal,
|
|
|
|
Help: "Total number of MinIO nodes online.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getNodeOfflineTotalMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: clusterMetricNamespace,
|
|
|
|
Subsystem: nodesSubsystem,
|
|
|
|
Name: offlineTotal,
|
|
|
|
Help: "Total number of MinIO nodes offline.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getMinIOVersionMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
2021-04-03 12:03:42 -04:00
|
|
|
Namespace: minioMetricNamespace,
|
2021-01-18 23:35:38 -05:00
|
|
|
Subsystem: softwareSubsystem,
|
|
|
|
Name: versionInfo,
|
|
|
|
Help: "MinIO Release tag for the server",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getMinIOCommitMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
2021-04-03 12:03:42 -04:00
|
|
|
Namespace: minioMetricNamespace,
|
2021-01-18 23:35:38 -05:00
|
|
|
Subsystem: softwareSubsystem,
|
|
|
|
Name: commitInfo,
|
|
|
|
Help: "Git commit hash for the MinIO release.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getS3TTFBDistributionMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: s3MetricNamespace,
|
|
|
|
Subsystem: timeSubsystem,
|
|
|
|
Name: ttfbDistribution,
|
|
|
|
Help: "Distribution of the time to first byte across API calls.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
2021-01-22 21:30:16 -05:00
|
|
|
func getMinioFDOpenMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: nodeMetricNamespace,
|
|
|
|
Subsystem: fileDescriptorSubsystem,
|
|
|
|
Name: openTotal,
|
|
|
|
Help: "Total number of open file descriptors by the MinIO Server process.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getMinioFDLimitMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: nodeMetricNamespace,
|
|
|
|
Subsystem: fileDescriptorSubsystem,
|
|
|
|
Name: limitTotal,
|
|
|
|
Help: "Limit on total number of open file descriptors for the MinIO Server process.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getMinioProcessIOWriteBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: nodeMetricNamespace,
|
|
|
|
Subsystem: ioSubsystem,
|
|
|
|
Name: writeBytes,
|
|
|
|
Help: "Total bytes written by the process to the underlying storage system, /proc/[pid]/io write_bytes",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getMinioProcessIOReadBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: nodeMetricNamespace,
|
|
|
|
Subsystem: ioSubsystem,
|
|
|
|
Name: readBytes,
|
|
|
|
Help: "Total bytes read by the process from the underlying storage system, /proc/[pid]/io read_bytes",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getMinioProcessIOWriteCachedBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: nodeMetricNamespace,
|
|
|
|
Subsystem: ioSubsystem,
|
|
|
|
Name: wcharBytes,
|
|
|
|
Help: "Total bytes written by the process to the underlying storage system including page cache, /proc/[pid]/io wchar",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getMinioProcessIOReadCachedBytesMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: nodeMetricNamespace,
|
|
|
|
Subsystem: ioSubsystem,
|
|
|
|
Name: rcharBytes,
|
|
|
|
Help: "Total bytes read by the process from the underlying storage system including cache, /proc/[pid]/io rchar",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getMinIOProcessSysCallRMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: nodeMetricNamespace,
|
|
|
|
Subsystem: sysCallSubsystem,
|
|
|
|
Name: readTotal,
|
|
|
|
Help: "Total read SysCalls to the kernel. /proc/[pid]/io syscr",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getMinIOProcessSysCallWMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: nodeMetricNamespace,
|
|
|
|
Subsystem: sysCallSubsystem,
|
|
|
|
Name: writeTotal,
|
|
|
|
Help: "Total write SysCalls to the kernel. /proc/[pid]/io syscw",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getMinIOGORoutineCountMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: nodeMetricNamespace,
|
|
|
|
Subsystem: goRoutines,
|
|
|
|
Name: total,
|
|
|
|
Help: "Total number of go routines running.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
2021-02-02 02:02:18 -05:00
|
|
|
func getMinIOProcessStartTimeMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: nodeMetricNamespace,
|
|
|
|
Subsystem: processSubsystem,
|
|
|
|
Name: startTime,
|
2021-03-21 00:23:27 -04:00
|
|
|
Help: "Start time for MinIO process per node, time in seconds since Unix epoc.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getMinIOProcessUptimeMD() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: nodeMetricNamespace,
|
|
|
|
Subsystem: processSubsystem,
|
|
|
|
Name: upTime,
|
|
|
|
Help: "Uptime for MinIO process per node in seconds.",
|
2021-02-02 02:02:18 -05:00
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
2021-05-04 13:17:10 -04:00
|
|
|
func getMinIOProcessResidentMemory() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: nodeMetricNamespace,
|
|
|
|
Subsystem: processSubsystem,
|
|
|
|
Name: memory,
|
|
|
|
Help: "Resident memory size in bytes.",
|
|
|
|
Type: gaugeMetric,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getMinIOProcessCPUTime() MetricDescription {
|
|
|
|
return MetricDescription{
|
|
|
|
Namespace: nodeMetricNamespace,
|
|
|
|
Subsystem: processSubsystem,
|
|
|
|
Name: cpu,
|
|
|
|
Help: "Total user and system CPU time spent in seconds.",
|
|
|
|
Type: counterMetric,
|
|
|
|
}
|
|
|
|
}
|
2021-01-22 21:30:16 -05:00
|
|
|
func getMinioProcMetrics() MetricsGroup {
|
|
|
|
return MetricsGroup{
|
2021-03-19 03:04:29 -04:00
|
|
|
id: "MinioProcMetrics",
|
|
|
|
cachedRead: cachedRead,
|
|
|
|
read: func(ctx context.Context) (metrics []Metric) {
|
2021-03-25 15:58:43 -04:00
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
metrics = make([]Metric, 0, 20)
|
2021-01-22 21:30:16 -05:00
|
|
|
p, err := procfs.Self()
|
|
|
|
if err != nil {
|
|
|
|
logger.LogOnceIf(ctx, err, nodeMetricNamespace)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var openFDs int
|
|
|
|
openFDs, err = p.FileDescriptorsLen()
|
|
|
|
if err != nil {
|
|
|
|
logger.LogOnceIf(ctx, err, getMinioFDOpenMD())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
l, err := p.Limits()
|
|
|
|
if err != nil {
|
|
|
|
logger.LogOnceIf(ctx, err, getMinioFDLimitMD())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
io, err := p.IO()
|
|
|
|
if err != nil {
|
|
|
|
logger.LogOnceIf(ctx, err, ioSubsystem)
|
|
|
|
return
|
|
|
|
}
|
2021-02-02 02:02:18 -05:00
|
|
|
stat, err := p.Stat()
|
|
|
|
if err != nil {
|
|
|
|
logger.LogOnceIf(ctx, err, processSubsystem)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
startTime, err := stat.StartTime()
|
|
|
|
if err != nil {
|
|
|
|
logger.LogOnceIf(ctx, err, startTime)
|
|
|
|
return
|
|
|
|
}
|
2021-01-18 23:35:38 -05:00
|
|
|
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics,
|
2021-01-22 21:30:16 -05:00
|
|
|
Metric{
|
|
|
|
Description: getMinioFDOpenMD(),
|
|
|
|
Value: float64(openFDs),
|
|
|
|
},
|
|
|
|
)
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics,
|
2021-01-22 21:30:16 -05:00
|
|
|
Metric{
|
|
|
|
Description: getMinioFDLimitMD(),
|
|
|
|
Value: float64(l.OpenFiles),
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics,
|
2021-01-22 21:30:16 -05:00
|
|
|
Metric{
|
|
|
|
Description: getMinIOProcessSysCallRMD(),
|
|
|
|
Value: float64(io.SyscR),
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics,
|
2021-01-22 21:30:16 -05:00
|
|
|
Metric{
|
|
|
|
Description: getMinIOProcessSysCallWMD(),
|
|
|
|
Value: float64(io.SyscW),
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics,
|
2021-01-22 21:30:16 -05:00
|
|
|
Metric{
|
|
|
|
Description: getMinioProcessIOReadBytesMD(),
|
|
|
|
Value: float64(io.ReadBytes),
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics,
|
2021-01-22 21:30:16 -05:00
|
|
|
Metric{
|
|
|
|
Description: getMinioProcessIOWriteBytesMD(),
|
|
|
|
Value: float64(io.WriteBytes),
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics,
|
2021-01-22 21:30:16 -05:00
|
|
|
Metric{
|
|
|
|
Description: getMinioProcessIOReadCachedBytesMD(),
|
|
|
|
Value: float64(io.RChar),
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics,
|
2021-01-22 21:30:16 -05:00
|
|
|
Metric{
|
|
|
|
Description: getMinioProcessIOWriteCachedBytesMD(),
|
|
|
|
Value: float64(io.WChar),
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics,
|
2021-02-02 02:02:18 -05:00
|
|
|
Metric{
|
|
|
|
Description: getMinIOProcessStartTimeMD(),
|
|
|
|
Value: startTime,
|
|
|
|
})
|
2021-03-21 00:23:27 -04:00
|
|
|
metrics = append(metrics,
|
|
|
|
Metric{
|
|
|
|
Description: getMinIOProcessUptimeMD(),
|
|
|
|
Value: time.Since(globalBootTime).Seconds(),
|
|
|
|
})
|
2021-05-04 13:17:10 -04:00
|
|
|
metrics = append(metrics,
|
|
|
|
Metric{
|
|
|
|
Description: getMinIOProcessResidentMemory(),
|
|
|
|
Value: float64(stat.ResidentMemory()),
|
|
|
|
})
|
|
|
|
metrics = append(metrics,
|
|
|
|
Metric{
|
|
|
|
Description: getMinIOProcessCPUTime(),
|
|
|
|
Value: float64(stat.CPUTime()),
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
return
|
2021-01-22 21:30:16 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getGoMetrics() MetricsGroup {
|
|
|
|
return MetricsGroup{
|
2021-03-19 03:04:29 -04:00
|
|
|
id: "GoMetrics",
|
|
|
|
cachedRead: cachedRead,
|
|
|
|
read: func(ctx context.Context) (metrics []Metric) {
|
|
|
|
metrics = append(metrics, Metric{
|
2021-01-22 21:30:16 -05:00
|
|
|
Description: getMinIOGORoutineCountMD(),
|
|
|
|
Value: float64(runtime.NumGoroutine()),
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
return
|
2021-01-22 21:30:16 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2021-01-18 23:35:38 -05:00
|
|
|
func getS3TTFBMetric() MetricsGroup {
|
|
|
|
return MetricsGroup{
|
2021-03-19 03:04:29 -04:00
|
|
|
id: "s3TTFBMetric",
|
|
|
|
cachedRead: cachedRead,
|
|
|
|
read: func(ctx context.Context) (metrics []Metric) {
|
2021-01-18 23:35:38 -05:00
|
|
|
|
|
|
|
// Read prometheus metric on this channel
|
|
|
|
ch := make(chan prometheus.Metric)
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
wg.Add(1)
|
|
|
|
|
|
|
|
// Read prometheus histogram data and convert it to internal metric data
|
|
|
|
go func() {
|
|
|
|
defer wg.Done()
|
|
|
|
for promMetric := range ch {
|
|
|
|
dtoMetric := &dto.Metric{}
|
|
|
|
err := promMetric.Write(dtoMetric)
|
|
|
|
if err != nil {
|
|
|
|
logger.LogIf(GlobalContext, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
h := dtoMetric.GetHistogram()
|
|
|
|
for _, b := range h.Bucket {
|
|
|
|
labels := make(map[string]string)
|
|
|
|
for _, lp := range dtoMetric.GetLabel() {
|
|
|
|
labels[*lp.Name] = *lp.Value
|
|
|
|
}
|
|
|
|
labels["le"] = fmt.Sprintf("%.3f", *b.UpperBound)
|
|
|
|
metric := Metric{
|
|
|
|
Description: getS3TTFBDistributionMD(),
|
|
|
|
VariableLabels: labels,
|
|
|
|
Value: float64(b.GetCumulativeCount()),
|
|
|
|
}
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, metric)
|
2021-01-18 23:35:38 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
httpRequestsDuration.Collect(ch)
|
|
|
|
close(ch)
|
|
|
|
wg.Wait()
|
2021-03-19 03:04:29 -04:00
|
|
|
return
|
2021-01-18 23:35:38 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func getMinioVersionMetrics() MetricsGroup {
|
|
|
|
return MetricsGroup{
|
2021-03-19 03:04:29 -04:00
|
|
|
id: "MinioVersionMetrics",
|
|
|
|
cachedRead: cachedRead,
|
|
|
|
read: func(_ context.Context) (metrics []Metric) {
|
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getMinIOCommitMD(),
|
|
|
|
VariableLabels: map[string]string{"commit": CommitID},
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getMinIOVersionMD(),
|
|
|
|
VariableLabels: map[string]string{"version": Version},
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
return
|
2021-01-18 23:35:38 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func getNodeHealthMetrics() MetricsGroup {
|
|
|
|
return MetricsGroup{
|
2021-03-19 03:04:29 -04:00
|
|
|
id: "NodeHealthMetrics",
|
|
|
|
cachedRead: cachedRead,
|
|
|
|
read: func(_ context.Context) (metrics []Metric) {
|
|
|
|
nodesUp, nodesDown := GetPeerOnlineCount()
|
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getNodeOnlineTotalMD(),
|
2021-03-19 03:04:29 -04:00
|
|
|
Value: float64(nodesUp),
|
|
|
|
})
|
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getNodeOfflineTotalMD(),
|
2021-03-19 03:04:29 -04:00
|
|
|
Value: float64(nodesDown),
|
|
|
|
})
|
|
|
|
return
|
2021-01-18 23:35:38 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func getMinioHealingMetrics() MetricsGroup {
|
|
|
|
return MetricsGroup{
|
2021-03-19 03:04:29 -04:00
|
|
|
id: "minioHealingMetrics",
|
|
|
|
cachedRead: cachedRead,
|
|
|
|
read: func(_ context.Context) (metrics []Metric) {
|
2021-03-25 15:58:43 -04:00
|
|
|
metrics = make([]Metric, 0, 5)
|
2021-01-18 23:35:38 -05:00
|
|
|
if !globalIsErasure {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
bgSeq, exists := globalBackgroundHealState.getHealSequenceByToken(bgHealingUUID)
|
|
|
|
if !exists {
|
|
|
|
return
|
|
|
|
}
|
2021-04-03 12:03:42 -04:00
|
|
|
|
|
|
|
if bgSeq.lastHealActivity.IsZero() {
|
|
|
|
return
|
2021-01-18 23:35:38 -05:00
|
|
|
}
|
2021-04-03 12:03:42 -04:00
|
|
|
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getHealLastActivityTimeMD(),
|
2021-04-03 12:03:42 -04:00
|
|
|
Value: float64(time.Since(bgSeq.lastHealActivity)),
|
2021-01-18 23:35:38 -05:00
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, getObjectsScanned(bgSeq)...)
|
|
|
|
metrics = append(metrics, getScannedItems(bgSeq)...)
|
|
|
|
metrics = append(metrics, getFailedItems(bgSeq)...)
|
|
|
|
return
|
2021-01-18 23:35:38 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func getFailedItems(seq *healSequence) (m []Metric) {
|
2021-03-25 15:58:43 -04:00
|
|
|
m = make([]Metric, 0, 1)
|
2021-01-18 23:35:38 -05:00
|
|
|
for k, v := range seq.gethealFailedItemsMap() {
|
|
|
|
s := strings.Split(k, ",")
|
|
|
|
m = append(m, Metric{
|
|
|
|
Description: getHealObjectsFailTotalMD(),
|
|
|
|
VariableLabels: map[string]string{
|
|
|
|
"mount_path": s[0],
|
|
|
|
"volume_status": s[1],
|
|
|
|
},
|
|
|
|
Value: float64(v),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func getScannedItems(seq *healSequence) (m []Metric) {
|
2021-03-25 15:58:43 -04:00
|
|
|
items := seq.getHealedItemsMap()
|
|
|
|
m = make([]Metric, 0, len(items))
|
|
|
|
for k, v := range items {
|
2021-01-18 23:35:38 -05:00
|
|
|
m = append(m, Metric{
|
|
|
|
Description: getHealObjectsHealTotalMD(),
|
|
|
|
VariableLabels: map[string]string{"type": string(k)},
|
|
|
|
Value: float64(v),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func getObjectsScanned(seq *healSequence) (m []Metric) {
|
2021-03-25 15:58:43 -04:00
|
|
|
items := seq.getHealedItemsMap()
|
|
|
|
m = make([]Metric, 0, len(items))
|
2021-01-18 23:35:38 -05:00
|
|
|
for k, v := range seq.getScannedItemsMap() {
|
|
|
|
m = append(m, Metric{
|
|
|
|
Description: getHealObjectsTotalMD(),
|
|
|
|
VariableLabels: map[string]string{"type": string(k)},
|
|
|
|
Value: float64(v),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
func getCacheMetrics() MetricsGroup {
|
|
|
|
return MetricsGroup{
|
2021-03-19 03:04:29 -04:00
|
|
|
id: "CacheMetrics",
|
|
|
|
cachedRead: cachedRead,
|
|
|
|
read: func(ctx context.Context) (metrics []Metric) {
|
2021-03-25 15:58:43 -04:00
|
|
|
metrics = make([]Metric, 0, 20)
|
2021-01-18 23:35:38 -05:00
|
|
|
cacheObjLayer := newCachedObjectLayerFn()
|
|
|
|
// Service not initialized yet
|
|
|
|
if cacheObjLayer == nil {
|
|
|
|
return
|
|
|
|
}
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getCacheHitsTotalMD(),
|
|
|
|
Value: float64(cacheObjLayer.CacheStats().getHits()),
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getCacheHitsMissedTotalMD(),
|
|
|
|
Value: float64(cacheObjLayer.CacheStats().getMisses()),
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getCacheSentBytesMD(),
|
|
|
|
Value: float64(cacheObjLayer.CacheStats().getBytesServed()),
|
|
|
|
})
|
|
|
|
for _, cdStats := range cacheObjLayer.CacheStats().GetDiskStats() {
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getCacheUsagePercentMD(),
|
|
|
|
Value: float64(cdStats.UsagePercent),
|
|
|
|
VariableLabels: map[string]string{"disk": cdStats.Dir},
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getCacheUsageInfoMD(),
|
|
|
|
Value: float64(cdStats.UsageState),
|
|
|
|
VariableLabels: map[string]string{"disk": cdStats.Dir, "level": cdStats.GetUsageLevelString()},
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getCacheUsedBytesMD(),
|
|
|
|
Value: float64(cdStats.UsageSize),
|
|
|
|
VariableLabels: map[string]string{"disk": cdStats.Dir},
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getCacheTotalBytesMD(),
|
|
|
|
Value: float64(cdStats.TotalCapacity),
|
|
|
|
VariableLabels: map[string]string{"disk": cdStats.Dir},
|
|
|
|
})
|
|
|
|
}
|
2021-03-19 03:04:29 -04:00
|
|
|
return
|
2021-01-18 23:35:38 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func getHTTPMetrics() MetricsGroup {
|
|
|
|
return MetricsGroup{
|
2021-03-19 03:04:29 -04:00
|
|
|
id: "httpMetrics",
|
|
|
|
cachedRead: cachedRead,
|
|
|
|
read: func(ctx context.Context) (metrics []Metric) {
|
2021-01-18 23:35:38 -05:00
|
|
|
httpStats := globalHTTPStats.toServerHTTPStats()
|
2021-03-25 15:58:43 -04:00
|
|
|
metrics = make([]Metric, 0, 3+
|
|
|
|
len(httpStats.CurrentS3Requests.APIStats)+
|
|
|
|
len(httpStats.TotalS3Requests.APIStats)+
|
|
|
|
len(httpStats.TotalS3Errors.APIStats))
|
2021-03-31 02:19:36 -04:00
|
|
|
metrics = append(metrics, Metric{
|
|
|
|
Description: getS3RejectedAuthRequestsTotalMD(),
|
|
|
|
Value: float64(httpStats.TotalS3RejectedAuth),
|
|
|
|
})
|
|
|
|
metrics = append(metrics, Metric{
|
|
|
|
Description: getS3RejectedTimestampRequestsTotalMD(),
|
|
|
|
Value: float64(httpStats.TotalS3RejectedTime),
|
|
|
|
})
|
|
|
|
metrics = append(metrics, Metric{
|
|
|
|
Description: getS3RejectedHeaderRequestsTotalMD(),
|
|
|
|
Value: float64(httpStats.TotalS3RejectedHeader),
|
|
|
|
})
|
|
|
|
metrics = append(metrics, Metric{
|
|
|
|
Description: getS3RejectedInvalidRequestsTotalMD(),
|
|
|
|
Value: float64(httpStats.TotalS3RejectedInvalid),
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-02-20 03:21:55 -05:00
|
|
|
Description: getS3RequestsInQueueMD(),
|
|
|
|
Value: float64(httpStats.S3RequestsInQueue),
|
|
|
|
})
|
2021-01-18 23:35:38 -05:00
|
|
|
for api, value := range httpStats.CurrentS3Requests.APIStats {
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getS3RequestsInFlightMD(),
|
|
|
|
Value: float64(value),
|
|
|
|
VariableLabels: map[string]string{"api": api},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
for api, value := range httpStats.TotalS3Requests.APIStats {
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getS3RequestsTotalMD(),
|
|
|
|
Value: float64(value),
|
|
|
|
VariableLabels: map[string]string{"api": api},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
for api, value := range httpStats.TotalS3Errors.APIStats {
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getS3RequestsErrorsMD(),
|
|
|
|
Value: float64(value),
|
2021-03-24 13:25:27 -04:00
|
|
|
VariableLabels: map[string]string{"api": api},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
for api, value := range httpStats.TotalS3Canceled.APIStats {
|
|
|
|
metrics = append(metrics, Metric{
|
|
|
|
Description: getS3RequestsCanceledMD(),
|
|
|
|
Value: float64(value),
|
2021-01-18 23:35:38 -05:00
|
|
|
VariableLabels: map[string]string{"api": api},
|
|
|
|
})
|
|
|
|
}
|
2021-03-19 03:04:29 -04:00
|
|
|
return
|
2021-01-18 23:35:38 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func getNetworkMetrics() MetricsGroup {
|
|
|
|
return MetricsGroup{
|
2021-03-19 03:04:29 -04:00
|
|
|
id: "networkMetrics",
|
|
|
|
cachedRead: cachedRead,
|
|
|
|
read: func(ctx context.Context) (metrics []Metric) {
|
2021-03-25 15:58:43 -04:00
|
|
|
metrics = make([]Metric, 0, 10)
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-03-01 15:31:33 -05:00
|
|
|
Description: getInternodeFailedRequests(),
|
|
|
|
Value: float64(loadAndResetRPCNetworkErrsCounter()),
|
|
|
|
})
|
2021-01-18 23:35:38 -05:00
|
|
|
connStats := globalConnStats.toServerConnStats()
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getInterNodeSentBytesMD(),
|
|
|
|
Value: float64(connStats.TotalOutputBytes),
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getInterNodeReceivedBytesMD(),
|
|
|
|
Value: float64(connStats.TotalInputBytes),
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getS3SentBytesMD(),
|
|
|
|
Value: float64(connStats.S3OutputBytes),
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getS3ReceivedBytesMD(),
|
|
|
|
Value: float64(connStats.S3InputBytes),
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
return
|
2021-01-18 23:35:38 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func getBucketUsageMetrics() MetricsGroup {
|
|
|
|
return MetricsGroup{
|
2021-03-19 03:04:29 -04:00
|
|
|
id: "BucketUsageMetrics",
|
|
|
|
cachedRead: cachedRead,
|
|
|
|
read: func(ctx context.Context) (metrics []Metric) {
|
2021-03-25 15:58:43 -04:00
|
|
|
metrics = make([]Metric, 0, 50)
|
2021-01-18 23:35:38 -05:00
|
|
|
objLayer := newObjectLayerFn()
|
|
|
|
// Service not initialized yet
|
2021-03-02 20:28:04 -05:00
|
|
|
if objLayer == nil {
|
2021-01-18 23:35:38 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if globalIsGateway {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-03-02 20:28:04 -05:00
|
|
|
dataUsageInfo, err := loadDataUsageFromBackend(ctx, objLayer)
|
2021-01-18 23:35:38 -05:00
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// data usage has not captured any data yet.
|
|
|
|
if dataUsageInfo.LastUpdate.IsZero() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-04-03 12:03:42 -04:00
|
|
|
metrics = append(metrics, Metric{
|
|
|
|
Description: getUsageLastScanActivityMD(),
|
|
|
|
Value: float64(time.Since(dataUsageInfo.LastUpdate)),
|
|
|
|
})
|
|
|
|
|
2021-03-02 20:28:04 -05:00
|
|
|
for bucket, usage := range dataUsageInfo.BucketsUsage {
|
2021-04-03 12:03:42 -04:00
|
|
|
stat := getLatestReplicationStats(bucket, usage)
|
|
|
|
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getBucketUsageTotalBytesMD(),
|
|
|
|
Value: float64(usage.Size),
|
|
|
|
VariableLabels: map[string]string{"bucket": bucket},
|
|
|
|
})
|
|
|
|
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getBucketUsageObjectsTotalMD(),
|
|
|
|
Value: float64(usage.ObjectsCount),
|
|
|
|
VariableLabels: map[string]string{"bucket": bucket},
|
|
|
|
})
|
|
|
|
|
2021-04-03 12:03:42 -04:00
|
|
|
if stat.hasReplicationUsage() {
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getBucketRepPendingBytesMD(),
|
2021-04-03 12:03:42 -04:00
|
|
|
Value: float64(stat.PendingSize),
|
2021-01-18 23:35:38 -05:00
|
|
|
VariableLabels: map[string]string{"bucket": bucket},
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getBucketRepFailedBytesMD(),
|
2021-04-03 12:03:42 -04:00
|
|
|
Value: float64(stat.FailedSize),
|
2021-01-18 23:35:38 -05:00
|
|
|
VariableLabels: map[string]string{"bucket": bucket},
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getBucketRepSentBytesMD(),
|
2021-04-03 12:03:42 -04:00
|
|
|
Value: float64(stat.ReplicatedSize),
|
2021-01-18 23:35:38 -05:00
|
|
|
VariableLabels: map[string]string{"bucket": bucket},
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getBucketRepReceivedBytesMD(),
|
2021-04-03 12:03:42 -04:00
|
|
|
Value: float64(stat.ReplicaSize),
|
|
|
|
VariableLabels: map[string]string{"bucket": bucket},
|
|
|
|
})
|
|
|
|
metrics = append(metrics, Metric{
|
|
|
|
Description: getBucketRepPendingOperationsMD(),
|
|
|
|
Value: float64(stat.PendingCount),
|
|
|
|
VariableLabels: map[string]string{"bucket": bucket},
|
|
|
|
})
|
|
|
|
metrics = append(metrics, Metric{
|
|
|
|
Description: getBucketRepFailedOperationsMD(),
|
|
|
|
Value: float64(stat.FailedCount),
|
2021-01-18 23:35:38 -05:00
|
|
|
VariableLabels: map[string]string{"bucket": bucket},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getBucketObjectDistributionMD(),
|
|
|
|
Histogram: usage.ObjectSizesHistogram,
|
|
|
|
HistogramBucketLabel: "range",
|
|
|
|
VariableLabels: map[string]string{"bucket": bucket},
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
2021-03-19 03:04:29 -04:00
|
|
|
return
|
2021-01-18 23:35:38 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getLocalStorageMetrics() MetricsGroup {
|
|
|
|
return MetricsGroup{
|
2021-03-19 03:04:29 -04:00
|
|
|
id: "localStorageMetrics",
|
|
|
|
cachedRead: cachedRead,
|
|
|
|
read: func(ctx context.Context) (metrics []Metric) {
|
2021-03-02 20:28:04 -05:00
|
|
|
objLayer := newObjectLayerFn()
|
|
|
|
// Service not initialized yet
|
|
|
|
if objLayer == nil {
|
|
|
|
return
|
|
|
|
}
|
2021-01-18 23:35:38 -05:00
|
|
|
|
2021-03-02 20:28:04 -05:00
|
|
|
if globalIsGateway {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-03-25 15:58:43 -04:00
|
|
|
metrics = make([]Metric, 0, 50)
|
2021-03-02 20:28:04 -05:00
|
|
|
storageInfo, _ := objLayer.LocalStorageInfo(ctx)
|
|
|
|
for _, disk := range storageInfo.Disks {
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getNodeDiskUsedBytesMD(),
|
|
|
|
Value: float64(disk.UsedSpace),
|
|
|
|
VariableLabels: map[string]string{"disk": disk.DrivePath},
|
|
|
|
})
|
|
|
|
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getNodeDiskFreeBytesMD(),
|
|
|
|
Value: float64(disk.AvailableSpace),
|
|
|
|
VariableLabels: map[string]string{"disk": disk.DrivePath},
|
|
|
|
})
|
|
|
|
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getNodeDiskTotalBytesMD(),
|
|
|
|
Value: float64(disk.TotalSpace),
|
|
|
|
VariableLabels: map[string]string{"disk": disk.DrivePath},
|
|
|
|
})
|
2021-05-06 02:03:40 -04:00
|
|
|
|
|
|
|
metrics = append(metrics, Metric{
|
|
|
|
Description: getClusterDisksFreeInodes(),
|
|
|
|
Value: float64(disk.FreeInodes),
|
|
|
|
VariableLabels: map[string]string{"disk": disk.DrivePath},
|
|
|
|
})
|
2021-01-18 23:35:38 -05:00
|
|
|
}
|
2021-03-19 03:04:29 -04:00
|
|
|
return
|
2021-01-18 23:35:38 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func getClusterStorageMetrics() MetricsGroup {
|
|
|
|
return MetricsGroup{
|
2021-03-19 03:04:29 -04:00
|
|
|
id: "ClusterStorageMetrics",
|
|
|
|
cachedRead: cachedRead,
|
|
|
|
read: func(ctx context.Context) (metrics []Metric) {
|
2021-01-18 23:35:38 -05:00
|
|
|
objLayer := newObjectLayerFn()
|
|
|
|
// Service not initialized yet
|
|
|
|
if objLayer == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-03-02 20:28:04 -05:00
|
|
|
if globalIsGateway {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-01-18 23:35:38 -05:00
|
|
|
// Fetch disk space info, ignore errors
|
2021-03-25 15:58:43 -04:00
|
|
|
metrics = make([]Metric, 0, 10)
|
2021-03-02 20:28:04 -05:00
|
|
|
storageInfo, _ := objLayer.StorageInfo(ctx)
|
2021-01-18 23:35:38 -05:00
|
|
|
onlineDisks, offlineDisks := getOnlineOfflineDisksStats(storageInfo.Disks)
|
2021-03-03 14:18:41 -05:00
|
|
|
totalDisks := onlineDisks.Merge(offlineDisks)
|
2021-01-18 23:35:38 -05:00
|
|
|
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getClusterCapacityTotalBytesMD(),
|
2021-02-04 15:26:58 -05:00
|
|
|
Value: float64(GetTotalCapacity(storageInfo.Disks)),
|
2021-01-18 23:35:38 -05:00
|
|
|
})
|
|
|
|
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getClusterCapacityFreeBytesMD(),
|
2021-02-04 15:26:58 -05:00
|
|
|
Value: float64(GetTotalCapacityFree(storageInfo.Disks)),
|
2021-01-18 23:35:38 -05:00
|
|
|
})
|
|
|
|
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getClusterCapacityUsageBytesMD(),
|
2021-03-02 20:28:04 -05:00
|
|
|
Value: GetTotalUsableCapacity(storageInfo.Disks, storageInfo),
|
2021-01-18 23:35:38 -05:00
|
|
|
})
|
|
|
|
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-01-18 23:35:38 -05:00
|
|
|
Description: getClusterCapacityUsageFreeBytesMD(),
|
2021-03-02 20:28:04 -05:00
|
|
|
Value: GetTotalUsableCapacityFree(storageInfo.Disks, storageInfo),
|
2021-01-18 23:35:38 -05:00
|
|
|
})
|
|
|
|
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-03-03 14:18:41 -05:00
|
|
|
Description: getClusterDisksOfflineTotalMD(),
|
2021-01-18 23:35:38 -05:00
|
|
|
Value: float64(offlineDisks.Sum()),
|
|
|
|
})
|
|
|
|
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-03-03 14:18:41 -05:00
|
|
|
Description: getClusterDisksOnlineTotalMD(),
|
|
|
|
Value: float64(onlineDisks.Sum()),
|
|
|
|
})
|
|
|
|
|
2021-03-19 03:04:29 -04:00
|
|
|
metrics = append(metrics, Metric{
|
2021-03-03 14:18:41 -05:00
|
|
|
Description: getClusterDisksTotalMD(),
|
2021-01-18 23:35:38 -05:00
|
|
|
Value: float64(totalDisks.Sum()),
|
|
|
|
})
|
2021-03-19 03:04:29 -04:00
|
|
|
return
|
2021-01-18 23:35:38 -05:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type minioClusterCollector struct {
|
|
|
|
desc *prometheus.Desc
|
|
|
|
}
|
|
|
|
|
|
|
|
func newMinioClusterCollector() *minioClusterCollector {
|
|
|
|
return &minioClusterCollector{
|
|
|
|
desc: prometheus.NewDesc("minio_stats", "Statistics exposed by MinIO server", nil, nil),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Describe sends the super-set of all possible descriptors of metrics
|
|
|
|
func (c *minioClusterCollector) Describe(ch chan<- *prometheus.Desc) {
|
|
|
|
ch <- c.desc
|
|
|
|
}
|
|
|
|
|
|
|
|
// Collect is called by the Prometheus registry when collecting metrics.
|
|
|
|
func (c *minioClusterCollector) Collect(out chan<- prometheus.Metric) {
|
|
|
|
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
publish := func(in <-chan Metric) {
|
|
|
|
defer wg.Done()
|
|
|
|
for metric := range in {
|
|
|
|
labels, values := getOrderedLabelValueArrays(metric.VariableLabels)
|
|
|
|
if metric.Description.Type == histogramMetric {
|
|
|
|
if metric.Histogram == nil {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
for k, v := range metric.Histogram {
|
|
|
|
l := append(labels, metric.HistogramBucketLabel)
|
|
|
|
lv := append(values, k)
|
|
|
|
out <- prometheus.MustNewConstMetric(
|
|
|
|
prometheus.NewDesc(
|
|
|
|
prometheus.BuildFQName(string(metric.Description.Namespace),
|
|
|
|
string(metric.Description.Subsystem),
|
|
|
|
string(metric.Description.Name)),
|
|
|
|
metric.Description.Help,
|
|
|
|
l,
|
|
|
|
metric.StaticLabels,
|
|
|
|
),
|
|
|
|
prometheus.GaugeValue,
|
|
|
|
float64(v),
|
|
|
|
lv...)
|
|
|
|
}
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
metricType := prometheus.GaugeValue
|
|
|
|
switch metric.Description.Type {
|
|
|
|
case counterMetric:
|
|
|
|
metricType = prometheus.CounterValue
|
|
|
|
}
|
|
|
|
toPost := prometheus.MustNewConstMetric(
|
|
|
|
prometheus.NewDesc(
|
|
|
|
prometheus.BuildFQName(string(metric.Description.Namespace),
|
|
|
|
string(metric.Description.Subsystem),
|
|
|
|
string(metric.Description.Name)),
|
|
|
|
metric.Description.Help,
|
|
|
|
labels,
|
|
|
|
metric.StaticLabels,
|
|
|
|
),
|
|
|
|
metricType,
|
|
|
|
metric.Value,
|
|
|
|
values...)
|
|
|
|
out <- toPost
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Call peer api to fetch metrics
|
|
|
|
peerCh := globalNotificationSys.GetClusterMetrics(GlobalContext)
|
|
|
|
selfCh := ReportMetrics(GlobalContext, GetAllGenerators)
|
|
|
|
wg.Add(2)
|
|
|
|
go publish(peerCh)
|
|
|
|
go publish(selfCh)
|
|
|
|
wg.Wait()
|
|
|
|
}
|
|
|
|
|
|
|
|
// ReportMetrics reports serialized metrics to the channel passed for the metrics generated.
|
|
|
|
func ReportMetrics(ctx context.Context, generators func() []MetricsGenerator) <-chan Metric {
|
|
|
|
ch := make(chan Metric)
|
|
|
|
go func() {
|
|
|
|
defer close(ch)
|
|
|
|
populateAndPublish(generators, func(m Metric) bool {
|
|
|
|
if m.VariableLabels == nil {
|
|
|
|
m.VariableLabels = make(map[string]string)
|
|
|
|
}
|
2021-03-26 14:37:58 -04:00
|
|
|
m.VariableLabels[serverName] = globalLocalNodeName
|
2021-01-18 23:35:38 -05:00
|
|
|
for {
|
|
|
|
select {
|
|
|
|
case ch <- m:
|
|
|
|
return true
|
|
|
|
case <-ctx.Done():
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}()
|
|
|
|
return ch
|
|
|
|
}
|
|
|
|
|
|
|
|
// minioCollectorV2 is the Custom Collector
|
|
|
|
type minioCollectorV2 struct {
|
|
|
|
generator func() []MetricsGenerator
|
|
|
|
desc *prometheus.Desc
|
|
|
|
}
|
|
|
|
|
|
|
|
// Describe sends the super-set of all possible descriptors of metrics
|
|
|
|
func (c *minioCollectorV2) Describe(ch chan<- *prometheus.Desc) {
|
|
|
|
ch <- c.desc
|
|
|
|
}
|
|
|
|
|
|
|
|
// populateAndPublish populates and then publishes the metrics generated by the generator function.
|
|
|
|
func populateAndPublish(generatorFn func() []MetricsGenerator, publish func(m Metric) bool) {
|
|
|
|
generators := generatorFn()
|
|
|
|
for _, g := range generators {
|
2021-03-19 03:04:29 -04:00
|
|
|
metricsGroup := g()
|
|
|
|
metrics := metricsGroup.cachedRead(GlobalContext, &metricsGroup)
|
|
|
|
for _, metric := range metrics {
|
2021-01-18 23:35:38 -05:00
|
|
|
if !publish(metric) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Collect is called by the Prometheus registry when collecting metrics.
|
|
|
|
func (c *minioCollectorV2) Collect(ch chan<- prometheus.Metric) {
|
|
|
|
|
|
|
|
// Expose MinIO's version information
|
|
|
|
minioVersionInfo.WithLabelValues(Version, CommitID).Set(1.0)
|
|
|
|
|
|
|
|
populateAndPublish(c.generator, func(metric Metric) bool {
|
|
|
|
labels, values := getOrderedLabelValueArrays(metric.VariableLabels)
|
2021-03-26 14:37:58 -04:00
|
|
|
values = append(values, globalLocalNodeName)
|
2021-01-18 23:35:38 -05:00
|
|
|
labels = append(labels, serverName)
|
|
|
|
|
|
|
|
if metric.Description.Type == histogramMetric {
|
|
|
|
if metric.Histogram == nil {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
for k, v := range metric.Histogram {
|
|
|
|
labels = append(labels, metric.HistogramBucketLabel)
|
|
|
|
values = append(values, k)
|
|
|
|
ch <- prometheus.MustNewConstMetric(
|
|
|
|
prometheus.NewDesc(
|
|
|
|
prometheus.BuildFQName(string(metric.Description.Namespace),
|
|
|
|
string(metric.Description.Subsystem),
|
|
|
|
string(metric.Description.Name)),
|
|
|
|
metric.Description.Help,
|
|
|
|
labels,
|
|
|
|
metric.StaticLabels,
|
|
|
|
),
|
|
|
|
prometheus.GaugeValue,
|
|
|
|
float64(v),
|
|
|
|
values...)
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
metricType := prometheus.GaugeValue
|
|
|
|
switch metric.Description.Type {
|
|
|
|
case counterMetric:
|
|
|
|
metricType = prometheus.CounterValue
|
|
|
|
}
|
|
|
|
ch <- prometheus.MustNewConstMetric(
|
|
|
|
prometheus.NewDesc(
|
|
|
|
prometheus.BuildFQName(string(metric.Description.Namespace),
|
|
|
|
string(metric.Description.Subsystem),
|
|
|
|
string(metric.Description.Name)),
|
|
|
|
metric.Description.Help,
|
|
|
|
labels,
|
|
|
|
metric.StaticLabels,
|
|
|
|
),
|
|
|
|
metricType,
|
|
|
|
metric.Value,
|
|
|
|
values...)
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func getOrderedLabelValueArrays(labelsWithValue map[string]string) (labels, values []string) {
|
|
|
|
labels = make([]string, 0)
|
|
|
|
values = make([]string, 0)
|
|
|
|
for l, v := range labelsWithValue {
|
|
|
|
labels = append(labels, l)
|
|
|
|
values = append(values, v)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// newMinioCollectorV2 describes the collector
|
|
|
|
// and returns reference of minioCollector for version 2
|
|
|
|
// It creates the Prometheus Description which is used
|
|
|
|
// to define Metric and help string
|
|
|
|
func newMinioCollectorV2(generator func() []MetricsGenerator) *minioCollectorV2 {
|
|
|
|
return &minioCollectorV2{
|
|
|
|
generator: generator,
|
|
|
|
desc: prometheus.NewDesc("minio_stats", "Statistics exposed by MinIO server", nil, nil),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func metricsServerHandler() http.Handler {
|
|
|
|
|
|
|
|
registry := prometheus.NewRegistry()
|
|
|
|
|
|
|
|
// Report all other metrics
|
|
|
|
err := registry.Register(newMinioClusterCollector())
|
|
|
|
if err != nil {
|
|
|
|
logger.CriticalIf(GlobalContext, err)
|
|
|
|
}
|
|
|
|
// DefaultGatherers include golang metrics and process metrics.
|
|
|
|
gatherers := prometheus.Gatherers{
|
|
|
|
registry,
|
|
|
|
}
|
|
|
|
// Delegate http serving to Prometheus client library, which will call collector.Collect.
|
|
|
|
return promhttp.InstrumentMetricHandler(
|
|
|
|
registry,
|
|
|
|
promhttp.HandlerFor(gatherers,
|
|
|
|
promhttp.HandlerOpts{
|
|
|
|
ErrorHandling: promhttp.ContinueOnError,
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func metricsNodeHandler() http.Handler {
|
|
|
|
registry := prometheus.NewRegistry()
|
|
|
|
|
|
|
|
err := registry.Register(newMinioCollectorV2(GetSingleNodeGenerators))
|
|
|
|
if err != nil {
|
|
|
|
logger.CriticalIf(GlobalContext, err)
|
|
|
|
}
|
2021-01-22 21:30:16 -05:00
|
|
|
err = registry.Register(prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{
|
|
|
|
Namespace: minioNamespace,
|
|
|
|
ReportErrors: true,
|
|
|
|
}))
|
|
|
|
if err != nil {
|
|
|
|
logger.CriticalIf(GlobalContext, err)
|
|
|
|
}
|
|
|
|
err = registry.Register(prometheus.NewGoCollector())
|
|
|
|
if err != nil {
|
|
|
|
logger.CriticalIf(GlobalContext, err)
|
|
|
|
}
|
2021-01-18 23:35:38 -05:00
|
|
|
gatherers := prometheus.Gatherers{
|
|
|
|
registry,
|
|
|
|
}
|
|
|
|
// Delegate http serving to Prometheus client library, which will call collector.Collect.
|
|
|
|
return promhttp.InstrumentMetricHandler(
|
|
|
|
registry,
|
|
|
|
promhttp.HandlerFor(gatherers,
|
|
|
|
promhttp.HandlerOpts{
|
|
|
|
ErrorHandling: promhttp.ContinueOnError,
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
}
|