Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change bulk operation for metrics and index templates to support Open… #186

Merged
merged 2 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions osbenchmark/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import zlib
from enum import Enum, IntEnum
from http.client import responses

import opensearchpy.helpers
import tabulate

from osbenchmark import client, time, exceptions, config, version, paths
Expand All @@ -54,7 +54,6 @@ def __init__(self, client, cluster_version=None):
self._cluster_version = cluster_version
self._cluster_distribution = None

# TODO #653: Remove version-specific support for metrics stores before 7.0.0.
def probe_version(self):
info = self.guarded(self._client.info)
try:
Expand All @@ -72,15 +71,7 @@ def probe_version(self):
self._cluster_distribution = "elasticsearch"

def put_template(self, name, template):
# TODO #653: Remove version-specific support for metrics stores before 7.0.0 (also adjust template)
if (self._cluster_version[0] > 6 and self._cluster_distribution == "elasticsearch") or \
self._cluster_distribution == "opensearch":
return self.guarded(self._client.indices.put_template, name=name, body=template, params={
# allows to include the type name although it is not allowed anymore by default
"include_type_name": "true"
})
else:
return self.guarded(self._client.indices.put_template, name=name, body=template)
return self.guarded(self._client.indices.put_template, name=name, body=template)

def template_exists(self, name):
return self.guarded(self._client.indices.exists_template, name)
Expand All @@ -102,13 +93,7 @@ def refresh(self, index):
return self.guarded(self._client.indices.refresh, index=index)

def bulk_index(self, index, doc_type, items):
# TODO #653: Remove version-specific support for metrics stores before 7.0.0.
# pylint: disable=import-outside-toplevel
import opensearchpy.helpers
if self._cluster_version[0] > 6:
self.guarded(opensearchpy.helpers.bulk, self._client, items, index=index, chunk_size=5000)
else:
self.guarded(opensearchpy.helpers.bulk, self._client, items, index=index, doc_type=doc_type, chunk_size=5000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some context on why removing metric store support for ES < 6 is needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing support for ES 6 and below is not explicitly needed but would require an additional maintenance burden for us. ES 7 deprecated certain parameters related to put template operations (more info here). If we want to continue supporting ES 6 as a data store we would need to create duplicates of the index templates and add some additional branching logic.

self.guarded(opensearchpy.helpers.bulk, self._client, items, index=index, chunk_size=5000)

def index(self, index, doc_type, item, id=None):
doc = {
Expand Down
160 changes: 79 additions & 81 deletions osbenchmark/resources/metrics-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,91 +9,89 @@
}
},
"mappings": {
"_doc": {
"date_detection": false,
"dynamic_templates": [
{
"strings": {
"match": "*",
"match_mapping_type": "string",
"mapping": {
"type": "keyword"
}
"date_detection": false,
"dynamic_templates": [
{
"strings": {
"match": "*",
"match_mapping_type": "string",
"mapping": {
"type": "keyword"
}
}
],
"_source": {
"enabled": true
},
"properties": {
"@timestamp": {
"type": "date",
"format": "epoch_millis"
},
"relative-time-ms": {
"type": "float"
},
"test-execution-id": {
"type": "keyword"
},
"test-execution-timestamp": {
"type": "date",
"format": "basic_date_time_no_millis",
"fields": {
"raw": {
"type": "keyword"
}
}
],
"_source": {
"enabled": true
},
"properties": {
"@timestamp": {
"type": "date",
"format": "epoch_millis"
},
"relative-time-ms": {
"type": "float"
},
"test-execution-id": {
"type": "keyword"
},
"test-execution-timestamp": {
"type": "date",
"format": "basic_date_time_no_millis",
"fields": {
"raw": {
"type": "keyword"
}
},
"environment": {
"type": "keyword"
},
"workload": {
"type": "keyword"
},
"test_procedure": {
"type": "keyword"
},
"provision-config-instance": {
"type": "keyword"
},
"name": {
"type": "keyword"
},
"value": {
"type": "float"
},
"min": {
"type": "float"
},
"max": {
"type": "float"
},
"mean": {
"type": "float"
},
"median": {
"type": "float"
},
"unit": {
"type": "keyword"
},
"sample-type": {
"type": "keyword"
},
"task": {
"type": "keyword"
},
"operation": {
"type": "keyword"
},
"operation-type": {
"type": "keyword"
},
"job": {
"type": "keyword"
}
},
"environment": {
"type": "keyword"
},
"workload": {
"type": "keyword"
},
"test_procedure": {
"type": "keyword"
},
"provision-config-instance": {
"type": "keyword"
},
"name": {
"type": "keyword"
},
"value": {
"type": "float"
},
"min": {
"type": "float"
},
"max": {
"type": "float"
},
"mean": {
"type": "float"
},
"median": {
"type": "float"
},
"unit": {
"type": "keyword"
},
"sample-type": {
"type": "keyword"
},
"task": {
"type": "keyword"
},
"operation": {
"type": "keyword"
},
"operation-type": {
"type": "keyword"
},
"job": {
"type": "keyword"
}
}
}
}
}
Loading