Skip to content

Commit

Permalink
bug 1530157. Configure Kibana timeout via env var
Browse files Browse the repository at this point in the history
  • Loading branch information
jcantrill committed Jan 18, 2018
1 parent f756e14 commit 969e130
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 7 deletions.
2 changes: 1 addition & 1 deletion kibana/Dockerfile
Expand Up @@ -39,7 +39,7 @@ ADD nodescl-node /usr/bin
ADD probe/ /usr/share/kibana/probe/
ADD lib/origin-kibana ${KIBANA_HOME}/installedPlugins/origin-kibana
ADD kibana.yml ${KIBANA_CONF_DIR}/
ADD run.sh install.sh prep-install.${RELEASE_STREAM} ${HOME}/
ADD run.sh utils install.sh prep-install.${RELEASE_STREAM} ${HOME}/
RUN sh ${HOME}/install.sh

WORKDIR ${HOME}
Expand Down
2 changes: 1 addition & 1 deletion kibana/Dockerfile.centos7
Expand Up @@ -28,7 +28,7 @@ RUN rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch && \
ADD probe/ /usr/share/kibana/probe/
ADD kibana.yml ${KIBANA_CONF_DIR}/
ADD lib/origin-kibana ${KIBANA_HOME}/installedPlugins/origin-kibana
ADD run.sh install.sh prep-install.${RELEASE_STREAM} ${HOME}/
ADD run.sh utils install.sh prep-install.${RELEASE_STREAM} ${HOME}/
RUN ${HOME}/install.sh

WORKDIR ${HOME}
Expand Down
20 changes: 20 additions & 0 deletions kibana/README.md
@@ -0,0 +1,20 @@
# Kibana

This repo provides the Openshift Origin customization to [Kibana](https://www.elastic.co/products/kibana). The primary differences are:

* User Interface skinning based on [origin-kibana](https://github.com/openshift/origin-kibana) plugin
* Configuration overrides via [environment variables](https://www.elastic.co/guide/en/kibana/master/_configuring_kibana_on_docker.html) similar to that provided by the official Kibana Docker image

## Configuration Modifications
Modifying Kibana's configuration is possible by setting an environment value that corresponds to a config key. This is generally accomplished by making all values uppercase and replacing the dots with underscores. Examples of possible changes are listed below:

|Environment Variable | Kibana Config Key |
|------|------|
|`ELASTICSEARCH_URL` | `elasticsearch.url`|
|`ELASTICSEARCH_REQUESTTIMEOUT`|`elasticsearch.requestTimeout`|
|`KIBANA_DEFAULTAPPID`|`kibana.defaultAppId`|



## Additional Customizations
Additional customizations for Kibana are added to the Openshift logging stack in the [openshift-elasticsearch-plugin](https://github.com/fabric8io/openshift-elasticsearch-plugin).
2 changes: 1 addition & 1 deletion kibana/kibana.yml
Expand Up @@ -12,7 +12,7 @@
# server.maxPayloadBytes: 1048576

# The Elasticsearch instance to use for all your queries.
elasticsearch.url: https://es_host:es_port
elasticsearch.url: https://localhost:9200

# preserve_elasticsearch_host true will send the hostname specified in `elasticsearch`. If you set it to false,
# then the host you use to connect to *this* Kibana instance will be sent.
Expand Down
27 changes: 23 additions & 4 deletions kibana/run.sh
@@ -1,4 +1,22 @@
#!/bin/bash
#
# Copyright 2017 Red Hat, Inc. and/or its affiliates
# and other contributors as indicated by the @author tags.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

source "utils"

if [ -n "${DEBUG:-}" ] ; then
set -x
Expand All @@ -10,10 +28,6 @@ fi

set -euo pipefail

# add host and port to config
sed -i "s/es_host/${ES_HOST}/" "${KIBANA_CONF_DIR}/kibana.yml"
sed -i "s/es_port/${ES_PORT}/" "${KIBANA_CONF_DIR}/kibana.yml"

# override styles for branding
if [ -f "/etc/openshift/kibana/styles/overrides.css" ]; then
cp -f /etc/openshift/kibana/styles/overrides.css "${KIBANA_HOME}/installedPlugins/origin-kibana/public/styles"
Expand Down Expand Up @@ -63,6 +77,11 @@ else
exit 1
fi

if [ -z "${ELASTICSEARCH_URL:-}" ] ; then
ELASTICSEARCH_URL="https://${ES_HOST:-localhost}:${ES_PORT:-9200}"
fi
update_config_from_env_vars ${KIBANA_CONF_DIR}

echo "Using NODE_OPTIONS: '${NODE_OPTIONS:-}' Memory setting is in MB"

set -a && source /etc/sysconfig/kibana && "${NODE_BIN}" "${KIBANA_HOME}/src/cli"
60 changes: 60 additions & 0 deletions kibana/utils
@@ -0,0 +1,60 @@
#!/bin/bash
#
# Copyright 2018 Red Hat, Inc. and/or its affiliates
# and other contributors as indicated by the @author tags.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#override config by environment variables
#inspired by https://github.com/elastic/kibana-docker/blob/master/build/kibana/bin/kibana-docker

update_config_from_env_vars() {
conf_dir=$1
kibana_vars=(
elasticsearch.pingTimeout
elasticsearch.preserveHost
elasticsearch.requestTimeout
elasticsearch.shardTimeout
elasticsearch.ssl.ca
elasticsearch.ssl.cert
elasticsearch.ssl.certificate
elasticsearch.ssl.certificateAuthorities
elasticsearch.ssl.key
elasticsearch.ssl.keyPassphrase
elasticsearch.ssl.verificationMode
elasticsearch.ssl.verify
elasticsearch.startupTimeout
elasticsearch.url
kibana.defaultAppId
logging.quiet
logging.silent
logging.verbose
server.basePath
server.maxPayloadBytes
)
conf_file=${conf_dir}/kibana.yml
echo "#The following values dynamically added from environment variable overrides:"
for kibana_var in ${kibana_vars[*]}; do
# 'elasticsearch.url' -> 'ELASTICSEARCH_URL'
env_var=$(echo ${kibana_var^^} | tr . _)
# Indirectly lookup env var values via the name of the var.
# REF: http://tldp.org/LDP/abs/html/bashver2.html#EX78
value="${!env_var:-}"
if [[ -n "${value:-}" ]]; then
if [ -n "${DEBUG:-}" ] ; then
echo "updating ${conf_file} - '${kibana_var}: ${value}'"
fi
echo "${kibana_var}: ${value}" >> ${conf_file}
fi
done
}

0 comments on commit 969e130

Please sign in to comment.