Skip to content

Commit

Permalink
Content of index-patterns depends on supported version
Browse files Browse the repository at this point in the history
Closes #119
  • Loading branch information
lukas-vlcek committed Jan 15, 2020
1 parent addbceb commit c5abef4
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scripts/generate_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def object_types_to_template(template_definition, output, output_index_pattern,
default_mapping, default_mapping_yml['field_defaults'], process_leaf, True))

add_type_version(default_mapping_yml["version"], skeleton['mappings'][_idx_type])
add_index_pattern(template_definition['elasticsearch_template']['index_pattern'], skeleton)
add_index_pattern(template_definition['elasticsearch_template'][supported.index_patterns(es_version)], skeleton)
add_index_order(template_definition['elasticsearch_template']['order'], skeleton)

for field in ['_source', '_all', 'include_in_all']:
Expand Down
17 changes: 17 additions & 0 deletions scripts/supported_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@
_es6x: _doc
}

_index_templates = {
_es2x: "index_pattern_old_model",
_es5x: "index_pattern_old_model",
_es6x: "index_pattern"
}


def index_patterns(es_version):
"""
We change the index_patterns depending on ES version. Starting with ES6 we are switching to the
new data model. See https://github.com/openshift/origin-aggregated-logging/pull/1807#issuecomment-573721937
:param es_version:
:return: Field name containing index_patterns
"""
return _index_templates[es_version]


def index_type_name(es_version):
"""
Expand Down
1 change: 1 addition & 0 deletions templates/ci_model/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ skeleton_index_pattern_path: ../skeleton-index-pattern.json

elasticsearch_template:
name: com.redhat.viaq-ci
index_pattern_old_model: "viaq-ci-*"
index_pattern: "viaq-ci-*"
order: 10

Expand Down
1 change: 1 addition & 0 deletions templates/collectd_metrics/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ skeleton_index_pattern_path: ../skeleton-index-pattern.json
# see https://www.elastic.co/guide/en/elasticsearch/reference/2.4/mapping-source-field.html#_disabling_the_literal__source_literal_field
elasticsearch_template:
name: org.ovirt.viaq-collectd
index_pattern_old_model: "project.ovirt-metrics-*"
index_pattern: "project.ovirt-metrics-*"
order: 20
_source:
Expand Down
1 change: 1 addition & 0 deletions templates/fedora_ci/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ skeleton_index_pattern_path: ../skeleton-index-pattern.json

elasticsearch_template:
name: com.redhat.fedora-ci
index_pattern_old_model: "centosci-pipeline-prod-*"
index_pattern: "centosci-pipeline-prod-*"
order: 10

Expand Down
1 change: 1 addition & 0 deletions templates/foreman/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ skeleton_index_pattern_path: ../skeleton-index-pattern.json

elasticsearch_template:
name: org.foreman.viaq-cdm
index_pattern_old_model: "project.foreman-*"
index_pattern: "project.foreman-*"
order: 20

Expand Down
3 changes: 2 additions & 1 deletion templates/openshift/template-operations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ skeleton_index_pattern_path: ../skeleton-index-pattern.json

elasticsearch_template:
name: com.redhat.viaq-openshift-operations
index_pattern: ".operations.*"
index_pattern_old_model: ".operations.*"
index_pattern: [ "node.infra-*", "container.infra-*", "audit.infra-*" ]
order: 10

namespaces:
Expand Down
3 changes: 2 additions & 1 deletion templates/openshift/template-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ skeleton_index_pattern_path: ../skeleton-index-pattern.json

elasticsearch_template:
name: com.redhat.viaq-openshift-project
index_pattern: "project.*"
index_pattern_old_model: "project.*"
index_pattern: "container.app-*"
order: 10

namespaces:
Expand Down
1 change: 1 addition & 0 deletions templates/test/template-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ skeleton_index_pattern_path: ../skeleton-index-pattern.json

elasticsearch_template:
name: foo.test
index_pattern_old_model: ".test.*"
index_pattern: ".test.*"
order: 10

Expand Down

0 comments on commit c5abef4

Please sign in to comment.