diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index b1c28b93c3..872489d174 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -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 diff --git a/ansible/roles/common/templates/conf/output/00-local.conf.j2 b/ansible/roles/common/templates/conf/output/00-local.conf.j2 index 3b972d523c..dc87c7ef94 100644 --- a/ansible/roles/common/templates/conf/output/00-local.conf.j2 +++ b/ansible/roles/common/templates/conf/output/00-local.conf.j2 @@ -15,7 +15,7 @@ host {{ elasticsearch_address }} port {{ elasticsearch_port }} logstash_format true - logstash_prefix flog + logstash_prefix {{ kibana_log_prefix }} flush_interval 15s {% 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 {% endif %} diff --git a/ansible/roles/common/templates/conf/output/01-es.conf.j2 b/ansible/roles/common/templates/conf/output/01-es.conf.j2 index 4a87fcf2fe..82cf3c89dc 100644 --- a/ansible/roles/common/templates/conf/output/01-es.conf.j2 +++ b/ansible/roles/common/templates/conf/output/01-es.conf.j2 @@ -5,7 +5,7 @@ host {{ elasticsearch_address }} port {{ elasticsearch_port }} logstash_format true - logstash_prefix flog + logstash_prefix {{ kibana_log_prefix }} flush_interval 15s diff --git a/ansible/roles/kibana/defaults/main.yml b/ansible/roles/kibana/defaults/main.yml index fde66bfda6..28bf4cc3f2 100644 --- a/ansible/roles/kibana/defaults/main.yml +++ b/ansible/roles/kibana/defaults/main.yml @@ -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 #################### diff --git a/ansible/roles/kibana/tasks/deploy.yml b/ansible/roles/kibana/tasks/deploy.yml index dd26ecc34d..844a72d0c7 100644 --- a/ansible/roles/kibana/tasks/deploy.yml +++ b/ansible/roles/kibana/tasks/deploy.yml @@ -3,3 +3,5 @@ - name: Flush handlers meta: flush_handlers + +- include: post_config.yml diff --git a/ansible/roles/kibana/tasks/post_config.yml b/ansible/roles/kibana/tasks/post_config.yml new file mode 100644 index 0000000000..976ba7dc12 --- /dev/null +++ b/ansible/roles/kibana/tasks/post_config.yml @@ -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 diff --git a/doc/central-logging-guide.rst b/doc/central-logging-guide.rst index 9f78a08f20..938b8b1374 100644 --- a/doc/central-logging-guide.rst +++ b/doc/central-logging-guide.rst @@ -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 ```` 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 -------------------------- diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index d097562292..b7a120d3de 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -94,9 +94,4 @@ The values ````, ```` values are overridden, in ``/etc/kolla/globals.yml``. The value of ```` 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