storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/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.
     4  
     5  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.
     6  
     7  MinIO exports Prometheus compatible data by default as an authorized endpoint at `/minio/v2/metrics/cluster`. Users looking to monitor their MinIO instances can point Prometheus configuration to scrape data from this endpoint. This document explains how to setup Prometheus and configure it to scrape data from MinIO servers.
     8  
     9  **Table of Contents**
    10  
    11  - [Prerequisites](#prerequisites)
    12      - [1. Download Prometheus](#1-download-prometheus)
    13      - [2. Configure authentication type for Prometheus metrics](#2-configure-authentication-type-for-prometheus-metrics)
    14      - [3. Configuring Prometheus](#3-configuring-prometheus)
    15          - [3.1 Authenticated Prometheus config](#31-authenticated-prometheus-config)
    16          - [3.2 Public Prometheus config](#32-public-prometheus-config)
    17      - [4. Update `scrape_configs` section in prometheus.yml](#4-update-scrapeconfigs-section-in-prometheusyml)
    18      - [5. Start Prometheus](#5-start-prometheus)
    19      - [6. Configure Grafana](#6-configure-grafana)
    20  - [List of metrics exposed by MinIO](#list-of-metrics-exposed-by-minio)
    21  
    22  ## Prerequisites
    23  To get started with MinIO, refer [MinIO QuickStart Document](https://docs.min.io/docs/minio-quickstart-guide).
    24  Follow below steps to get started with MinIO monitoring using Prometheus.
    25  
    26  ### 1. Download Prometheus
    27  
    28  [Download the latest release](https://prometheus.io/download) of Prometheus for your platform, then extract it
    29  
    30  ```sh
    31  tar xvfz prometheus-*.tar.gz
    32  cd prometheus-*
    33  ```
    34  
    35  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
    36  
    37  ```sh
    38  ./prometheus --help
    39  usage: prometheus [<flags>]
    40  
    41  The Prometheus monitoring server
    42  
    43  . . .
    44  ```
    45  
    46  Refer [Prometheus documentation](https://prometheus.io/docs/introduction/first_steps/) for more details.
    47  
    48  ### 2. Configure authentication type for Prometheus metrics
    49  
    50  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.
    51  
    52  ```
    53  export MINIO_PROMETHEUS_AUTH_TYPE="public"
    54  minio server ~/test
    55  ```
    56  
    57  ### 3. Configuring Prometheus
    58  
    59  #### 3.1 Authenticated Prometheus config
    60  
    61  > 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.
    62  
    63  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://docs.min.io/docs/minio-client-quickstart-guide) as follows `mc admin prometheus generate <alias>`.
    64  
    65  The command will generate the `scrape_configs` section of the prometheus.yml as follows:
    66  
    67  ```yaml
    68  scrape_configs:
    69  - job_name: minio-job
    70    bearer_token: <secret>
    71    metrics_path: /minio/v2/metrics/cluster
    72    scheme: http
    73    static_configs:
    74    - targets: ['localhost:9000']
    75  ```
    76  
    77  #### 3.2 Public Prometheus config
    78  
    79  If Prometheus endpoint authentication type is set to `public`. Following prometheus config is sufficient to start scraping metrics data from MinIO.
    80  This can be collected from any server once per collection.
    81  
    82  ##### Cluster
    83  ```yaml
    84  scrape_configs:
    85  - job_name: minio-job
    86    metrics_path: /minio/v2/metrics/cluster
    87    scheme: http
    88    static_configs:
    89    - targets: ['localhost:9000']
    90  ```
    91  
    92  ##### Node (optional)
    93  Optionally you can also collect per node metrics. This needs to be done on a per server instance.
    94  ```yaml
    95  scrape_configs:
    96  - job_name: minio-job
    97    metrics_path: /minio/v2/metrics/node
    98    scheme: http
    99    static_configs:
   100    - targets: ['localhost:9000']
   101  ```
   102  
   103  ### 4. Update `scrape_configs` section in prometheus.yml
   104  
   105  To authorize every scrape request, copy and paste the generated `scrape_configs` section in the prometheus.yml and restart the Prometheus service.
   106  
   107  ### 5. Start Prometheus
   108  
   109  Start (or) Restart Prometheus service by running
   110  
   111  ```sh
   112  ./prometheus --config.file=prometheus.yml
   113  ```
   114  
   115  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`.
   116  
   117  ### 6. Configure Grafana
   118  
   119  After Prometheus is configured, you can use Grafana to visualize MinIO metrics.
   120  Refer the [document here to setup Grafana with MinIO prometheus metrics](https://github.com/minio/minio/blob/master/docs/metrics/prometheus/grafana/README.md).
   121  
   122  ## List of metrics exposed by MinIO
   123  
   124  MinIO server exposes the following metrics on `/minio/v2/metrics/cluster` endpoint. All of these can be accessed via Prometheus dashboard. A sample list of exposed metrics along with their definition is available in the demo server at
   125  
   126  ```sh
   127  curl https://play.min.io/minio/v2/metrics/cluster
   128  ```
   129  
   130  ### List of metrics reported
   131  
   132  [The list of metrics reported can be here](https://github.com/minio/minio/blob/master/docs/metrics/prometheus/list.md)