MCPcopy Create free account
hub / github.com/cortexproject/cortex / main

Function main

cmd/query-tee/main.go:24–60  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22}
23
24func main() {
25 // Parse CLI flags.
26 cfg := Config{}
27 flag.IntVar(&cfg.ServerMetricsPort, "server.metrics-port", 9900, "The port where metrics are exposed.")
28 flag.StringVar(&cfg.PathPrefix, "server.path-prefix", "", "Prefix for API paths (query-tee will accept Prometheus API calls at <prefix>/api/v1/...)")
29 cfg.LogLevel.RegisterFlags(flag.CommandLine)
30 cfg.ProxyConfig.RegisterFlags(flag.CommandLine)
31 flag.Parse()
32
33 util_log.InitLogger(&server.Config{
34 LogLevel: cfg.LogLevel,
35 })
36
37 // Run the instrumentation server.
38 registry := prometheus.NewRegistry()
39 registry.MustRegister(collectors.NewGoCollector())
40
41 i := querytee.NewInstrumentationServer(cfg.ServerMetricsPort, registry)
42 if err := i.Start(); err != nil {
43 level.Error(util_log.Logger).Log("msg", "Unable to start instrumentation server", "err", err.Error())
44 os.Exit(1)
45 }
46
47 // Run the proxy.
48 proxy, err := querytee.NewProxy(cfg.ProxyConfig, util_log.Logger, cortexReadRoutes(cfg), registry)
49 if err != nil {
50 level.Error(util_log.Logger).Log("msg", "Unable to initialize the proxy", "err", err.Error())
51 os.Exit(1)
52 }
53
54 if err := proxy.Start(); err != nil {
55 level.Error(util_log.Logger).Log("msg", "Unable to start the proxy", "err", err.Error())
56 os.Exit(1)
57 }
58
59 proxy.Await()
60}
61
62func cortexReadRoutes(cfg Config) []querytee.Route {
63 prefix := cfg.PathPrefix

Callers

nothing calls this directly

Calls 10

StartMethod · 0.95
StartMethod · 0.95
AwaitMethod · 0.95
NewInstrumentationServerFunction · 0.92
NewProxyFunction · 0.92
cortexReadRoutesFunction · 0.85
ParseMethod · 0.80
RegisterFlagsMethod · 0.65
LogMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected