summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorK Jonathan Harker <k.jonathan.harker@hp.com>2015-06-02 16:24:30 -0700
committerK Jonathan Harker <k.jonathan.harker@hp.com>2015-10-14 12:18:31 -0700
commit8c66da99df09a4cbd655141df891aee4c1a049f2 (patch)
tree8acd29921bf76a8dda2cbec01d534ff76c85c057
parent3e95d92cfcbaeb9db7c994a28e7680f467cc9855 (diff)
Add kibana3 support
Add support for the javascript version of kibana. By default, this is done by serving both the kibana and also an elasticsearch proxy from the same location. Allowed GETs and POSTs for read-only access to elasticsearch are passed to a proxy and all other requests are served from the kibana source directory. An optional prefix, such as 'elasticsearch/', can be specified in which case the reverse proxy to elasticsearch will be served from this sub-path. Change-Id: I13f9dff0bbd6498a36dc75b026c9042a9bb05e8f
Notes
Notes (review): Verified+2: Jenkins Code-Review+2: Clark Boylan <cboylan@sapwetik.org> Workflow+1: Clark Boylan <cboylan@sapwetik.org> Submitted-by: Jenkins Submitted-at: Wed, 14 Oct 2015 20:45:27 +0000 Reviewed-on: https://review.openstack.org/188907 Project: openstack-infra/puppet-kibana Branch: refs/heads/master
-rw-r--r--manifests/init.pp18
-rw-r--r--manifests/js.pp54
-rw-r--r--templates/config.js.erb80
-rw-r--r--templates/dual-elasticsearch.vhost.erb41
4 files changed, 191 insertions, 2 deletions
diff --git a/manifests/init.pp b/manifests/init.pp
index af9c008..23f1d7f 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -15,8 +15,13 @@
15# Class to install kibana frontend to logstash. 15# Class to install kibana frontend to logstash.
16# 16#
17class kibana ( 17class kibana (
18 $discover_nodes = ['localhost:9200'], 18 $discover_nodes = ['localhost:9200'],
19 $version = 'ruby', 19 $version = 'ruby',
20 $js_vhost_name = $::fqdn,
21 $js_vhost_aliases = [],
22 $js_vhost_template = 'kibana/dual-elasticsearch.vhost.erb',
23 $js_elasticsearch_prefix = '/',
24 $js_elasticsearch_url = 'http://localhost:9200',
20) { 25) {
21 26
22 group { 'kibana': 27 group { 'kibana':
@@ -46,6 +51,15 @@ class kibana (
46 'ruby': { 51 'ruby': {
47 include ::kibana::ruby 52 include ::kibana::ruby
48 } 53 }
54 'js': {
55 class { '::kibana::js':
56 vhost_name => $js_vhost_name,
57 vhost_aliases => $js_vhost_aliases,
58 vhost_template => $js_vhost_template,
59 elasticsearch_prefix => $js_elasticsearch_prefix,
60 elasticsearch_url => $js_elasticsearch_url,
61 }
62 }
49 default: { 63 default: {
50 fail("Unknown version: ${version}") 64 fail("Unknown version: ${version}")
51 } 65 }
diff --git a/manifests/js.pp b/manifests/js.pp
new file mode 100644
index 0000000..646db02
--- /dev/null
+++ b/manifests/js.pp
@@ -0,0 +1,54 @@
1# Copyright 2015 Hewlett-Packard Development Company, L.P.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14#
15# Class to install kibana frontend to logstash.
16#
17class kibana::js (
18 $vhost_template = 'kibana/dual-elasticsearch.vhost.erb',
19 $vhost_aliases = [],
20 $vhost_name = $::fqdn,
21 $vhost_proxy_timeout = '120',
22 $vhost_proxy_connect_timeout = '15',
23 $elasticsearch_url = 'http://localhost:9200',
24 $elasticsearch_prefix = '/', # Must contain trailing /
25 $git_revision = 'v3.1.2',
26) {
27
28 $base_path = "/opt/kibana/${git_revision}"
29
30 vcsrepo { $base_path:
31 ensure => latest,
32 provider => 'git',
33 source => 'https://github.com/elasticsearch/kibana.git',
34 revision => $git_revision,
35 owner => 'www-data',
36 }
37
38 file { "${base_path}/src/config.js":
39 ensure => present,
40 content => template('kibana/config.js.erb'),
41 owner => 'www-data',
42 require => Vcsrepo[$base_path],
43 subscribe => Vcsrepo[$base_path],
44 }
45
46 apache::vhost { 'kibana':
47 docroot => "${base_path}/src",
48 vhost_name => $vhost_name,
49 serveraliases => $vhost_aliases,
50 port => 80,
51 template => $vhost_template,
52 }
53
54}
diff --git a/templates/config.js.erb b/templates/config.js.erb
new file mode 100644
index 0000000..411ffa9
--- /dev/null
+++ b/templates/config.js.erb
@@ -0,0 +1,80 @@
1/** @scratch /configuration/config.js/1
2 *
3 * == Configuration
4 * config.js is where you will find the core Kibana configuration. This file contains parameter that
5 * must be set before kibana is run for the first time.
6 */
7define(['settings'],
8function (Settings) {
9 "use strict";
10
11 /** @scratch /configuration/config.js/2
12 *
13 * === Parameters
14 */
15 return new Settings({
16
17 /** @scratch /configuration/config.js/5
18 *
19 * ==== elasticsearch
20 *
21 * The URL to your elasticsearch server. You almost certainly don't
22 * want +http://localhost:9200+ here. Even if Kibana and Elasticsearch are on
23 * the same host. By default this will attempt to reach ES at the same host you have
24 * kibana installed on. You probably want to set it to the FQDN of your
25 * elasticsearch host
26 *
27 * Note: this can also be an object if you want to pass options to the http client. For example:
28 *
29 * +elasticsearch: {server: "http://localhost:9200", withCredentials: true}+
30 *
31 */
32 elasticsearch: "http://"+window.location.hostname+":80"+"<%= @elasticsearch_prefix %>",
33
34 /** @scratch /configuration/config.js/5
35 *
36 * ==== default_route
37 *
38 * This is the default landing page when you don't specify a dashboard to load. You can specify
39 * files, scripts or saved dashboards here. For example, if you had saved a dashboard called
40 * `WebLogs' to elasticsearch you might use:
41 *
42 * default_route: '/dashboard/elasticsearch/WebLogs',
43 */
44 default_route : '/dashboard/file/logstash.json',
45
46 /** @scratch /configuration/config.js/5
47 *
48 * ==== kibana-int
49 *
50 * The default ES index to use for storing Kibana specific object
51 * such as stored dashboards
52 */
53 kibana_index: "kibana-int",
54
55 /** @scratch /configuration/config.js/5
56 *
57 * ==== panel_name
58 *
59 * An array of panel modules available. Panels will only be loaded when they are defined in the
60 * dashboard, but this list is used in the "add panel" interface.
61 */
62 panel_names: [
63 'histogram',
64 'map',
65 'goal',
66 'table',
67 'filtering',
68 'timepicker',
69 'text',
70 'hits',
71 'column',
72 'trends',
73 'bettermap',
74 'query',
75 'terms',
76 'stats',
77 'sparklines'
78 ]
79 });
80});
diff --git a/templates/dual-elasticsearch.vhost.erb b/templates/dual-elasticsearch.vhost.erb
new file mode 100644
index 0000000..78b3394
--- /dev/null
+++ b/templates/dual-elasticsearch.vhost.erb
@@ -0,0 +1,41 @@
1<VirtualHost *:80>
2 ServerName <%= @vhost_name %>
3 ServerAdmin <%= @serveradmin %>
4<% if @serveraliases.is_a? Array %>
5<% serveraliases.each do |name| %><%= " ServerAlias #{name}\n" %><% end %>
6<% elsif @serveraliases != '' %>
7<%= " ServerAlias #{serveraliases}" %>
8<% end %>
9
10 ErrorLog ${APACHE_LOG_DIR}/<%= @vhost_name %>-error.log
11
12 LogLevel warn
13
14 CustomLog ${APACHE_LOG_DIR}/<%= @vhost_name %>-access.log combined
15
16 <IfModule mod_proxy.c>
17 # Proxy GETs for elasticsearch .*/_aliases, .*/_status, .*/_search,
18 # .*/_mapping, .*/_mapping/field/.*, _cluster/health, _cluster/state/.*,
19 # _nodes. and _nodes/stats
20 # These GETs allow read-only access for kibana3, elasticsearch-head, and bigdesk,
21 # as well as arbitrary searches using the elasticsearch search api.
22 RewriteEngine on
23 RewriteCond %{REQUEST_METHOD} GET
24 RewriteRule ^<%= @elasticsearch_prefix %>((.*/)?_aliases|(.*/)?_status|(.*/)?_search|(.*/)?_mapping(/field(/.*)?)?|_cluster/(health|state(/.*)?)|_nodes(/stats)?)$ <%= @elasticsearch_url %>/$1 [P]
25 RewriteCond %{REQUEST_METHOD} POST
26 RewriteRule ^<%= @elasticsearch_prefix %>(_aliases|(.*/)?_search)$ <%= @elasticsearch_url %>/$1 [P]
27 RewriteCond %{REQUEST_METHOD} OPTIONS
28 RewriteRule ^<%= @elasticsearch_prefix %>((.*/)?_search)$ <%= @elasticsearch_url %>/$1 [P]
29 <Proxy <%= @elasticsearch_url %>/>
30 ProxySet connectiontimeout=<%= @vhost_proxy_connect_timeout %> timeout=<%= @vhost_proxy_timeout %>
31 </Proxy>
32 ProxyPassReverse <%= @elasticsearch_prefix %> <%= @elasticsearch_url %>/
33 </IfModule>
34
35 DocumentRoot <%= docroot %>
36 <Directory <%= docroot %>>
37 Options -Multiviews
38 </Directory>
39
40</VirtualHost>
41