Elasticsearch: Allow omitting field when metric supports inline script (#32839)

* Elasticsearch: Allow omitting field when metric supports inline script

* Add tests for MetricEditor to show a None option

* Add tests for useFields hook

* Alerting: allow elasticsearch metrics without field
This commit is contained in:
Giordano Ricci
2021-04-14 15:18:06 +01:00
committed by GitHub
parent 4b801be98c
commit cdb4785496
12 changed files with 281 additions and 88 deletions
+4 -2
View File
@@ -280,8 +280,10 @@ type MetricAggregation struct {
// MarshalJSON returns the JSON encoding of the metric aggregation
func (a *MetricAggregation) MarshalJSON() ([]byte, error) {
root := map[string]interface{}{
"field": a.Field,
root := map[string]interface{}{}
if a.Field != "" {
root["field"] = a.Field
}
for k, v := range a.Settings {