Configure Kibana default index pattern

When Kibana interface is opened for the first time, it requires creating
a default index pattern. To view, analyse and search logs, at least one
index pattern has to be created.
This patch automate "flog-*" default index pattern creation and set it
has default config.

Partially-implements: blueprint default-kibana-dashboard
Change-Id: Ie36696f9ad38ba7e49e65e0793a3b98d9f03ee8d
This commit is contained in:
Bertrand Lallau 2017-04-19 18:24:36 +02:00 committed by Bertrand Lallau
parent b236be7cb1
commit 2afc869d0f
8 changed files with 83 additions and 20 deletions

View File

@ -416,7 +416,7 @@ kolla_external_fqdn_cacert: "{{ node_config_directory }}/certificates/haproxy-ca
# Kibana options
####################
kibana_user: "kibana"
kibana_log_prefix: "flog"
####################
# Keystone options

View File

@ -15,7 +15,7 @@
host {{ elasticsearch_address }}
port {{ elasticsearch_port }}
logstash_format true
logstash_prefix flog
logstash_prefix {{ kibana_log_prefix }}
flush_interval 15s
</store>
{% endif %}
@ -40,7 +40,7 @@
host {{ elasticsearch_address }}
port {{ elasticsearch_port }}
logstash_format true
logstash_prefix flog
logstash_prefix {{ kibana_log_prefix }}
flush_interval 15s
</store>
{% endif %}

View File

@ -5,7 +5,7 @@
host {{ elasticsearch_address }}
port {{ elasticsearch_port }}
logstash_format true
logstash_prefix flog
logstash_prefix {{ kibana_log_prefix }}
flush_interval 15s
</store>
</match>

View File

@ -22,6 +22,15 @@ kibana_elasticsearch_shard_timeout: 0
kibana_elasticsearch_ssl_verify: false
####################
# Default index
####################
kibana_default_index_pattern: "{{ kibana_log_prefix }}-*"
kibana_default_index:
title: "{{ kibana_default_index_pattern }}"
timeFieldName: "@timestamp"
####################
# Docker
####################

View File

@ -3,3 +3,5 @@
- name: Flush handlers
meta: flush_handlers
- include: post_config.yml

View File

@ -0,0 +1,68 @@
---
- name: Wait for kibana port
wait_for:
host: "{{ api_interface_address }}"
port: "{{ kibana_server_port }}"
- name: Wait for kibana to register in elasticsearch
uri:
url: "{{ internal_protocol }}://{{ api_interface_address }}:{{ elasticsearch_port }}/.kibana"
status_code: 200
register: result
until: result.status == 200
retries: 5
delay: 2
- name: Get kibana default indexes
uri:
HEADER_Content-Type: application/json
url: "{{ internal_protocol }}://{{ api_interface_address }}:{{ elasticsearch_port }}/.kibana"
method: GET
register: kibana_default_indexes
when: kibana_default_index is defined
- name: Set kibana default indexes fact
set_fact:
kibana_default_indexes: "{{ kibana_default_indexes.json | default([]) }}"
when:
- kibana_default_indexes is defined
- name: Add index pattern to kibana
uri:
url: "{{ internal_protocol }}://{{ api_interface_address }}:{{ elasticsearch_port }}/.kibana/index-pattern/{{ kibana_default_index_pattern }}"
method: PUT
body: "{{ kibana_default_index | to_json }}"
body_format: json
status_code: 201
when:
- kibana_default_index is defined
- kibana_default_indexes is defined
- kibana_default_indexes['.kibana']['mappings']['config']['properties']['defaultIndex'] is not defined
- name: Find kibana version
command: docker exec -t kibana /opt/kibana/bin/kibana --version
register: kibana_version
when:
- kibana_default_index is defined
- kibana_default_indexes is defined
- kibana_default_indexes['.kibana']['mappings']['config']['properties']['defaultIndex'] is not defined
- set_fact:
kibana_version: "{{ kibana_version.stdout }}"
when:
- kibana_default_index is defined
- kibana_default_indexes is defined
- kibana_default_indexes['.kibana']['mappings']['config']['properties']['defaultIndex'] is not defined
- name: Change kibana config to set index as defaultIndex
uri:
url: "http://{{ api_interface_address }}:{{ elasticsearch_port }}/.kibana/config/{{ kibana_version }}"
method: PUT
body:
defaultIndex: "{{ kibana_default_index_pattern }}"
body_format: json
status_code: 200
when:
- kibana_default_index is defined
- kibana_default_indexes is defined
- kibana_default_indexes['.kibana']['mappings']['config']['properties']['defaultIndex'] is not defined

View File

@ -44,17 +44,6 @@ After successful deployment, Kibana can be accessed using a browser on
The default username is ``kibana``, the password can be located under
``<kibana_password>`` in ``/etc/kolla/passwords.yml``.
When Kibana is opened for the first time, it requires creating a default index
pattern. To view, analyse and search logs, at least one index pattern has to be
created. To match indices stored in ElasticSearch, we suggest setting the
"Index name or pattern" field to ``flog-*``. The rest of the fields can be left
as is.
After setting parameters, create an index by clicking the ``Create`` button.
.. note:: This step is necessary until the default Kibana dashboard is implemented
in Kolla.
Search logs - Discover tab
--------------------------

View File

@ -94,9 +94,4 @@ The values ``<kolla_internal_vip_address>``, ``<kolla_external_vip_address>``
values are overridden, in ``/etc/kolla/globals.yml``. The value of
``<kibana_password>`` can be found in ``/etc/kolla/passwords.yml``.
.. note:: When you log in to Kibana web interface for the first time, you are
prompted to create an index. Please create an index using the name ``flog-*``.
This step is necessary until the default Kibana dashboard is implemented in
Kolla.
.. _launchpad bug: https://bugs.launchpad.net/kolla-ansible/+filebug