Repository: minio/minio (language: go)

Issue:
"Object size distribution"-visualization shows wrong metrics
## Expected Behavior
The sum of all objects of the "Object size distribution"-visualization should be equal to the total amount of objects.

## Current Behavior
For Grafana at least:
The visualization uses `max by (range) (minio_bucket_objects_size_distribution{job="$scrape_jobs"})`, but every bucket sends this metric. So it takes the metric with the highest (max) value for each size-range, which excludes all values from other buckets in that range.

## Possible Solution
For Grafana:
Using `max by (range) ( sum(minio_bucket_objects_size_distribution{job="$scrape_jobs"}) by (range) )`.
This way it takes the sum of all buckets reporting values for a certain range first.

## Steps to Reproduce (for bugs)

1. Setup grafana-dashboarding with prometheus
2. Create multiple buckets with multiple objects

## Your Environment
* Version used (`minio --version`): RELEASE.2023-01-06T18-11-18Z (commit-id=ebd4388cca5e28619970032e32ddeb2cb51a6b38)
* Operating System and version (`uname -a`): Linux minio01 5.10.0-15-amd64 1 SMP Debian 5.10.120-1 (2022-06-09) x86_64 GNU/Linux



Discussion / hints:
@hamalchristiaan are you interested in sending a fix ? the grafana json is in github.com/minio/minio/docs/metrics/prometheus/grafana/minio-replication.json 
I can't send json-files in these comments. 
This is the "Object size distribution"-visualization as I think it should be in minio-dashboard.json:
```
{
  "datasource": {
    "type": "prometheus",
    "uid": "${DS_PROMETHEUS}"
  },
  "fieldConfig": {
    "defaults": {
      "mappings": [],
      "thresholds": {
        "mode": "absolute",
        "steps": [
          {
            "color": "green",
            "value": null
          },
          {
            "color": "semi-dark-red",
            "value": 80
          }
        ]
      }
    },
    "overrides": []
  },
  "gridPos": {
    "h": 6,
    "w": 5,
    "x": 16,
    "y": 0
  },
  "id": 52,
  "links": [],
  "options": {
    "displayMode": "basic",
    "minVizHeight": 10,
    "minVizWidth": 0,
    "orientation": "horizontal",
    "reduceOptions": {
      "calcs": [
        "mean"
      ],
      "fields": "",
      "values": false
    },
    "showUnfilled": false,
    "text": {}
  },
  "pluginVersion": "9.0.0",
  "targets": [
    {
      "exemplar": true,
      "expr": "max by (range) ( sum(minio_bucket_objects_size_distribution{job=\"$scrape_jobs\"}) by (range) )",
      "format": "time_series",
      "instant": false,
      "interval": "",
      "intervalFactor": 1,
      "legendFormat": "{{range}}",
      "refId": "A",
      "step": 300,
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      }
    }
  ],
  "title": "Object size distribution",
  "type": "bargauge"
},
```

Fix patch:
diff --git a/docs/metrics/prometheus/grafana/minio-dashboard.json b/docs/metrics/prometheus/grafana/minio-dashboard.json
index 9463b4e04c1ae..9904f4af9be09 100644
--- a/docs/metrics/prometheus/grafana/minio-dashboard.json
+++ b/docs/metrics/prometheus/grafana/minio-dashboard.json
@@ -564,7 +564,7 @@
       "targets": [
         {
           "exemplar": true,
-          "expr": "max by (range) (minio_bucket_objects_size_distribution{job=\"$scrape_jobs\"})",
+          "expr": "max by (range) (sum (minio_bucket_objects_size_distribution{job=\"$scrape_jobs\"}) by (range))",
           "format": "time_series",
           "instant": false,
           "interval": "",
diff --git a/docs/metrics/prometheus/grafana/minio-replication.json b/docs/metrics/prometheus/grafana/minio-replication.json
index a52150a5e4c22..ab6ff127d1f23 100644
--- a/docs/metrics/prometheus/grafana/minio-replication.json
+++ b/docs/metrics/prometheus/grafana/minio-replication.json
@@ -438,7 +438,7 @@
         "targets": [
           {
             "exemplar": true,
-            "expr": "max by (range) (minio_bucket_objects_size_distribution{job=\"$scrape_jobs\"})",
+            "expr": "max by (range) (sum (minio_bucket_objects_size_distribution{job=\"$scrape_jobs\"}) by (range))",
             "format": "time_series",
             "instant": false,
             "interval": "",


Test patch: