Skip to content

Commit f060eec

Browse files
committed
add job for kibana platform
1 parent 9f9def2 commit f060eec

File tree

7 files changed

+298
-0
lines changed

7 files changed

+298
-0
lines changed

jobs/kibana-platform/monit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
check process kibana
2+
with pidfile /var/vcap/sys/run/bpm/kibana/kibana.pid
3+
start program "/var/vcap/jobs/bpm/bin/bpm start kibana" with timeout 300 seconds
4+
stop program "/var/vcap/jobs/bpm/bin/bpm stop kibana"
5+
group vcap

jobs/kibana-platform/spec

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
name: kibana-platform
3+
4+
description: This job runs Kibana UI
5+
6+
packages:
7+
- kibana-platform
8+
9+
templates:
10+
bin/kibana: bin/kibana.sh
11+
bin/pre-start.erb: bin/pre-start
12+
bin/post-start.erb: bin/post-start
13+
config/kibana.conf.erb: config/kibana.conf
14+
config/bpm.yml.erb: config/bpm.yml
15+
16+
consumes:
17+
- name: elasticsearch-platform
18+
type: elasticsearch
19+
optional: true
20+
21+
provides:
22+
- name: kibana-platform
23+
type: kibana
24+
properties:
25+
- kibana.port
26+
27+
properties:
28+
kibana.elasticsearch.host:
29+
description: "IP address of elasticsearch master to send elasticsearch requests to"
30+
default: "127.0.0.1"
31+
kibana.elasticsearch.port:
32+
description: "Port of elasticsearch master to send elasticsearch requests to"
33+
default: "9200"
34+
kibana.default_app_id:
35+
description: "The default application to load."
36+
default: "discover"
37+
kibana.kibana_index:
38+
description: "Kibana uses an index in Elasticsearch to store saved searches, visualizations and dashboards"
39+
default: ".kibana"
40+
kibana.port:
41+
description: "Kibana is served by a back end server. This controls which port to use."
42+
default: 5601
43+
kibana.host:
44+
description: "This setting specifies the IP address of the back end server."
45+
default: "0.0.0.0"
46+
kibana.request_timeout:
47+
description: "Time in milliseconds to wait for responses from the back end or elasticsearch. This must be > 0"
48+
default: 300000
49+
kibana.shard_timeout:
50+
description: "Time in milliseconds for Elasticsearch to wait for responses from shards. Set to 0 to disable"
51+
default: 30000
52+
kibana.env:
53+
description: "a list of arbitrary key-value pairs to be passed on as process environment variables. eg: FOO: 123"
54+
default: []
55+
kibana.source_files:
56+
description: "List of files to source in kibana control script"
57+
default: []
58+
kibana.console_enabled:
59+
description: "Enable Kibana development console; should be set to `false` in a multi-tenant deployment."
60+
default: false
61+
kibana.searchprofiler_enabled:
62+
description: "Enable Kibana development search profiler; should be set to `false` in a multi-tenant deployment."
63+
default: false
64+
kibana.grokdebugger_enabled:
65+
description: "Enable Kibana development grok debugger; should be set to `false` in a multi-tenant deployment."
66+
default: false
67+
kibana.apm_enabled:
68+
description: "Enable Kibana APM ui; should be set to `false` in a multi-tenant deployment."
69+
default: false
70+
kibana.reporting_key:
71+
description: "Define a reporting key to prevent issues with exporting a report in a load balanced scenario."
72+
default: CloudFoundry123!
73+
kibana.config_options:
74+
description: "Additional options to append to kibana's config.yml (YAML format)."
75+
default: ~
76+
kibana.plugins:
77+
description: "a list of key-value pairs of plugins. e.b. Kibana-auth: /var/vcap/packagaes/kibana/kibana-auth"
78+
default: []
79+
kibana.memory_limit:
80+
description: "Configure the GC in nodejs to treat this number as the available memory for this process. The value is in the form of % of VM memory."
81+
default: 75
82+
kibana.health.disable_post_start:
83+
description: Allow node to run post-start script? (true / false)
84+
default: false
85+
kibana.health.interval:
86+
description: Kibana health check interval (seconds)
87+
default: 5
88+
kibana.health.timeout:
89+
description: Kibana health check number of attempts (seconds)
90+
default: 300
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
set -e # exit immediately if a simple command exits with a non-zero status
4+
set -u # report the usage of uninitialized variables
5+
6+
# Setup env vars and folders for the webapp_ctl script
7+
#source /var/vcap/jobs/kibana-platform/helpers/ctl_setup.sh 'kibana'
8+
export JOB_NAME=kibana-platform
9+
export JOB_DIR=/var/vcap/jobs/$JOB_NAME
10+
<%
11+
elasticsearch_port = nil
12+
if_link("elasticsearch") { |elasticsearch_link| elasticsearch_port = elasticsearch_link.p("elasticsearch.port") }
13+
unless elasticsearch_port
14+
elasticsearch_port = p("kibana.elasticsearch.port")
15+
end
16+
%>
17+
18+
MEMORY_LIMIT=$(($(grep MemTotal /proc/meminfo | awk '{print $2}') * <%= p('kibana.memory_limit') %>/100 / 1024))
19+
export NODE_OPTIONS="--max-old-space-size=$MEMORY_LIMIT"
20+
21+
<% p("kibana.env").each do |env| %>
22+
export <%= env.keys[0] %>="<%= env.values[0] %>"
23+
<% end %>
24+
25+
<% p("kibana.source_files").each do |sf| %>
26+
source <%= sf %>
27+
<% end %>
28+
29+
<% p("kibana.plugins").each do |plugin| name, path = plugin.first %>
30+
cd /var/vcap/packages/kibana-platform/plugins/
31+
<% if path.start_with? '/var/vcap' %>
32+
/var/vcap/packages/kibana-platform/bin/kibana-plugin install "file://<%= path %>"
33+
<% else %>
34+
/var/vcap/packages/kibana-platform/bin/kibana-plugin install "<%= path %>"
35+
<% end %>
36+
<% end %>
37+
38+
/var/vcap/packages/kibana-platform/bin/kibana -c $JOB_DIR/config/kibana.conf
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -x
5+
6+
<% if !p("kibana.health.disable_post_start") %>
7+
8+
echo "Waiting <%= p("kibana.health.timeout") %>s for kibana to accept connections..."
9+
elapsed=0
10+
until [ $elapsed -ge <%= p("kibana.health.timeout") %> ]
11+
do
12+
# We have to set and unset the 'e' flag around the curl as a return code of 000 (no network) will result in an error.
13+
# This return code is valid and therefore we want to ignore this as an error.
14+
set +e
15+
CODE=`curl -m 1 -s -o /dev/null -w "%{http_code}" http://<%= p("kibana.host") %>:<%= p("kibana.port") %>`
16+
set -e
17+
if [[ "$CODE" == "302" ]]; then
18+
echo Done!
19+
break
20+
fi
21+
echo -n .
22+
elapsed=$[$elapsed+<%= p("kibana.health.interval") %>]
23+
sleep <%= p("kibana.health.interval") %>
24+
done
25+
26+
if [ "$elapsed" -ge "<%= p("kibana.health.timeout") %>" ]; then
27+
echo "ERROR: Cannot connect to kibana. Exiting..."
28+
exit 1
29+
fi
30+
31+
<% end %>
32+
33+
exit 0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
if ! [[ $(ls -1 /var/vcap/packages/kibana-platform/plugins | wc -l) == 0 ]]; then
4+
rm -rf /var/vcap/packages/kibana-platform/plugins/*
5+
fi
6+
7+
cd /var/vcap/packages/kibana-platform
8+
chown -R vcap:vcap optimize config data plugins
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
processes:
2+
- name: kibana
3+
hooks:
4+
pre_start: /var/vcap/jobs/kibana-platform/bin/pre-start
5+
executable: /var/vcap/jobs/kibana-platform/bin/kibana.sh
6+
ephemeral_disk: true
7+
additional_volumes:
8+
<% p("kibana.source_files").each do |sf| %>
9+
- path: <%= sf %>
10+
<% end %>
11+
- path: /var/vcap/data/packages/kibana
12+
writable: true
13+
allow_executions: true
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Kibana is served by a back end server. This controls which port to use.
2+
server.port: <%= p('kibana.port') %>
3+
4+
# The host to bind the server to.
5+
server.host: <%= p('kibana.host') %>
6+
7+
# If you are running kibana behind a proxy, and want to mount it at a path,
8+
# specify that path here. The basePath can't end in a slash.
9+
# server.basePath: ""
10+
11+
# The Elasticsearch instance to use for all your queries.
12+
# elasticsearch.url: "http://localhost:9200"
13+
<%
14+
elasticsearch_port = nil
15+
if_link("elasticsearch") { |elasticsearch_link| elasticsearch_port = elasticsearch_link.p("elasticsearch.port") }
16+
unless elasticsearch_port
17+
elasticsearch_port = p("kibana.elasticsearch.port")
18+
end
19+
%>
20+
elasticsearch.hosts: "http://<%= p("kibana.elasticsearch.host") + ':' + elasticsearch_port.to_s %>"
21+
22+
# preserve_elasticsearch_host true will send the hostname specified in `elasticsearch`. If you set it to false,
23+
# then the host you use to connect to *this* Kibana instance will be sent.
24+
# elasticsearch.preserveHost: true
25+
26+
# Kibana uses an index in Elasticsearch to store saved searches, visualizations
27+
# and dashboards. It will create a new index if it doesn't already exist.
28+
# kibana.index: ".kibana"
29+
kibana.index: "<%= p('kibana.kibana_index') %>"
30+
31+
# The default application to load.
32+
# kibana.defaultAppId: "discover"
33+
kibana.defaultAppId: "<%= p('kibana.default_app_id') %>"
34+
35+
# If your Elasticsearch is protected with basic auth, these are the user credentials
36+
# used by the Kibana server to perform maintenance on the kibana_index at startup. Your Kibana
37+
# users will still need to authenticate with Elasticsearch (which is proxied through
38+
# the Kibana server)
39+
# elasticsearch.username: "user"
40+
# elasticsearch.password: "pass"
41+
42+
# SSL for outgoing requests from the Kibana Server to the browser (PEM formatted)
43+
# server.ssl.cert: /path/to/your/server.crt
44+
# server.ssl.key: /path/to/your/server.key
45+
46+
# Optional setting to validate that your Elasticsearch backend uses the same key files (PEM formatted)
47+
# elasticsearch.ssl.cert: /path/to/your/client.crt
48+
# elasticsearch.ssl.key: /path/to/your/client.key
49+
50+
# If you need to provide a CA certificate for your Elasticsearch instance, put
51+
# the path of the pem file here.
52+
# elasticsearch.ssl.ca: /path/to/your/CA.pem
53+
54+
# Set to false to have a complete disregard for the validity of the SSL
55+
# certificate.
56+
# elasticsearch.ssl.verify: true
57+
58+
# Time in milliseconds to wait for elasticsearch to respond to pings, defaults to
59+
# request_timeout setting
60+
# elasticsearch.pingTimeout: 1500
61+
62+
# Time in milliseconds to wait for responses from the back end or elasticsearch.
63+
# This must be > 0
64+
# elasticsearch.requestTimeout: 300000
65+
elasticsearch.requestTimeout: <%= p('kibana.request_timeout') %>
66+
67+
# Time in milliseconds for Elasticsearch to wait for responses from shards.
68+
# Set to 0 to disable.
69+
# elasticsearch.shardTimeout: 0
70+
elasticsearch.shardTimeout: <%= p('kibana.shard_timeout') %>
71+
72+
# Time in milliseconds to wait for Elasticsearch at Kibana startup before retrying
73+
# elasticsearch.startupTimeout: 5000
74+
75+
# Set the path to where you would like the process id file to be created.
76+
# pid.file: /var/run/kibana.pid
77+
78+
# If you would like to send the log output to a file you can set the path below.
79+
# logging.dest: stdout
80+
81+
# Set this to true to suppress all logging output.
82+
# logging.silent: false
83+
84+
# Set this to true to suppress all logging output except for error messages.
85+
# logging.quiet: false
86+
87+
# Set this to true to log all events, including system usage information and all requests.
88+
# logging.verbose: false
89+
90+
# Configure development console
91+
console.enabled: <%= p("kibana.console_enabled") %>
92+
xpack.searchprofiler.enabled: <%= p("kibana.searchprofiler_enabled") %>
93+
xpack.grokdebugger.enabled: <%= p("kibana.grokdebugger_enabled") %>
94+
95+
# configure apm
96+
xpack.apm.ui.enabled: <%= p("kibana.apm_enabled") %>
97+
98+
# set reporting key for load balanced scenarios
99+
xpack.reporting.encryptionKey: <%= p("kibana.reporting_key") %>
100+
101+
# disable x-pack
102+
xpack.monitoring.enabled: false
103+
xpack.graph.enabled: false
104+
xpack.ml.enabled: false
105+
xpack.security.enabled: false
106+
xpack.watcher.enabled: false
107+
xpack.spaces.enabled: false
108+
109+
<% if_p('kibana.config_options') do p("kibana.config_options", {}).each do | k, v | %>
110+
<%= k %>: <%= v %><% end %>
111+
<% end %>

0 commit comments

Comments
 (0)