Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added query logging for prometheus. Issue #1315 #5794

merged 10 commits into from Jul 31, 2019

Fixed an error regarding file creation

Signed-off-by: Advait Bhatwadekar <>
  • Loading branch information...
You-NeverKnow committed Jul 30, 2019
commit aac9f524cc957e34ac2609a76e15fb380ea8307b
@@ -358,7 +358,7 @@ func main() {
MaxConcurrent: cfg.queryConcurrency,
MaxSamples: cfg.queryMaxSamples,
Timeout: time.Duration(cfg.queryTimeout),
ActiveQueryTracker: promql.NewActiveQueryTracker(cfg.queryConcurrency, log.With(logger, "component", "activeQueryTracker")),
ActiveQueryTracker: promql.NewActiveQueryTracker(cfg.localStoragePath, cfg.queryConcurrency, log.With(logger, "component", "activeQueryTracker")),

queryEngine = promql.NewEngine(opts)
@@ -19,6 +19,7 @@ import (
@@ -97,8 +98,13 @@ func getMMapedFile(filename string, filesize int, logger log.Logger) (error, []b
return err, fileAsBytes

func NewActiveQueryTracker(maxQueries int, logger log.Logger) *ActiveQueryTracker {
filename, filesize := "data/", 1+maxQueries*entrySize
func NewActiveQueryTracker(localStoragePath string, maxQueries int, logger log.Logger) *ActiveQueryTracker {
err := os.MkdirAll(localStoragePath, 0777)
if err != nil {
level.Error(logger).Log("msg", "Failed to create directory for logging active queries")

filename, filesize := filepath.Join(localStoragePath, ""), 1+maxQueries*entrySize
logUnfinishedQueries(filename, filesize, logger)

err, fileAsBytes := getMMapedFile(filename, filesize, logger)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.