-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Code enhancements in minio prometheus exporter #5848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
cmd/metrics.go
Outdated
| // Fetch disk space info | ||
| objLayer := newObjectLayerFn() | ||
| // Service not initialized yet | ||
| s := objLayer.StorageInfo(context.Background()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be called after the following if condition.
cmd/metrics.go
Outdated
| if objLayer == nil { | ||
| return | ||
| } | ||
| //Network Sent/Recieved Bytes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A space after //
cmd/metrics.go
Outdated
| prometheus.GaugeValue, | ||
| float64(s.Free), | ||
| ) | ||
| //Set Server Start Time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above..
cmd/metrics.go
Outdated
| "github.com/prometheus/client_golang/prometheus" | ||
| ) | ||
|
|
||
| // NetworkByte - Network statistics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment looks a bit out of place...
cmd/metrics.go
Outdated
| func updateGeneralMetrics() { | ||
| // Increment server uptime | ||
| serverUptime.Set(UTCNow().Sub(globalBootTime).Seconds()) | ||
| // NewNetworkBytesCollector describes the collector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"describes the collector" we need to explain what kind of collector.
|
@sinhaashish Please fix wrong aliasing in https://github.com/minio/minio/blob/master/cmd/metrics-router.go#L20 also. |
|
This is looking pretty good so far. One thing I missed in the previous review was that you're using the deprecated |
b05882d to
d38790b
Compare
Codecov Report
@@ Coverage Diff @@
## master #5848 +/- ##
==========================================
- Coverage 59.99% 59.92% -0.08%
==========================================
Files 212 212
Lines 30387 30463 +76
==========================================
+ Hits 18232 18255 +23
- Misses 10622 10676 +54
+ Partials 1533 1532 -1
Continue to review full report at Codecov.
|
cmd/metrics.go
Outdated
| // to define metric and help string | ||
| func NewNetworkBytesCollector() *NetworkBytesCollector { | ||
| return &NetworkBytesCollector{ | ||
| counterDesc: prometheus.NewDesc("minio_counters", "Help string", nil, nil), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you replace "help string" with something more useful ?
docs/metric/README.md
Outdated
| minio_online_disks_total | ||
| minio_server_uptime_seconds | ||
| ``` | ||
| - ```minio_disk_storage_bytes``` : Total byte count of disk storage available to current Minio server instance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single quotes will work here i.e. minio_disk_storage_bytes
d66279a to
f83d302
Compare
|
@sinhaashish, Travis CI is not passing because there is one misspelled word Can you fix it ? |
2457d0a to
6a5eb50
Compare
|
@SuperQ @harshavardhana @vadmeste . The required changes are done. Please validate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, other than minor nits.
| ) | ||
|
|
||
| const ( | ||
| prometheusMetricsPath = "/prometheus/metrics" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, there's no need to prefix with /prometheus here. /metrics is the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason is to provide room for other metrics which do not provide in prometheus compatible form.
| ## Minio Prometheus Metric | ||
|
|
||
| Minio server exposes an endpoint for Promethueus to scrape server data at `/minio/metric`. | ||
| Minio server exposes an endpoint for Promethueus to scrape server data at `/minio/prometheus/metric`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo /metric here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sinhaashish can you address this minor issue ? LGTM otherwise
| // Update prometheus metric | ||
| networkSentBytes.Set(float64(globalConnStats.getTotalOutputBytes())) | ||
| networkReceivedBytes.Set(float64(globalConnStats.getTotalInputBytes())) | ||
| // Minio Total Disk/Offline Disk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although offline/online disks don't make sense in Minio FS mode, I recommend to show a value other than zero for total disks. The following diff fixes the problem:
diff --git a/cmd/metrics.go b/cmd/metrics.go
index 942c247d..66c3cea6 100644
--- a/cmd/metrics.go
+++ b/cmd/metrics.go
@@ -124,6 +124,15 @@ func (c *minioCollector) Collect(ch chan<- prometheus.Metric) {
float64(globalBootTime.Unix()),
)
+ var totalDisks, offlineDisks int
+ if s.Backend.Type == FS {
+ totalDisks = 1
+ offlineDisks = 0
+ } else {
+ offlineDisks = s.Backend.OfflineDisks
+ totalDisks = s.Backend.OfflineDisks + s.Backend.OnlineDisks
+ }
+
// Minio Total Disk/Offline Disk
ch <- prometheus.MustNewConstMetric(
prometheus.NewDesc(
@@ -131,7 +140,7 @@ func (c *minioCollector) Collect(ch chan<- prometheus.Metric) {
"Total number of disks for current Minio server instance",
nil, nil),
prometheus.GaugeValue,
- float64(s.Backend.OnlineDisks+s.Backend.OfflineDisks),
+ float64(totalDisks),
)
ch <- prometheus.MustNewConstMetric(
prometheus.NewDesc(
@@ -139,7 +148,7 @@ func (c *minioCollector) Collect(ch chan<- prometheus.Metric) {
"Total number of offline disks for current Minio server instance",
nil, nil),
prometheus.GaugeValue,
- float64(s.Backend.OfflineDisks),
+ float64(offlineDisks),
)
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
6a5eb50 to
01bb3b0
Compare
Changes made to standardize the code with respect to Prometheus Ref : minio#5829
01bb3b0 to
404e2f6
Compare
Mint Automation
5848-404e2f6/mint-gateway-s3.sh.log:5848-404e2f6/mint-gateway-azure.sh.log:5848-404e2f6/mint-xl.sh.log:5848-404e2f6/mint-fs.sh.log:5848-404e2f6/mint-dist-xl.sh.log: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Standardized Minio collectors based on Prometheus recommendations.
Description
Changes made as suggested by @SuperQ in PR #5829.
Code modification in minio prometheus
changed from Gauge to Counter
Motivation and Context
As suggested by @SuperQ . It standardize the code wrt to prometheus
How Has This Been Tested?
Run the minio server and the prometheus metric is exposed at /minio/prometheus/metric
Types of changes
Checklist:
mintPR # here: )