Commit 36f3accf by Marcus Efraimsson

log phantomjs output even if it timeout and include orgId when render alert

parent 63e7330f
...@@ -25,6 +25,7 @@ var filters map[string]log15.Lvl ...@@ -25,6 +25,7 @@ var filters map[string]log15.Lvl
func init() { func init() {
loggersToClose = make([]DisposableHandler, 0) loggersToClose = make([]DisposableHandler, 0)
loggersToReload = make([]ReloadableHandler, 0) loggersToReload = make([]ReloadableHandler, 0)
filters = map[string]log15.Lvl{}
Root = log15.Root() Root = log15.Root()
Root.SetHandler(log15.DiscardHandler()) Root.SetHandler(log15.DiscardHandler())
} }
...@@ -197,7 +198,7 @@ func ReadLoggingConfig(modes []string, logsPath string, cfg *ini.File) { ...@@ -197,7 +198,7 @@ func ReadLoggingConfig(modes []string, logsPath string, cfg *ini.File) {
// Log level. // Log level.
_, level := getLogLevelFromConfig("log."+mode, defaultLevelName, cfg) _, level := getLogLevelFromConfig("log."+mode, defaultLevelName, cfg)
filters := getFilters(util.SplitString(sec.Key("filters").String())) modeFilters := getFilters(util.SplitString(sec.Key("filters").String()))
format := getLogFormat(sec.Key("format").MustString("")) format := getLogFormat(sec.Key("format").MustString(""))
var handler log15.Handler var handler log15.Handler
...@@ -230,12 +231,18 @@ func ReadLoggingConfig(modes []string, logsPath string, cfg *ini.File) { ...@@ -230,12 +231,18 @@ func ReadLoggingConfig(modes []string, logsPath string, cfg *ini.File) {
} }
for key, value := range defaultFilters { for key, value := range defaultFilters {
if _, exist := modeFilters[key]; !exist {
modeFilters[key] = value
}
}
for key, value := range modeFilters {
if _, exist := filters[key]; !exist { if _, exist := filters[key]; !exist {
filters[key] = value filters[key] = value
} }
} }
handler = LogFilterHandler(level, filters, handler) handler = LogFilterHandler(level, modeFilters, handler)
handlers = append(handlers, handler) handlers = append(handlers, handler)
} }
......
...@@ -138,7 +138,7 @@ func (n *notificationService) uploadImage(context *EvalContext) (err error) { ...@@ -138,7 +138,7 @@ func (n *notificationService) uploadImage(context *EvalContext) (err error) {
return err return err
} }
renderOpts.Path = fmt.Sprintf("d-solo/%s/%s?panelId=%d", ref.Uid, ref.Slug, context.Rule.PanelId) renderOpts.Path = fmt.Sprintf("d-solo/%s/%s?orgId=%d&panelId=%d", ref.Uid, ref.Slug, context.Rule.OrgId, context.Rule.PanelId)
result, err := n.renderService.Render(context.Ctx, renderOpts) result, err := n.renderService.Render(context.Ctx, renderOpts)
if err != nil { if err != nil {
......
...@@ -36,7 +36,7 @@ func (rs *RenderingService) renderViaPhantomJS(ctx context.Context, opts Opts) ( ...@@ -36,7 +36,7 @@ func (rs *RenderingService) renderViaPhantomJS(ctx context.Context, opts Opts) (
defer middleware.RemoveRenderAuthKey(renderKey) defer middleware.RemoveRenderAuthKey(renderKey)
phantomDebugArg := "--debug=false" phantomDebugArg := "--debug=false"
if log.GetLogLevelFor("renderer") >= log.LvlDebug { if log.GetLogLevelFor("rendering") >= log.LvlDebug {
phantomDebugArg = "--debug=true" phantomDebugArg = "--debug=true"
} }
...@@ -64,13 +64,26 @@ func (rs *RenderingService) renderViaPhantomJS(ctx context.Context, opts Opts) ( ...@@ -64,13 +64,26 @@ func (rs *RenderingService) renderViaPhantomJS(ctx context.Context, opts Opts) (
cmd := exec.CommandContext(commandCtx, binPath, cmdArgs...) cmd := exec.CommandContext(commandCtx, binPath, cmdArgs...)
cmd.Stderr = cmd.Stdout cmd.Stderr = cmd.Stdout
timezone := ""
if opts.Timezone != "" { if opts.Timezone != "" {
timezone = isoTimeOffsetToPosixTz(opts.Timezone)
baseEnviron := os.Environ() baseEnviron := os.Environ()
cmd.Env = appendEnviron(baseEnviron, "TZ", isoTimeOffsetToPosixTz(opts.Timezone)) cmd.Env = appendEnviron(baseEnviron, "TZ", timezone)
} }
rs.log.Debug("executing Phantomjs", "binPath", binPath, "cmdArgs", cmdArgs, "timezone", timezone)
out, err := cmd.Output() out, err := cmd.Output()
if out != nil {
rs.log.Debug("Phantomjs output", "out", string(out))
}
if err != nil {
rs.log.Debug("Phantomjs error", "error", err)
}
// check for timeout first // check for timeout first
if commandCtx.Err() == context.DeadlineExceeded { if commandCtx.Err() == context.DeadlineExceeded {
rs.log.Info("Rendering timed out") rs.log.Info("Rendering timed out")
...@@ -82,8 +95,6 @@ func (rs *RenderingService) renderViaPhantomJS(ctx context.Context, opts Opts) ( ...@@ -82,8 +95,6 @@ func (rs *RenderingService) renderViaPhantomJS(ctx context.Context, opts Opts) (
return nil, err return nil, err
} }
rs.log.Debug("Phantomjs output", "out", string(out))
rs.log.Debug("Image rendered", "path", pngPath) rs.log.Debug("Image rendered", "path", pngPath)
return &RenderResult{FilePath: pngPath}, nil return &RenderResult{FilePath: pngPath}, nil
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment