Skip to content

Commit

Permalink
Support dashboard loading without Elasticsearch (#5653)
Browse files Browse the repository at this point in the history
* libbeat: support dashboard loading without Elasticsearch

A new boolean option for dashboards is introduced named alwas_kibana.
If it is true, Elasticsearch version check is skipped and dashboards
are loaded using Kibana API. It should be used when no Elasticsearch
output is configured.

* additional docs and changelog fix
  • Loading branch information
kvch authored and tsg committed Nov 21, 2017
1 parent 085d5bf commit 0bc3186
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di

*Affecting all Beats*

- Support dashboard loading without Elasticseach {pull}5653[5653]

*Auditbeat*

- Changed `audit.file.path` to be a multi-field so that path is searchable. {pull}5625[5625]
Expand Down
3 changes: 3 additions & 0 deletions auditbeat/auditbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,9 @@ output.elasticsearch:
# dashboards and index pattern. Example: testbeat-*
#setup.dashboards.index:

# Force loading of dashboards using the Kibana API without querying Elasticsearch for the version
#always_kibana: false

#============================== Template =====================================

# A template is used to set the mapping in Elasticsearch
Expand Down
3 changes: 3 additions & 0 deletions filebeat/filebeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,9 @@ output.elasticsearch:
# dashboards and index pattern. Example: testbeat-*
#setup.dashboards.index:

# Force loading of dashboards using the Kibana API without querying Elasticsearch for the version
#always_kibana: false

#============================== Template =====================================

# A template is used to set the mapping in Elasticsearch
Expand Down
3 changes: 3 additions & 0 deletions heartbeat/heartbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,9 @@ output.elasticsearch:
# dashboards and index pattern. Example: testbeat-*
#setup.dashboards.index:

# Force loading of dashboards using the Kibana API without querying Elasticsearch for the version
#always_kibana: false

#============================== Template =====================================

# A template is used to set the mapping in Elasticsearch
Expand Down
3 changes: 3 additions & 0 deletions libbeat/_meta/config.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,9 @@ output.elasticsearch:
# dashboards and index pattern. Example: testbeat-*
#setup.dashboards.index:

# Force loading of dashboards using the Kibana API without querying Elasticsearch for the version
#always_kibana: false

#============================== Template =====================================

# A template is used to set the mapping in Elasticsearch
Expand Down
4 changes: 3 additions & 1 deletion libbeat/dashboards/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ type Config struct {
URL string `config:"url"`
OnlyDashboards bool `config:"only_dashboards"`
OnlyIndex bool `config:"only_index"`
AlwaysKibana bool `config:"always_kibana"`
}

var defaultConfig = Config{
KibanaIndex: ".kibana",
KibanaIndex: ".kibana",
AlwaysKibana: false,
}
var (
defaultDirectory = "kibana"
Expand Down
20 changes: 15 additions & 5 deletions libbeat/dashboards/dashboards.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ func ImportDashboards(beatName, hostname, homePath string,
return err
}

if kibanaConfig == nil {
kibanaConfig = common.NewConfig()
}

if esConfig == nil && dashConfig.AlwaysKibana {
return setupAndImportDashboardsViaKibana(hostname, kibanaConfig, &dashConfig, msgOutputter)
}

esLoader, err := NewElasticsearchLoader(esConfig, &dashConfig, msgOutputter)
if err != nil {
return fmt.Errorf("fail to create the Elasticsearch loader: %v", err)
Expand All @@ -48,10 +56,6 @@ func ImportDashboards(beatName, hostname, homePath string,

logp.Info("For Elasticsearch version >= 6.0.0, the Kibana dashboards need to be imported via the Kibana API.")

if kibanaConfig == nil {
kibanaConfig = common.NewConfig()
}

// In Cloud, the Kibana URL is different than the Elasticsearch URL,
// but the credentials are the same.
// So, by default, use same credentials for connecting to Kibana as to Elasticsearch
Expand All @@ -62,7 +66,13 @@ func ImportDashboards(beatName, hostname, homePath string,
kibanaConfig.SetString("password", -1, esLoader.client.Password)
}

kibanaLoader, err := NewKibanaLoader(kibanaConfig, &dashConfig, hostname, msgOutputter)
return setupAndImportDashboardsViaKibana(hostname, kibanaConfig, &dashConfig, msgOutputter)
}

func setupAndImportDashboardsViaKibana(hostname string, kibanaConfig *common.Config,
dashboardsConfig *Config, msgOutputter MessageOutputter) error {

kibanaLoader, err := NewKibanaLoader(kibanaConfig, dashboardsConfig, hostname, msgOutputter)
if err != nil {
return fmt.Errorf("fail to create the Kibana loader: %v", err)
}
Expand Down
6 changes: 6 additions & 0 deletions libbeat/docs/dashboardsconfig.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,9 @@ is `".kibana"`

The Elasticsearch index name. This setting overwrites the index name defined
in the dashboards and index pattern. Example: `"testbeat-*"`

[float]
==== `setup.dashboards.always_kibana`

Force loading of dashboards using the Kibana API without querying Elasticsearch for the version
The default is `false`.
3 changes: 3 additions & 0 deletions metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,9 @@ output.elasticsearch:
# dashboards and index pattern. Example: testbeat-*
#setup.dashboards.index:

# Force loading of dashboards using the Kibana API without querying Elasticsearch for the version
#always_kibana: false

#============================== Template =====================================

# A template is used to set the mapping in Elasticsearch
Expand Down
3 changes: 3 additions & 0 deletions packetbeat/packetbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,9 @@ output.elasticsearch:
# dashboards and index pattern. Example: testbeat-*
#setup.dashboards.index:

# Force loading of dashboards using the Kibana API without querying Elasticsearch for the version
#always_kibana: false

#============================== Template =====================================

# A template is used to set the mapping in Elasticsearch
Expand Down
3 changes: 3 additions & 0 deletions winlogbeat/winlogbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,9 @@ output.elasticsearch:
# dashboards and index pattern. Example: testbeat-*
#setup.dashboards.index:

# Force loading of dashboards using the Kibana API without querying Elasticsearch for the version
#always_kibana: false

#============================== Template =====================================

# A template is used to set the mapping in Elasticsearch
Expand Down

0 comments on commit 0bc3186

Please sign in to comment.