Browse Source

Make the server more flexible with configuration files

The server can only find files in /etc/kiloeyes directory. This
patch set will allow a configuration file to be specified at
the command line

Change-Id: Ie8128048f5ea958595c49a375ff56825c89efe0c
Tong Li 3 years ago
parent
commit
fb786600f4
4 changed files with 17 additions and 5 deletions
  1. 7
    2
      kiloeyes/api/server.py
  2. 4
    0
      kiloeyes/common/es_conn.py
  3. 5
    2
      kiloeyes/v2/elasticsearch/alarms.py
  4. 1
    1
      setup_horizon.sh

+ 7
- 2
kiloeyes/api/server.py View File

@@ -38,9 +38,14 @@ def api_app(conf):
38 38
                      constant.KILOEYES_LOG_LEVELS)
39 39
     log.register_options(cfg.CONF)
40 40
 
41
-    cfg.CONF(args=[], project='kiloeyes')
41
+    if conf.get('name'):
42
+        name = conf.get('name')
43
+    else:
44
+        name = 'kiloeyes'
42 45
 
43
-    log.setup(cfg.CONF, 'kiloeyes')
46
+    cfg.CONF(args=[], project=name)
47
+
48
+    log.setup(cfg.CONF, name)
44 49
 
45 50
     dispatcher_manager = named.NamedExtensionManager(
46 51
         namespace=namespace.DISPATCHER_NS,

+ 4
- 0
kiloeyes/common/es_conn.py View File

@@ -92,6 +92,8 @@ class ESConnection(object):
92 92
             data = json.dumps(cond)
93 93
         else:
94 94
             data = {}
95
+        LOG.debug('The request path:%s?%s' % (self.search_path, q_string))
96
+
95 97
         return requests.post(self.search_path + "?" + q_string, data=data)
96 98
 
97 99
     def get_message_by_id(self, id):
@@ -111,6 +113,8 @@ class ESConnection(object):
111 113
             path = '%s%s%s/%s/' % (self.uri, self.index_prefix,
112 114
                                    index, self.doc_type)
113 115
 
116
+            LOG.debug('The request path:%s' % path)
117
+
114 118
             res = requests.post(path + id, data=msg)
115 119
             LOG.debug('Msg post with response code: %s' % res.status_code)
116 120
             return res.status_code

+ 5
- 2
kiloeyes/v2/elasticsearch/alarms.py View File

@@ -92,12 +92,15 @@ class AlarmDispatcher(object):
92 92
         params = ('{"aggs": {"latest_state": {'
93 93
                   '"terms": {"field": "alarm_definition.name", "size": 0},'
94 94
                   '"aggs": {"top_state_hits": {"top_hits": {"sort": ['
95
-                  '{"updated_timestamp": {"order": "desc"}}],'
95
+                  '{"updated_timestamp": {"order": "desc", '
96
+                  '"ignore_unmapped": true}}],'
96 97
                   '"_source": {"include": ['
97 98
                   '"state", "created_timestamp","updated_timestamp",'
98 99
                   '"metrics","sub_alarms","state_updated_timestamp",'
99 100
                   '"id", "alarm_definition"]},"size" : 1}}}}}}')
100 101
 
102
+        LOG.debug("params= %s" % params)
103
+
101 104
         es_res = self._es_conn.get_messages(json.loads(params),
102 105
                                             q_string='search_type=count')
103 106
         res.status = getattr(falcon, 'HTTP_%s' % es_res.status_code)
@@ -110,7 +113,7 @@ class AlarmDispatcher(object):
110 113
         res.body = ''
111 114
         result_elements = []
112 115
         try:
113
-            if es_res["latest_state"]:
116
+            if es_res and es_res.get("latest_state"):
114 117
                 res_data = es_res["latest_state"]["buckets"]
115 118
                 res.body = '['
116 119
                 for bucket in res_data:

+ 1
- 1
setup_horizon.sh View File

@@ -1,6 +1,6 @@
1 1
 service_id=`keystone service-create --name=monitoring --type=monitoring --description="Kiloeyes monitoring service" | awk 'BEGIN {FS="|"} NR == 6 {print $(NF-1)}'`
2 2
 service_id=`echo ${service_id}`
3 3
 echo $service_id
4
-keystone endpoint-create --region RegionOne --service-id=$service_id --publicurl=http://192.168.1.190:9090/v2.0 --internalurl=http://192.168.1.190:9090/v2.0 --adminurl=http://192.168.1.190/v2.0
4
+keystone endpoint-create --region RegionOne --service-id=$service_id --publicurl=http://192.168.56.180:9090/v2.0 --internalurl=http://192.168.56.180:9090/v2.0 --adminurl=http://192.168.56.180/v2.0
5 5
 
6 6
 

Loading…
Cancel
Save