Browse Source

bulk insert can not be done implicitly

Change-Id: Idc029b6ba2171f2182cecb2124f4a44922eb5910
Tong Li 3 years ago
parent
commit
4eae981b79

+ 1
- 8
kiloeyes/microservice/metrics_fixer.py View File

@@ -45,14 +45,7 @@ class MetricsFixer(object):
45 45
 
46 46
     def process_msg(self, msg):
47 47
         try:
48
-            data = json.loads(msg)
49
-            if not isinstance(data, list):
50
-                data = [data]
51
-            result = ''
52
-            for item in data:
53
-                result += '{"index":{}}\n' + MetricsFixer._add_hash(item)
54
-                result += '\n'
55
-            return result
48
+            return MetricsFixer._add_hash(json.loads(msg))
56 49
         except Exception:
57 50
             LOG.exception('')
58 51
             return ''

+ 1
- 1
kiloeyes/tests/microservice/test_metrics_fixer.py View File

@@ -48,7 +48,7 @@ class TestMetricsFixer(tests.BaseTestCase):
48 48
         fixer = metrics_fixer.MetricsFixer()
49 49
         result = fixer.process_msg(json.dumps(items))
50 50
         self.assertTrue(isinstance(result, str))
51
-        self.assertTrue(result.startswith('{"index":{}}'))
51
+        self.assertFalse(result.startswith('{"index":{}}'))
52 52
 
53 53
     def test_process_msg_multiple(self):
54 54
         items = [{'name': 'name1', 'dimensions': {'name1': 'value1'},

+ 1
- 1
kiloeyes/tests/setup_metrics.py View File

@@ -100,4 +100,4 @@ if __name__ == '__main__':
100 100
         setup_metrics(sys.argv)
101 101
     else:
102 102
         print('Usage: setup_metrics endpoint. For example:')
103
-        print('       setup_metrics http://host:9000/data_2015')
103
+        print('       setup_metrics http://<host_ip>:9090/v20/metrics')

Loading…
Cancel
Save