github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/docs/metrics/prometheus/README.md (about) 1 # How to monitor MinIO server with Prometheus? [![Slack](https://slack.min.io/slack?type=svg)](https://slack.min.io) 2 3 [Prometheus](https://prometheus.io) is a cloud-native monitoring platform. Prometheus offers a multi-dimensional data model with time series data identified by metric name and key/value pairs. The data collection happens via a pull model over HTTP/HTTPS. Users looking to monitor their MinIO instances can point Prometheus configuration to scrape data from following endpoints. 4 5 - MinIO exports Prometheus compatible data by default as an authorized endpoint at `/minio/v2/metrics/cluster`. 6 - MinIO exports Prometheus compatible data by default which is bucket centric as an authorized endpoint at `/minio/v2/metrics/bucket`. 7 8 This document explains how to setup Prometheus and configure it to scrape data from MinIO servers. 9 10 ## Prerequisites 11 12 To get started with MinIO, refer [MinIO QuickStart Document](https://min.io/docs/minio/linux/index.html#quickstart-for-linux). 13 Follow below steps to get started with MinIO monitoring using Prometheus. 14 15 ### 1. Download Prometheus 16 17 [Download the latest release](https://prometheus.io/download) of Prometheus for your platform, then extract it 18 19 ```sh 20 tar xvfz prometheus-*.tar.gz 21 cd prometheus-* 22 ``` 23 24 Prometheus server is a single binary called `prometheus` (or `prometheus.exe` on Microsoft Windows). Run the binary and pass `--help` flag to see available options 25 26 ```sh 27 ./prometheus --help 28 usage: prometheus [<flags>] 29 30 The Prometheus monitoring server 31 32 . . . 33 ``` 34 35 Refer [Prometheus documentation](https://prometheus.io/docs/introduction/first_steps/) for more details. 36 37 ### 2. Configure authentication type for Prometheus metrics 38 39 MinIO supports two authentication modes for Prometheus either `jwt` or `public`, by default MinIO runs in `jwt` mode. To allow public access without authentication for prometheus metrics set environment as follows. 40 41 ``` 42 export MINIO_PROMETHEUS_AUTH_TYPE="public" 43 minio server ~/test 44 ``` 45 46 ### 3. Configuring Prometheus 47 48 #### 3.1 Authenticated Prometheus config 49 50 > If MinIO is configured to expose metrics without authentication, you don't need to use `mc` to generate prometheus config. You can skip reading further and move to 3.2 section. 51 52 The Prometheus endpoint in MinIO requires authentication by default. Prometheus supports a bearer token approach to authenticate prometheus scrape requests, override the default Prometheus config with the one generated using mc. To generate a Prometheus config for an alias, use [mc](https://min.io/docs/minio/linux/reference/minio-mc.html#quickstart) as follows `mc admin prometheus generate <alias> [METRIC-TYPE]`. The valid values for METRIC-TYPE are `cluster`, `node`, `bucket` and `resource` and if not mentioned, it defaults to `cluster`. 53 54 The command will generate the `scrape_configs` section of the prometheus.yml as follows: 55 56 ##### Cluster 57 58 ```yaml 59 scrape_configs: 60 - job_name: minio-job 61 bearer_token: <secret> 62 metrics_path: /minio/v2/metrics/cluster 63 scheme: http 64 static_configs: 65 - targets: ['localhost:9000'] 66 ``` 67 68 ##### Bucket centric 69 70 ```yaml 71 - job_name: minio-job-bucket 72 bearer_token: <secret> 73 metrics_path: /minio/v2/metrics/bucket 74 scheme: http 75 static_configs: 76 - targets: ['localhost:9000'] 77 ``` 78 79 ##### Node centric (optional) 80 81 ```yaml 82 - job_name: minio-job-node 83 bearer_token: <secret> 84 metrics_path: /minio/v2/metrics/node 85 scheme: http 86 static_configs: 87 - targets: ['localhost:9000'] 88 ``` 89 90 ##### Resource centric (optional) 91 92 ```yaml 93 - job_name: minio-job-resource 94 bearer_token: <secret> 95 metrics_path: /minio/v2/metrics/resource 96 scheme: http 97 static_configs: 98 - targets: ['localhost:9000'] 99 ``` 100 101 #### 3.2 Public Prometheus config 102 103 If Prometheus endpoint authentication type is set to `public`. Following prometheus config is sufficient to start scraping metrics data from MinIO. 104 This can be collected from any server once per collection. 105 106 ##### Cluster 107 108 ```yaml 109 scrape_configs: 110 - job_name: minio-job 111 metrics_path: /minio/v2/metrics/cluster 112 scheme: http 113 static_configs: 114 - targets: ['localhost:9000'] 115 ``` 116 117 #### Bucket centric 118 119 ```yaml 120 scrape_configs: 121 - job_name: minio-job-bucket 122 metrics_path: /minio/v2/metrics/bucket 123 scheme: http 124 static_configs: 125 - targets: ['localhost:9000'] 126 ``` 127 128 ##### Node (optional) 129 130 Optionally you can also collect per node metrics. This needs to be done on a per server instance. 131 132 ```yaml 133 scrape_configs: 134 - job_name: minio-job 135 metrics_path: /minio/v2/metrics/node 136 scheme: http 137 static_configs: 138 - targets: ['localhost:9000'] 139 ``` 140 141 ##### Resource (optional) 142 143 Optionally you can also collect resource metrics. 144 145 ```yaml 146 scrape_configs: 147 - job_name: minio-job 148 metrics_path: /minio/v2/metrics/resource 149 scheme: http 150 static_configs: 151 - targets: ['localhost:9000'] 152 ``` 153 154 ### 4. Update `scrape_configs` section in prometheus.yml 155 156 To authorize every scrape request, copy and paste the generated `scrape_configs` section in the prometheus.yml and restart the Prometheus service. 157 158 ### 5. Start Prometheus 159 160 Start (or) Restart Prometheus service by running 161 162 ```sh 163 ./prometheus --config.file=prometheus.yml 164 ``` 165 166 Here `prometheus.yml` is the name of configuration file. You can now see MinIO metrics in Prometheus dashboard. By default Prometheus dashboard is accessible at `http://localhost:9090`. 167 168 Prometheus sets the `Host` header to `domain:port` as part of HTTP operations against the MinIO metrics endpoint. For MinIO deployments behind a load balancer, reverse proxy, or other control plane (HAProxy, nginx, pfsense, opnsense, etc.), ensure the network service supports routing these requests to the deployment. 169 170 ### 6. Configure Grafana 171 172 After Prometheus is configured, you can use Grafana to visualize MinIO metrics. Refer the [document here to setup Grafana with MinIO prometheus metrics](https://github.com/minio/minio/blob/master/docs/metrics/prometheus/grafana/README.md). 173 174 ## List of metrics exposed by MinIO 175 176 - MinIO exports Prometheus compatible data by default as an authorized endpoint at `/minio/v2/metrics/cluster`. 177 - MinIO exports Prometheus compatible data by default which is bucket centric as an authorized endpoint at `/minio/v2/metrics/bucket`. 178 - MinIO exports Prometheus compatible data by default which is node centric as an authorized endpoint at `/minio/v2/metrics/node`. 179 - MinIO exports Prometheus compatible data by default which is resource centric as an authorized endpoint at `/minio/v2/metrics/resource`. 180 181 All of these can be accessed via Prometheus dashboard. A sample list of exposed metrics along with their definition is available on our public demo server at 182 183 ```sh 184 curl https://play.min.io/minio/v2/metrics/cluster 185 ``` 186 187 ### List of metrics reported Cluster and Bucket level 188 189 [The list of metrics reported can be here](https://github.com/minio/minio/blob/master/docs/metrics/prometheus/list.md) 190 191 ### Configure Alerts for Prometheus 192 193 [The Prometheus AlertManager and alerts can be configured following this](https://github.com/minio/minio/blob/master/docs/metrics/prometheus/alerts.md)