Browse Source

Reformat the readme.MD file and update the listOpt in kafka_conn.py

Change-Id: I6c2bb593308e096cee76b59bfd01f47875a29aea
Tong Li 3 years ago
parent
commit
b540bbb550
3 changed files with 80 additions and 29 deletions
  1. 75
    26
      README.md
  2. 2
    3
      kiloeyes/common/kafka_conn.py
  3. 3
    0
      kiloeyes/tests/setup_metrics.py

+ 75
- 26
README.md View File

@@ -190,58 +190,107 @@ Install Kiloeyes dependencies, server and services by following instructions abo
190 190
 
191 191
 Register kiloeyes as monitoring service with Keystone::
192 192
 =======================================================
193
-1. On the keystone server, setup environment variable:
193
+1. On the keystone server, setup environment variable::
194 194
 
195
-    export OS_USERNAME=admin
196
-    export OS_PASSWORD=<password>
197
-    export OS_TENANT_NAME=admin
198
-    export OS_AUTH_URL=http://localhost:5000/v2.0
195
+        export OS_USERNAME=admin
196
+        export OS_PASSWORD=<password>
197
+        export OS_TENANT_NAME=admin
198
+        export OS_AUTH_URL=http://localhost:5000/v3
199
+        export OS_IDENTITY_API_VERSION=3
199 200
 
200
-2. Create monitoring service by running the following command:
201
+2. Create monitoring service by running the following command::
201 202
 
202 203
     openstack service create --name kiloeyes --description "Monitoring" monitoring
203 204
 
204
-3. Create endpoint by running the following command:
205
+3. Create endpoint by running the following command::
205 206
 
206
-    openstack endpoint create --region RegionOne monitoring --publicurl http://<<kiloeyes_server_host_ip>>:9090/v2.0
207
+    openstack endpoint create --region RegionOne monitoring public http://<<kiloeyes_server_host_ip>>:9090/v2.0
207 208
 
208 209
 
209 210
 Install monasca-agent from the source::
210 211
 =======================================
211
-1. Get the source code:
212
+1. Get the source code::
212 213
 
213
-    git clone https://github.com/openstack/monasca-agent.git
214
+        git clone https://github.com/openstack/monasca-agent.git
214 215
 
215
-2. Change requirements.txt due to a bug in the monasca-agent project:
216
+2. Change requirements.txt due to a bug in the monasca-agent project::
216 217
 
217
-    requests==2.8.1
218
-    psutil=3.4.2
218
+        requests==2.8.1
219
+        psutil=3.4.2
219 220
 
220
-3. Install the requirements:
221
+3. Install the requirements::
221 222
 
222
-    sudo apt-get install python-dev python-pip
223
-    sudo pip install -r requirements.txt
223
+        sudo apt-get install python-dev python-pip
224
+        sudo pip install -r requirements.txt
224 225
 
225
-4. Install monasca agents:
226
+4. Install monasca agents::
226 227
 
227
-    sudo python setup.py install
228
+        sudo python setup.py install
228 229
 
229
-5. Run the following command to create agent configurations:
230
+5. Run the following command to create agent configurations::
230 231
 
231
-    sudo monasca-setup --username KEYSTONE_USERNAME --password KEYSTONE_PASSWORD --project_name KEYSTONE_PROJECT_NAME --keystone_url http://URL_OF_KEYSTONE_API:35357/v3
232
+        sudo monasca-setup --username KEYSTONE_USERNAME --password KEYSTONE_PASSWORD --project_name KEYSTONE_PROJECT_NAME --keystone_url http://URL_OF_KEYSTONE_API:5000/v3
232 233
 
233 234
     Replace KEYSTONE_USERNAME, KEYSTONE_PASSWORD, KEYSTONE_PROJECT_NAME,
234 235
     URL_OF_KEYSTONE_API with correct value according to your openstack
235 236
     keystone setups
236 237
 
237 238
 6. If the above runs with no errors, you need to add the following in
238
-/etc/monasca/agent/supervisor.conf file:
239
+/etc/monasca/agent/supervisor.conf file::
240
+
241
+        [inet_http_server]
242
+        port = localhost:9001
243
+
244
+7. Check configuration file at /etc/monasca/agent/agent.yml, the content
245
+should look like the following::
246
+
247
+        keystone_url: http://192.168.15.5:5000/v3
248
+        username: <<id to use to post data>>
249
+        password: <<user password>>
250
+        project_name: service
251
+        url: null
252
+
253
+    You can create a user in keystone for agent. Make sure that the user is
254
+    in the project named service.
255
+
256
+8. Restart monasca agent services on the machine by running the following command::
257
+
258
+        sudo service monasca-agent restart
259
+
260
+9. Agent log files will be in /var/log/monasca/agent directory.
261
+
262
+
263
+Enable keystone middleware for security
264
+=======================================
265
+To enable keystone middleware for security, the following configurations need
266
+to be done.
267
+
268
+1. Install keystone middleware::
269
+
270
+        sudo apt-get install python-keystonemiddleware
271
+
272
+2. Edit /etc/kiloeyes/kiloeyes.ini file to insert the middleware in the pipeline::
273
+
274
+        [pipeline:main]
275
+        #pipeline = api
276
+        pipeline = authtoken api
277
+
278
+        [filter:authtoken]
279
+        paste.filter_factory = keystonemiddleware.auth_token:filter_factory
280
+        delay_auth_decision = false
281
+3. Edit /etc/kiloeyes/kiloeyes.conf file to configure the middleware::
239 282
 
240
-    [inet_http_server]
241
-    port = localhost:9001
283
+        [keystone_authtoken]
284
+        auth_uri = http://<<keystone_ip>>:5000
285
+        auth_url = http://<<keystone_ip>>:5000
286
+        identity_uri = http://<<keystone_ip>>:5000
242 287
 
243
-7. Restart monasca agent services on the machine by running the following command:
288
+        auth_type = token
289
+        admin_user = admin
290
+        admin_password = <<admin password>>
291
+        admin_tenant_name = admin
244 292
 
245
-    sudo service monasca-agent restart
293
+4. Restart kiloeyes api server::
246 294
 
247
-8. Agent log files will be in /var/log/monasca/agent directory.
295
+        gunicorn --debug -k eventlet --worker-connections=20 --backlog=10
296
+            --paste /etc/kiloeyes/kiloeyes.ini

+ 2
- 3
kiloeyes/common/kafka_conn.py View File

@@ -19,7 +19,6 @@ from kafka import common
19 19
 from kafka import consumer
20 20
 from kafka import producer
21 21
 from oslo_config import cfg
22
-from oslo_config import types
23 22
 
24 23
 try:
25 24
     import ujson as json
@@ -47,8 +46,8 @@ KAFKA_OPTS = [
47 46
                 help=('Specify if the message received should be parsed. '
48 47
                       'If True, message will not be parsed, otherwise '
49 48
                       'messages will be parsed.')),
50
-    cfg.ListOpt('partitions', item_type=types.String(),
51
-                default=[0],
49
+    cfg.ListOpt('partitions',
50
+                default=['0'],
52 51
                 help='The sleep time when no messages on kafka queue.'),
53 52
     cfg.BoolOpt('drop_data', default=False,
54 53
                 help=('Specify if received data should be simply dropped. '

+ 3
- 0
kiloeyes/tests/setup_metrics.py View File

@@ -73,6 +73,7 @@ def setup_metrics(argv):
73 73
                     res = requests.post(argv[1], data=json.dumps(MOLD))
74 74
                     if res.status_code != 201 and res.status_code != 204:
75 75
                         print(json.dumps(MOLD))
76
+                        print('StatusCode is %s' % res.status_code)
76 77
                         exit(0)
77 78
                 # multiple messages
78 79
                 for k in range(3):
@@ -89,8 +90,10 @@ def setup_metrics(argv):
89 90
                         msg += ',' + json.dumps(MOLD)
90 91
                     msg += "]"
91 92
                     res = requests.post(argv[1], data=msg)
93
+
92 94
                     if res.status_code != 201 and res.status_code != 204:
93 95
                         print(json.dumps(MOLD))
96
+                        print('StatusCode is %s' % res.status_code)
94 97
                         exit(0)
95 98
         del MOLD_DIMENSIONS['key_' + str(a)]
96 99
         print('round finished %s' % a)

Loading…
Cancel
Save