bulk insert can not be done implicitly
Change-Id: Idc029b6ba2171f2182cecb2124f4a44922eb5910
This commit is contained in:
parent
15d8569019
commit
4eae981b79
|
@ -45,14 +45,7 @@ class MetricsFixer(object):
|
|||
|
||||
def process_msg(self, msg):
|
||||
try:
|
||||
data = json.loads(msg)
|
||||
if not isinstance(data, list):
|
||||
data = [data]
|
||||
result = ''
|
||||
for item in data:
|
||||
result += '{"index":{}}\n' + MetricsFixer._add_hash(item)
|
||||
result += '\n'
|
||||
return result
|
||||
return MetricsFixer._add_hash(json.loads(msg))
|
||||
except Exception:
|
||||
LOG.exception('')
|
||||
return ''
|
||||
|
|
|
@ -48,7 +48,7 @@ class TestMetricsFixer(tests.BaseTestCase):
|
|||
fixer = metrics_fixer.MetricsFixer()
|
||||
result = fixer.process_msg(json.dumps(items))
|
||||
self.assertTrue(isinstance(result, str))
|
||||
self.assertTrue(result.startswith('{"index":{}}'))
|
||||
self.assertFalse(result.startswith('{"index":{}}'))
|
||||
|
||||
def test_process_msg_multiple(self):
|
||||
items = [{'name': 'name1', 'dimensions': {'name1': 'value1'},
|
||||
|
|
|
@ -100,4 +100,4 @@ if __name__ == '__main__':
|
|||
setup_metrics(sys.argv)
|
||||
else:
|
||||
print('Usage: setup_metrics endpoint. For example:')
|
||||
print(' setup_metrics http://host:9000/data_2015')
|
||||
print(' setup_metrics http://<host_ip>:9090/v20/metrics')
|
||||
|
|
Loading…
Reference in New Issue