-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (36 loc) · 840 Bytes
/
main.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
package main
import (
"os"
"context"
"github.com/go-kit/kit/log"
"net/url"
"github.com/improbable-eng/thanos/pkg/reloader"
"flag"
)
func main() {
baseurl := flag.String("url", "http://localhost:9090", "The base url to Prometheus")
input := flag.String("input", "", "The input template file")
output := flag.String("output", "", "The output file")
flag.Parse()
rules := flag.Args()
w := log.NewSyncWriter(os.Stderr)
logger := log.NewLogfmtLogger(w)
u, err := url.Parse(*baseurl)
if err != nil {
logger.Log("err", err)
os.Exit(1)
}
rl := reloader.New(
logger,
reloader.ReloadURLFromBase(u),
*input,
*output,
rules,
)
ctx, cancel := context.WithCancel(context.Background())
if err := rl.Watch(ctx); err != nil {
cancel()
logger.Log("err", err)
os.Exit(1)
}
}