Skip to content

Commit

Permalink
fix(dashboards): fix broken condition when thresholds are nil with bi…
Browse files Browse the repository at this point in the history
…llboard widgets (#2676)
  • Loading branch information
pranav-new-relic authored May 24, 2024
1 parent ff8af40 commit 48185e7
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions newrelic/structures_newrelic_one_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -1203,19 +1203,21 @@ func flattenDashboardWidget(in *entities.DashboardWidget, pageGUID string) (stri
case "viz.billboard":
widgetType = "widget_billboard"
out["nrql_query"] = flattenDashboardWidgetNRQLQuery(&rawCfg.NRQLQueries)
rawCfgThresholdsFetched := rawCfg.Thresholds.([]interface{})
if len(rawCfgThresholdsFetched) > 0 {
for _, t := range rawCfgThresholdsFetched {
thresholdFetched := t.(map[string]interface{})
if thresholdFetched["value"] == nil {
continue
}
if rawCfg.Thresholds != nil {
rawCfgThresholdsFetched := rawCfg.Thresholds.([]interface{})
if len(rawCfgThresholdsFetched) > 0 {
for _, t := range rawCfgThresholdsFetched {
thresholdFetched := t.(map[string]interface{})
if thresholdFetched["value"] == nil {
continue
}

switch thresholdFetched["alertSeverity"].(string) {
case string(entities.DashboardAlertSeverityTypes.CRITICAL):
out["critical"] = strconv.FormatFloat(thresholdFetched["value"].(float64), 'f', -1, 64)
case string(entities.DashboardAlertSeverityTypes.WARNING):
out["warning"] = strconv.FormatFloat(thresholdFetched["value"].(float64), 'f', -1, 64)
switch thresholdFetched["alertSeverity"].(string) {
case string(entities.DashboardAlertSeverityTypes.CRITICAL):
out["critical"] = strconv.FormatFloat(thresholdFetched["value"].(float64), 'f', -1, 64)
case string(entities.DashboardAlertSeverityTypes.WARNING):
out["warning"] = strconv.FormatFloat(thresholdFetched["value"].(float64), 'f', -1, 64)
}
}
}
}
Expand Down

0 comments on commit 48185e7

Please sign in to comment.