Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "tsl", Short: "A proxy that translates queries for a TSDB backend", Run: func(cmd *cobra.Command, args []string) { r := echo.New() addr := viper.GetString("listen") r.Logger.SetOutput(ioutil.Discard) r.Use(middleware.MethodOverride()) r.Use(middleware.Secure()) r.Use(middleware.Recover()) r.Use(middlewares.CORS()) r.Use(middlewares.Logger()) r.Any("/", func(ctx echo.Context) error { return ctx.NoContent(http.StatusOK) }) promRegistry := prometheus.NewRegistry() tsl := proxy.NewProxyTSL(promRegistry) r.POST("/v0/query", tsl.Query) r.Any("/metrics", echo.WrapHandler(promhttp.HandlerFor(promRegistry, promhttp.HandlerOpts{}))) server := &http.Server{ Handler: r, Addr: addr, } go func() { log.Infof("Start tsl server on %s", server.Addr) if err := server.ListenAndServe(); err != nil { log.Fatal(err) } }() quit := make(chan os.Signal, 1) signal.Notify(quit, os.Interrupt) <-quit ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() if err := server.Shutdown(ctx); err != nil { log.WithFields(log.Fields{ "error": err, }).Fatal("Cannot gracefully shutdown tsl server") } }, }
RootCmd represents the base command when called without any subcommands
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.