Skip to content

Commit

Permalink
index_pattern under visState.params cannot be empty "" (elastic#18865
Browse files Browse the repository at this point in the history
…) (elastic#18947)

* `index_pattern` under visState.params cannot be empty ""

(cherry picked from commit f6710e3)
  • Loading branch information
kaiyan-sheng authored Jun 4, 2020
1 parent d068c98 commit c194dbd
Show file tree
Hide file tree
Showing 29 changed files with 184 additions and 180 deletions.
22 changes: 13 additions & 9 deletions dev-tools/mage/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,14 @@ type dashboardObject struct {
Title string `json:"title"`
KibanaSavedObjectMeta *struct {
SearchSourceJSON struct {
Index string `json:"index"`
Index *string `json:"index"`
} `json:"searchSourceJSON,omitempty"`
} `json:"kibanaSavedObjectMeta"`
VisState *struct {
Params struct {
Controls []struct {
IndexPattern string
Params *struct {
IndexPattern *string `json:"index_pattern"`
Controls []struct {
IndexPattern *string
} `json:"controls"`
} `json:"params"`
} `json:"visState,omitempty"`
Expand Down Expand Up @@ -346,20 +347,23 @@ func checkTitle(re *regexp.Regexp, title string, module string) error {

func checkDashboardIndexPattern(expectedIndex string, o *dashboardObject) error {
if objectMeta := o.Attributes.KibanaSavedObjectMeta; objectMeta != nil {
if index := objectMeta.SearchSourceJSON.Index; index != "" && index != expectedIndex {
return errors.Errorf("unexpected index pattern reference found in object meta: %s", index)
if index := objectMeta.SearchSourceJSON.Index; index != nil && *index != expectedIndex {
return errors.Errorf("unexpected index pattern reference found in object meta: `%s` in visualization `%s`", *index, o.Attributes.Title)
}
}
if visState := o.Attributes.VisState; visState != nil {
for _, control := range visState.Params.Controls {
if index := control.IndexPattern; index != "" && index != expectedIndex {
return errors.Errorf("unexpected index pattern reference found in visualization state: %s", index)
if index := control.IndexPattern; index != nil && *index != expectedIndex {
return errors.Errorf("unexpected index pattern reference found in visualization state: `%s` in visualization `%s`", *index, o.Attributes.Title)
}
}
if index := visState.Params.IndexPattern; index != nil && *index != expectedIndex {
return errors.Errorf("unexpected index pattern reference found in visualization state params: `%s` in visualization `%s`", *index, o.Attributes.Title)
}
}
for _, reference := range o.References {
if reference.Type == "index-pattern" && reference.ID != expectedIndex {
return errors.Errorf("unexpected reference to index pattern %s", reference.ID)
return errors.Errorf("unexpected reference to index pattern `%s`", reference.ID)
}
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@
"default_timefield": "@timestamp",
"drop_last_bucket": 1,
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "30s",
"markdown": "| | |\n|---|---|\n|**Days running**|{{ math.started.last.raw }}|\n|**File descriptors open**|{{ average_of_kubernetes_controllermanager_process_fds_open_count.fds.last.raw }}|\n|**Resident Memory**|{{ average_of_kubernetes_controllermanager_process_memory_resident_bytes.resident_memory.last.formatted }}|\n|**Virtual Memory**|{{ average_of_kubernetes_controllermanager_process_memory_virtual_bytes.virtual_memory.last.formatted }}|\n",
"markdown_css": "#markdown-61ca57f0-469d-11e7-af02-69e470af7417 table,#markdown-61ca57f0-469d-11e7-af02-69e470af7417 tr,#markdown-61ca57f0-469d-11e7-af02-69e470af7417 td,#markdown-61ca57f0-469d-11e7-af02-69e470af7417 th{border:none}",
Expand Down Expand Up @@ -475,7 +475,7 @@
"axis_scale": "normal",
"default_index_pattern": "metricbeat-*",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "auto",
"series": [
{
Expand Down Expand Up @@ -585,7 +585,7 @@
"default_index_pattern": "metricbeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "auto",
"series": [
{
Expand Down Expand Up @@ -658,7 +658,7 @@
"default_index_pattern": "metricbeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "auto",
"series": [
{
Expand Down Expand Up @@ -728,7 +728,7 @@
"default_index_pattern": "metricbeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "auto",
"series": [
{
Expand Down Expand Up @@ -816,7 +816,7 @@
"default_index_pattern": "metricbeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "auto",
"series": [
{
Expand Down Expand Up @@ -893,7 +893,7 @@
"default_index_pattern": "metricbeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "auto",
"series": [
{
Expand Down Expand Up @@ -972,7 +972,7 @@
"default_index_pattern": "metricbeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "",
"series": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
"default_index_pattern": "metricbeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "auto",
"series": [
{
Expand Down Expand Up @@ -288,7 +288,7 @@
"axis_scale": "normal",
"default_index_pattern": "metricbeat-*",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "auto",
"series": [
{
Expand Down Expand Up @@ -376,7 +376,7 @@
"default_index_pattern": "metricbeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "30s",
"markdown": "\n| | |\n|---|---|\n|**Days running**|{{ math.started.last.raw }}|\n|**File descriptors open**|{{ average_of_kubernetes_proxy_process_fds_open_count.fds.last.raw }}|\n|**Resident Memory**|{{ average_of_kubernetes_proxy_process_memory_resident_bytes.resident_memory.last.formatted }}|\n|**Virtual Memory**|{{ average_of_kubernetes_proxy_process_memory_virtual_bytes.virtual_memory.last.formatted }}|\n\n",
"markdown_css": "#markdown-61ca57f0-469d-11e7-af02-69e470af7417 table,#markdown-61ca57f0-469d-11e7-af02-69e470af7417 tr,#markdown-61ca57f0-469d-11e7-af02-69e470af7417 td,#markdown-61ca57f0-469d-11e7-af02-69e470af7417 th{border:none}",
Expand Down Expand Up @@ -532,7 +532,7 @@
"axis_scale": "normal",
"default_index_pattern": "metricbeat-*",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "auto",
"series": [
{
Expand Down Expand Up @@ -659,7 +659,7 @@
"gauge_style": "half",
"gauge_width": 10,
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "auto",
"series": [
{
Expand Down Expand Up @@ -897,7 +897,7 @@
"axis_scale": "normal",
"default_index_pattern": "metricbeat-*",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "auto",
"series": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
"drop_last_bucket": 1,
"filter": "_exists_:\"kubernetes.scheduler.process.started.sec\"",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "30s",
"markdown": "| | |\n|---|---|\n|**Days running**|{{ math.started.last.raw }}|\n|**File descriptors open**|{{ max_of_kubernetes_scheduler_process_fds_open_count.fds.last.raw }}|\n|**Resident Memory**|{{ max_of_kubernetes_scheduler_process_memory_resident_bytes.resident_memory.last.formatted }}|\n|**Virtual Memory**|{{ max_of_kubernetes_scheduler_process_memory_virtual_bytes.virtual_memory.last.formatted }}|\n",
"markdown_css": "#markdown-61ca57f0-469d-11e7-af02-69e470af7417 table,#markdown-61ca57f0-469d-11e7-af02-69e470af7417 tr,#markdown-61ca57f0-469d-11e7-af02-69e470af7417 td,#markdown-61ca57f0-469d-11e7-af02-69e470af7417 th{border:none}",
Expand Down Expand Up @@ -443,7 +443,7 @@
"default_index_pattern": "metricbeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "",
"series": [
{
Expand Down Expand Up @@ -553,7 +553,7 @@
"default_index_pattern": "metricbeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "",
"series": [
{
Expand Down Expand Up @@ -796,7 +796,7 @@
"default_index_pattern": "metricbeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "",
"series": [
{
Expand Down Expand Up @@ -873,7 +873,7 @@
"default_index_pattern": "metricbeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "",
"series": [
{
Expand Down Expand Up @@ -947,7 +947,7 @@
"default_index_pattern": "metricbeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "",
"series": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@
"default_index_pattern": "metricbeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "",
"isModelInvalid": false,
"series": [
Expand Down Expand Up @@ -777,7 +777,7 @@
"default_index_pattern": "metricbeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "metricbeat-*",
"interval": "",
"isModelInvalid": false,
"series": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@
"query": "-system.network.name:l*"
},
"id": "da1046f0-faa0-11e6-86b1-cd7735ff7e23",
"index_pattern": "*",
"index_pattern": "metricbeat-*",
"interval": "auto",
"series": [
{
Expand Down Expand Up @@ -719,7 +719,7 @@
"query": "-system.network.name:l*"
},
"id": "da1046f0-faa0-11e6-86b1-cd7735ff7e23",
"index_pattern": "*",
"index_pattern": "metricbeat-*",
"interval": "auto",
"series": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@
"default_index_pattern": "filebeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "filebeat-*",
"interval": "",
"isModelInvalid": false,
"legend_position": "bottom",
Expand Down Expand Up @@ -401,7 +401,7 @@
"gauge_style": "half",
"gauge_width": 10,
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "filebeat-*",
"interval": "",
"isModelInvalid": false,
"legend_position": "bottom",
Expand Down Expand Up @@ -488,7 +488,7 @@
"default_index_pattern": "filebeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "filebeat-*",
"interval": "",
"isModelInvalid": false,
"legend_position": "bottom",
Expand Down Expand Up @@ -581,7 +581,7 @@
"gauge_style": "half",
"gauge_width": 10,
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "filebeat-*",
"interval": "",
"isModelInvalid": false,
"legend_position": "bottom",
Expand Down Expand Up @@ -668,7 +668,7 @@
"default_index_pattern": "filebeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "filebeat-*",
"interval": "",
"isModelInvalid": false,
"legend_position": "bottom",
Expand Down Expand Up @@ -744,7 +744,7 @@
"default_index_pattern": "filebeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "filebeat-*",
"interval": "",
"isModelInvalid": false,
"legend_position": "bottom",
Expand Down Expand Up @@ -819,7 +819,7 @@
"default_index_pattern": "filebeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "filebeat-*",
"interval": "",
"isModelInvalid": false,
"legend_position": "bottom",
Expand Down Expand Up @@ -894,7 +894,7 @@
"default_index_pattern": "filebeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "filebeat-*",
"interval": "",
"isModelInvalid": false,
"legend_position": "bottom",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
"gauge_style": "half",
"gauge_width": 10,
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "filebeat-*",
"interval": "",
"isModelInvalid": false,
"legend_position": "bottom",
Expand Down Expand Up @@ -396,7 +396,7 @@
"default_index_pattern": "metricbeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "filebeat-*",
"interval": "",
"isModelInvalid": false,
"legend_position": "right",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@
"gauge_style": "half",
"gauge_width": 10,
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "filebeat-*",
"interval": "auto",
"series": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@
"default_index_pattern": "filebeat-*",
"default_timefield": "@timestamp",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "filebeat-*",
"interval": "",
"isModelInvalid": false,
"series": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@
"axis_position": "left",
"axis_scale": "normal",
"id": "61ca57f0-469d-11e7-af02-69e470af7417",
"index_pattern": "",
"index_pattern": "filebeat-*",
"interval": "auto",
"series": [
{
Expand Down
Loading

0 comments on commit c194dbd

Please sign in to comment.