Skip to content

Commit

Permalink
Merge pull request #116 from ViaQ/viaq_index_name
Browse files Browse the repository at this point in the history
Introduce viaq_index_name field
  • Loading branch information
richm authored Nov 13, 2019
2 parents 2f4198d + 82ae6c1 commit 07165e7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
7 changes: 7 additions & 0 deletions namespaces/_default_.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,10 @@ _index_type_:
store or application other than Elasticsearch, but you still need
to correlate data with the data stored in Elasticsearch, this field
will give you the exact document corresponding to the record.
- name: viaq_index_name
type: keyword
example: project.my-cool-project-in-lab04.748e92c2-70d7-11e9-b387-000d3af2d83b.2019.05.09
description: |
Index name in which this message will be stored within the Elasticsearch.
The value of this field is generated based on the source of the message.
5 changes: 4 additions & 1 deletion scripts/compare_against_released_patterns_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ def _support_index_pattern_fields_field_only(self, released_file_URL, es_version
generated_fields = [item for item in generated_fields if not item["name"] == "systemd.t.LINE_BREAK"]
generated_fields = [item for item in generated_fields if not item["name"] == "systemd.t.STREAM_ID"]
generated_fields = [item for item in generated_fields if not item["name"] == "systemd.t.SYSTEMD_INVOCATION_ID"]
# ======================

# https://github.com/ViaQ/elasticsearch-templates/pull/115
generated_fields = [item for item in generated_fields if not item["name"] == "viaq_index_name"]
# ======================

# ---- wget
print('\nDownloading released index pattern file for comparison:')
Expand Down
14 changes: 12 additions & 2 deletions scripts/compare_against_released_templates_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,14 @@ def _remove_all_field(data, es_version):
_idx_type = supported.index_type_name(es_version)
if "_all" in data["mappings"][_idx_type]:
del data["mappings"][_idx_type]["_all"]


@staticmethod
def _remove_viaq_index_name_field(generated_json, es_version):
# Remove 'viaq_index_name' field. It was introduced after support for ES6.x was added.
# https://github.com/ViaQ/elasticsearch-templates/pull/115
_idx_type = supported.index_type_name(es_version)
if "viaq_index_name" in generated_json["mappings"][_idx_type]["properties"]:
del generated_json["mappings"][_idx_type]["properties"]["viaq_index_name"]

@staticmethod
def _generate_json_index_template(args, es_version):
Expand Down Expand Up @@ -156,11 +163,14 @@ def _support_compare_index_templates(self, es_version, args, json_url):
del generated_json["mappings"][_idx_type]["properties"]["systemd"]["properties"]["t"]["properties"]["STREAM_ID"]
del generated_json["mappings"][_idx_type]["properties"]["systemd"]["properties"]["t"]["properties"]["SYSTEMD_INVOCATION_ID"]

self._remove_viaq_index_name_field(generated_json, es_version)

elif es_version == supported._es5x:
pass
self._remove_viaq_index_name_field(generated_json, es_version)

elif es_version == supported._es6x:
self._remove_all_field(generated_json, es_version)
self._remove_viaq_index_name_field(generated_json, es_version)
# ======================

generated_index_template = self._sort(generated_json)
Expand Down

0 comments on commit 07165e7

Please sign in to comment.