diff --git a/pkg/tsdb/azuremonitor/applicationinsights-datasource_test.go b/pkg/tsdb/azuremonitor/applicationinsights-datasource_test.go index fb18a54e488..3b8080b54ad 100644 --- a/pkg/tsdb/azuremonitor/applicationinsights-datasource_test.go +++ b/pkg/tsdb/azuremonitor/applicationinsights-datasource_test.go @@ -211,6 +211,11 @@ func TestAppInsightsPluginRoutes(t *testing.T) { func TestInsightsDimensionsUnmarshalJSON(t *testing.T) { a := []byte(`"foo"`) b := []byte(`["foo"]`) + c := []byte(`["none"]`) + d := []byte(`["None"]`) + e := []byte("null") + f := []byte(`""`) + g := []byte(`"none"`) var as InsightsDimensions var bs InsightsDimensions @@ -223,4 +228,29 @@ func TestInsightsDimensionsUnmarshalJSON(t *testing.T) { require.NoError(t, err) require.Equal(t, []string{"foo"}, []string(bs)) + + var cs InsightsDimensions + err = json.Unmarshal(c, &cs) + require.NoError(t, err) + require.Empty(t, cs) + + var ds InsightsDimensions + err = json.Unmarshal(d, &ds) + require.NoError(t, err) + require.Empty(t, ds) + + var es InsightsDimensions + err = json.Unmarshal(e, &es) + require.NoError(t, err) + require.Empty(t, es) + + var fs InsightsDimensions + err = json.Unmarshal(f, &fs) + require.NoError(t, err) + require.Empty(t, fs) + + var gs InsightsDimensions + err = json.Unmarshal(g, &gs) + require.NoError(t, err) + require.Empty(t, gs) } diff --git a/pkg/tsdb/azuremonitor/types.go b/pkg/tsdb/azuremonitor/types.go index e412f46750e..b08f2bea08b 100644 --- a/pkg/tsdb/azuremonitor/types.go +++ b/pkg/tsdb/azuremonitor/types.go @@ -170,7 +170,14 @@ func (s *InsightsDimensions) UnmarshalJSON(data []byte) error { if err != nil { return err } - *s = InsightsDimensions(sa) + dimensions := []string{} + for _, v := range sa { + if v == "none" || v == "None" { + continue + } + dimensions = append(dimensions, v) + } + *s = InsightsDimensions(dimensions) return nil }