Alerting: Fix logging pointer address of DashboardUID and PanelID variables (#58539)

This commit is contained in:
George Robinson
2022-11-10 09:58:38 +00:00
committed by GitHub
parent 68600c224b
commit c5ae1bcfe0
3 changed files with 28 additions and 10 deletions
+8 -6
View File
@@ -115,24 +115,26 @@ func NewScreenshotImageServiceFromCfg(cfg *setting.Cfg, db *store.DBstore, ds da
func (s *ScreenshotImageService) NewImage(ctx context.Context, r *models.AlertRule) (*models.Image, error) {
logger := s.logger.FromContext(ctx)
if r.DashboardUID == nil || *r.DashboardUID == "" {
dashboardUID := r.GetDashboardUID()
if dashboardUID == "" {
logger.Debug("Cannot take screenshot for alert rule as it is not associated with a dashboard")
return nil, models.ErrNoDashboard
}
if r.PanelID == nil || *r.PanelID == 0 {
panelID := r.GetPanelID()
if panelID <= 0 {
logger.Debug("Cannot take screenshot for alert rule as it is not associated with a panel")
return nil, models.ErrNoPanel
}
logger = logger.New("dashboard", dashboardUID, "panel", panelID)
opts := screenshot.ScreenshotOptions{
DashboardUID: *r.DashboardUID,
PanelID: *r.PanelID,
DashboardUID: dashboardUID,
PanelID: panelID,
Timeout: screenshotTimeout,
}
logger = logger.New("dashboard", opts.DashboardUID, "panel", opts.PanelID)
// To prevent concurrent screenshots of the same dashboard panel we use singleflight,
// deduplicated on a base64 hash of the screenshot options.
optsHash := base64.StdEncoding.EncodeToString(opts.Hash())