File tree Expand file tree Collapse file tree 2 files changed +16
-25
lines changed Expand file tree Collapse file tree 2 files changed +16
-25
lines changed Original file line number Diff line number Diff line change @@ -116,35 +116,37 @@ exporter has access to.
116
116
117
117
This should be all the config required to successfully scrape every bucket :
118
118
119
- ` ` `
119
+ ` ` ` yml
120
120
scrape_configs:
121
- - job_name: 's3'
121
+ - job_name: "s3"
122
122
metrics_path: /probe
123
123
http_sd_configs:
124
124
- url: http://127.0.0.1:9340/discovery
125
125
` ` `
126
126
127
- You can limit the buckets returned with the `bucket_pattern` parameter. Refer to
128
- the documentation for [`path.Match`](https://golang.org/pkg/path/#Match) for the
129
- pattern syntax.
127
+ Use `relabel_configs` to select the buckets you want to scrape :
130
128
131
- ```
129
+ ` ` ` yml
132
130
scrape_configs:
133
- - job_name: 's3'
131
+ - job_name: "s3"
134
132
metrics_path: /probe
135
133
http_sd_configs:
136
- # This will only discover buckets with a name that starts with example-
137
- - url: http://127.0.0.1:9340/discovery?bucket_pattern=example- *
134
+ - url: http://127.0.0.1:9340/discovery
135
+ relabel_configs:
136
+ # Keep buckets that start with example-
137
+ - source_labels: [__param_bucket]
138
+ action: keep
139
+ regex: ^example-.*
138
140
` ` `
139
141
140
142
The prefix can be set too, but be mindful that this will apply to all buckets :
141
143
142
- ```
144
+ ` ` ` yml
143
145
scrape_configs:
144
- - job_name: 's3'
146
+ - job_name: "s3"
145
147
metrics_path: /probe
146
148
http_sd_configs:
147
- - url: http://127.0.0.1:9340/discovery?bucket_pattern=example- *
149
+ - url: http://127.0.0.1:9340/discovery
148
150
params:
149
151
prefix: ["thing.txt"]
150
152
` ` `
Original file line number Diff line number Diff line change 4
4
"encoding/json"
5
5
"net/http"
6
6
"os"
7
- "path"
8
7
"time"
9
8
10
9
"github.com/prometheus/client_golang/prometheus"
@@ -173,27 +172,17 @@ type discoveryTarget struct {
173
172
}
174
173
175
174
func discoveryHandler (w http.ResponseWriter , r * http.Request , svc s3iface.S3API ) {
176
- // If a bucket pattern isn't specified, then return every bucket
177
- bucketPattern := r .URL .Query ().Get ("bucket_pattern" )
178
- if bucketPattern == "" {
179
- bucketPattern = "*"
180
- }
181
-
182
175
result , err := svc .ListBuckets (& s3.ListBucketsInput {})
183
176
if err != nil {
177
+ log .Errorln (err )
184
178
http .Error (w , "error listing buckets" , http .StatusInternalServerError )
185
179
return
186
180
}
187
181
188
182
targets := []discoveryTarget {}
189
183
for _ , b := range result .Buckets {
190
184
name := aws .StringValue (b .Name )
191
-
192
- matched , err := path .Match (bucketPattern , name )
193
- if err != nil {
194
- http .Error (w , "bad pattern provided for 'bucket_pattern'" , http .StatusBadRequest )
195
- }
196
- if matched {
185
+ if name != "" {
197
186
t := discoveryTarget {
198
187
Targets : []string {r .Host },
199
188
Labels : map [string ]string {
You can’t perform that action at this time.
0 commit comments