Skip to content

Commit 6738380

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "opensearch: automate index pattern creation in dashboards"
2 parents 3e85c8e + 20c6740 commit 6738380

3 files changed

Lines changed: 70 additions & 14 deletions

File tree

ansible/roles/opensearch/tasks/post-config.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,30 @@
8787
when:
8888
- not ansible_check_mode
8989
- opensearch_retention_policy_check.status == 404
90+
91+
- name: Create OpenSearch Dashboards Index Pattern
92+
become: true
93+
kolla_toolbox:
94+
container_engine: "{{ kolla_container_engine }}"
95+
module_name: uri
96+
module_args:
97+
url: "{{ opensearch_dashboards_internal_endpoint }}/api/saved_objects/index-pattern/{{ opensearch_log_index_prefix }}-pattern"
98+
method: POST
99+
status_code: 200, 409
100+
url_username: "{{ opensearch_dashboards_user }}"
101+
url_password: "{{ opensearch_dashboards_password }}"
102+
force_basic_auth: true
103+
headers:
104+
osd-xsrf: "true"
105+
body:
106+
attributes:
107+
title: "{{ opensearch_log_index_prefix }}-*"
108+
timeFieldName: "@timestamp"
109+
body_format: json
110+
ca_path: "{{ openstack_cacert }}"
111+
register: opensearch_index_pattern_create
112+
changed_when: opensearch_index_pattern_create.status == 200
113+
delegate_to: "{{ groups['opensearch'][0] }}"
114+
run_once: true
115+
when:
116+
- not ansible_check_mode

doc/source/reference/logging-and-monitoring/central-logging-guide.rst

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,38 @@ If you want to prevent OpenSearch Dashboards being exposed on the external
9595
VIP, you can set ``enable_opensearch_dashboards_external`` to ``false`` in
9696
``/etc/kolla/globals.yml``.
9797

98-
First Login
99-
-----------
100-
101-
When OpenSearch Dashboards is opened for the first time, it requires creating
102-
a default index pattern. To view, analyse and search logs, at least one
103-
index pattern has to be created. To match indices stored in OpenSearch,
104-
we suggest using the following configuration:
105-
106-
#. Index pattern - flog-*
107-
#. Time Filter field name - @timestamp
108-
#. Expand index pattern when searching [DEPRECATED] - not checked
109-
#. Use event times to create index names [DEPRECATED] - not checked
110-
111-
After setting parameters, one can create an index with the *Create* button.
98+
Index Pattern Configuration
99+
---------------------------
100+
101+
Kolla Ansible fully automates the creation of the default index pattern.
102+
During the deployment or reconfiguration process, an index pattern is
103+
automatically provisioned. By default, it is dynamically configured to
104+
match the indices defined by the ``opensearch_log_index_prefix``
105+
variable (which defaults to ``flog``). This results in an automatic
106+
index pattern of ``flog-*``.
107+
108+
The time filter field name is automatically set to ``@timestamp``,
109+
ensuring that all time-based aggregations and histograms work perfectly
110+
out of the box.
111+
112+
As a result, the **Discover** tab is immediately ready to display
113+
incoming log data upon your first login, requiring no manual setup
114+
from the operator.
115+
116+
**Adding Custom Index Patterns Manually**
117+
118+
If you configure custom Fluentd outputs to route specific logs to
119+
different indices, or if you ingest external metrics into OpenSearch,
120+
you may still need to create additional index patterns manually.
121+
To do this:
122+
123+
1. Navigate to **Dashboards Management** -> **Index Patterns** in the
124+
OpenSearch Dashboards UI.
125+
2. Click **Create index pattern**.
126+
3. Define your custom index pattern (e.g., ``my-custom-logs-*``).
127+
4. Select the appropriate Time Filter field name (typically
128+
``@timestamp``).
129+
5. Click the **Create index pattern** button.
112130

113131
Search logs - Discover tab
114132
--------------------------
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
features:
3+
- |
4+
Automated the creation of the default OpenSearch Dashboards
5+
index pattern. During deployment or reconfiguration, Kolla
6+
Ansible now automatically provisions an index pattern based
7+
on the ``opensearch_log_index_prefix`` (defaulting to
8+
``flog-*``) with ``@timestamp`` configured as the time field.
9+
This removes the need for operators to manually configure the
10+
initial index pattern upon their first login to the Dashboards
11+
UI.

0 commit comments

Comments
 (0)