Skip to content

Commit

Permalink
Add more explicit logging RE recording rules
Browse files Browse the repository at this point in the history
Promxy doesn't currently support storing recording rules, because
prometheus has no remote write API -- meaning promxy has no place to put
the metrics. This used to log (before the 2.x upgrade)-- but that was
dropped and this is confusing again.

This patch adds 2 layers of logging. (1) in main it checks for recording
rules on start (where it will fatal log) and on reload (error log) (2)
the ProxyStorage.Appender() now also logs a warning. This will remain in
place until #79 (the long term plan) is figured out and executed

Fixes #74
  • Loading branch information
jacksontj committed Sep 25, 2018
1 parent cc96b30 commit 0163556
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cmd/promxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,22 @@ func main() {
logrus.Fatalf("Error loading config: %s", err)
}

// Our own checks on top of the config
checkConfig := func() error {
// check for any recording rules, if we find any lets log a fatal and stop
// https://github.com/jacksontj/promxy/issues/74
for _, rule := range ruleManager.Rules() {
if _, ok := rule.(*rules.RecordingRule); ok {
return fmt.Errorf("Promxy doesn't support recording rules: %s", rule)
}
}
return nil
}

if err := checkConfig(); err != nil {
logrus.Fatalf("Error checking config: %v", err)
}

close(reloadReady)

// Set up access logger
Expand Down Expand Up @@ -349,6 +365,9 @@ func main() {
if err := reloadConfig(reloadables...); err != nil {
log.Errorf("Error reloading config: %s", err)
}
if err := checkConfig(); err != nil {
logrus.Errorf("Error checking config: %v", err)
}
case syscall.SIGTERM, syscall.SIGINT:
log.Infof("promxy exiting")
cancel()
Expand Down
1 change: 1 addition & 0 deletions proxystorage/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func (a *appenderStub) Commit() error { return nil }
func (a *appenderStub) Rollback() error { return nil }

func (p *ProxyStorage) Appender() (storage.Appender, error) {
logrus.Warning("Promxy cannot *write* metrics but is being asked to. This is likely due to a RecordingRule")
return &appenderStub{}, nil
}

Expand Down

0 comments on commit 0163556

Please sign in to comment.