forked from pedro-stanaka/prom-scrape-analyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.go
52 lines (42 loc) · 1.23 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"time"
"github.com/docker/go-units"
"github.com/pkg/errors"
"github.com/thanos-io/thanos/pkg/extkingpin"
)
type Options struct {
ScrapeURL string
ScrapeFile string
OutputHeight int
MaxScrapeSize string
Timeout time.Duration
HttpConfigFile string
}
func (o *Options) MaxScrapeSizeBytes() (int64, error) {
size, err := units.FromHumanSize(o.MaxScrapeSize)
if err != nil {
return 0, errors.Wrap(err, "invalid max scrape size")
}
return size, nil
}
func (o *Options) AddFlags(app extkingpin.AppClause) {
app.Flag("scrape.url", "URL to scrape metrics from").
Default("").
StringVar(&o.ScrapeURL)
app.Flag("scrape.file", "File to scrape metrics from").
Default("").
StringVar(&o.ScrapeFile)
app.Flag("timeout", "Timeout for the scrape request").
Default("10s").
DurationVar(&o.Timeout)
app.Flag("output-height", "Height of the output table").
Default("40").
IntVar(&o.OutputHeight)
app.Flag("max-scrape-size", "Maximum size of the scrape response body (e.g. 10MB, 1GB)").
Default("100MB").
StringVar(&o.MaxScrapeSize)
app.Flag("http.config", "Path to file to use for HTTP client config options like basic auth and TLS.").
Default("").
StringVar(&o.HttpConfigFile)
}