Skip to content

Commit

Permalink
Wire up Promql query logging
Browse files Browse the repository at this point in the history
Fixes #653
  • Loading branch information
jacksontj committed Jul 14, 2024
1 parent f83875e commit de9be43
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cmd/promxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"github.com/prometheus/prometheus/rules"
"github.com/prometheus/prometheus/scrape"
"github.com/prometheus/prometheus/storage"
promlogging "github.com/prometheus/prometheus/util/logging"
"github.com/prometheus/prometheus/util/strutil"
"github.com/prometheus/prometheus/web"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -369,6 +370,22 @@ func main() {
return nil
}}))

// PromQL query engine reloadable
reloadables = append(reloadables, proxyconfig.WrapPromReloadable(&proxyconfig.ApplyConfigFunc{func(cfg *config.Config) error {
if cfg.GlobalConfig.QueryLogFile == "" {
engine.SetQueryLogger(nil)
return nil
}

l, err := promlogging.NewJSONFileLogger(cfg.GlobalConfig.QueryLogFile)
if err != nil {
return err
}
engine.SetQueryLogger(l)

return nil
}}))

// We need an empty scrape manager, simply to make the API not panic and error out
scrapeManager := scrape.NewManager(nil, kitlog.With(logger, "component", "scrape manager"), nil)

Expand Down

0 comments on commit de9be43

Please sign in to comment.