|
| 1 | +--- |
| 2 | +page_title: "minio_prometheus_scrape_config Data Source - terraform-provider-minio" |
| 3 | +subcategory: "" |
| 4 | +description: |- |
| 5 | + Generates Prometheus scrape configuration for MinIO metrics endpoints. |
| 6 | +--- |
| 7 | + |
| 8 | +# minio_prometheus_scrape_config (Data Source) |
| 9 | + |
| 10 | +Generates Prometheus scrape configuration for MinIO metrics endpoints. |
| 11 | + |
| 12 | +## Example Usage |
| 13 | + |
| 14 | +```terraform |
| 15 | +# Generate scrape configuration for cluster metrics |
| 16 | +data "minio_prometheus_scrape_config" "cluster" { |
| 17 | + metric_type = "cluster" |
| 18 | + alias = "minio-cluster" |
| 19 | +} |
| 20 | +
|
| 21 | +# Generate scrape configuration for node metrics |
| 22 | +data "minio_prometheus_scrape_config" "node" { |
| 23 | + metric_type = "node" |
| 24 | + alias = "minio-nodes" |
| 25 | +} |
| 26 | +
|
| 27 | +# Generate scrape configuration for bucket metrics with v2 metrics |
| 28 | +data "minio_prometheus_scrape_config" "bucket" { |
| 29 | + metric_type = "bucket" |
| 30 | + alias = "minio-buckets" |
| 31 | + metrics_version = "v2" |
| 32 | +} |
| 33 | +
|
| 34 | +# Generate scrape configuration for resource metrics with bearer token |
| 35 | +data "minio_prometheus_scrape_config" "resource" { |
| 36 | + metric_type = "resource" |
| 37 | + alias = "minio-resources" |
| 38 | + bearer_token = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9..." |
| 39 | +} |
| 40 | +``` |
| 41 | + |
| 42 | +## Using with Bearer Token Resource |
| 43 | + |
| 44 | +```terraform |
| 45 | +# Create a bearer token for authenticated access |
| 46 | +resource "minio_prometheus_bearer_token" "cluster_token" { |
| 47 | + metric_type = "cluster" |
| 48 | + expires_in = "24h" |
| 49 | +} |
| 50 | +
|
| 51 | +# Generate authenticated scrape configuration |
| 52 | +data "minio_prometheus_scrape_config" "cluster_auth" { |
| 53 | + metric_type = "cluster" |
| 54 | + alias = "minio-cluster-auth" |
| 55 | + bearer_token = minio_prometheus_bearer_token.cluster_token.token |
| 56 | +} |
| 57 | +
|
| 58 | +# Output the complete Prometheus configuration |
| 59 | +output "prometheus_config" { |
| 60 | + value = data.minio_prometheus_scrape_config.cluster_auth.scrape_config |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +## Complete Prometheus Configuration Example |
| 65 | + |
| 66 | +```terraform |
| 67 | +# Generate scrape configs for all metric types |
| 68 | +data "minio_prometheus_scrape_config" "cluster" { |
| 69 | + metric_type = "cluster" |
| 70 | + alias = "minio-cluster" |
| 71 | +} |
| 72 | +
|
| 73 | +data "minio_prometheus_scrape_config" "node" { |
| 74 | + metric_type = "node" |
| 75 | + alias = "minio-nodes" |
| 76 | +} |
| 77 | +
|
| 78 | +data "minio_prometheus_scrape_config" "bucket" { |
| 79 | + metric_type = "bucket" |
| 80 | + alias = "minio-buckets" |
| 81 | +} |
| 82 | +
|
| 83 | +data "minio_prometheus_scrape_config" "resource" { |
| 84 | + metric_type = "resource" |
| 85 | + alias = "minio-resources" |
| 86 | +} |
| 87 | +
|
| 88 | +# Combine all scrape configs |
| 89 | +locals { |
| 90 | + prometheus_config = <<-EOT |
| 91 | + ${data.minio_prometheus_scrape_config.cluster.scrape_config} |
| 92 | + |
| 93 | + ${data.minio_prometheus_scrape_config.node.scrape_config} |
| 94 | + |
| 95 | + ${data.minio_prometheus_scrape_config.bucket.scrape_config} |
| 96 | + |
| 97 | + ${data.minio_prometheus_scrape_config.resource.scrape_config} |
| 98 | + EOT |
| 99 | +} |
| 100 | +
|
| 101 | +output "complete_prometheus_config" { |
| 102 | + value = local.prometheus_config |
| 103 | +} |
| 104 | +``` |
| 105 | + |
| 106 | +<!-- schema generated by tfplugindocs --> |
| 107 | +## Schema |
| 108 | + |
| 109 | +### Required |
| 110 | + |
| 111 | +- `metric_type` (String) Metric type for the scrape configuration. Valid values are: cluster, node, bucket, resource |
| 112 | + |
| 113 | +### Optional |
| 114 | + |
| 115 | +- `alias` (String) Alias for the MinIO server in Prometheus configuration |
| 116 | +- `bearer_token` (String, Sensitive) Bearer token for authenticated access to Prometheus metrics (when using JWT auth) |
| 117 | +- `metrics_version` (String) Metrics version. Valid values are: v2, v3 |
| 118 | + |
| 119 | +### Read-Only |
| 120 | + |
| 121 | +- `id` (String) The ID of this resource. |
| 122 | +- `metrics_path` (String) Metrics endpoint path |
| 123 | +- `scrape_config` (String, Sensitive) Generated Prometheus scrape configuration in YAML format |
| 124 | + |
| 125 | +## Metric Types |
| 126 | + |
| 127 | +- **cluster**: Cluster-level metrics including server status, usage, and performance |
| 128 | +- **node**: Node-specific metrics for individual MinIO servers in a cluster |
| 129 | +- **bucket**: Bucket-level metrics including object counts, sizes, and operations |
| 130 | +- **resource**: Resource utilization metrics for CPU, memory, and disk |
| 131 | + |
| 132 | +## Metrics Versions |
| 133 | + |
| 134 | +- **v2**: Legacy metrics format (`/minio/v2/metrics/{type}`) |
| 135 | +- **v3**: Current metrics format (`/minio/metrics/v3?type={type}`) - default |
| 136 | + |
| 137 | +## Authentication |
| 138 | + |
| 139 | +The data source supports both unauthenticated and authenticated access: |
| 140 | + |
| 141 | +1. **Unauthenticated**: Omit the `bearer_token` field for public metrics endpoints |
| 142 | +2. **Authenticated**: Provide a JWT bearer token for secure metrics access |
| 143 | + |
| 144 | +Use the `minio_prometheus_bearer_token` resource to generate valid tokens. |
| 145 | + |
| 146 | +## Generated Configuration |
| 147 | + |
| 148 | +The generated scrape configuration includes: |
| 149 | + |
| 150 | +- Job name based on the alias |
| 151 | +- Metrics path for the specified metric type and version |
| 152 | +- Scheme (http/https) based on provider SSL configuration |
| 153 | +- Bearer token (if provided) |
| 154 | +- Static config with the MinIO server endpoint |
| 155 | + |
| 156 | +Example output: |
| 157 | +```yaml |
| 158 | +scrape_configs: |
| 159 | + - job_name: minio-cluster |
| 160 | + metrics_path: /minio/metrics/v3?type=cluster |
| 161 | + scheme: https |
| 162 | + bearer_token: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9... |
| 163 | + static_configs: |
| 164 | + - targets: ["minio.example.com:9000"] |
| 165 | +``` |
0 commit comments