9b93fc8864
Implemented specification proposal for batch support at, https://review.openstack.org/#/c/273058/ Note, if you want to use this in the monasca-vagrant environment it should work. I've modified the value of the field kafka_url in etc/monasca/monasca_log_api.conf to use the kafka server in the mini-mon vm. After you've deployed monasca-vagrant using "vagrant up" ssh into mini-mon "vagrant ssh mini-mon" and then create a new topic for logs which can be done running the command: /opt/kafka/bin/kafka-topics.sh --create -zookeeper localhost:2181 --replication-factor 1 --partitions 128 --topic logs To watch the log messages at the console in the mini-mon VM /opt/kafka/bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic logs Change-Id: I4247d1824a237ecbe4db878e72485938f40a31c3
107 lines
2.9 KiB
Python
107 lines
2.9 KiB
Python
# Copyright 2015 kornicameister@gmail.com
|
|
# Copyright 2015 FUJITSU LIMITED
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
import os
|
|
from wsgiref import simple_server
|
|
|
|
import falcon
|
|
from oslo_config import cfg
|
|
from oslo_log import log
|
|
import paste.deploy
|
|
import simport
|
|
|
|
LOG = log.getLogger(__name__)
|
|
CONF = cfg.CONF
|
|
|
|
dispatcher_opts = [
|
|
cfg.StrOpt('versions',
|
|
default=None,
|
|
required=True,
|
|
help='Versions endpoint'),
|
|
cfg.StrOpt('logs',
|
|
default=None,
|
|
required=True,
|
|
help='Logs endpoint'),
|
|
cfg.StrOpt('healthchecks',
|
|
default=None,
|
|
required=True,
|
|
help='Healthchecks endpoint'),
|
|
cfg.StrOpt('logs_v3',
|
|
default=None,
|
|
help='Logs')
|
|
]
|
|
dispatcher_group = cfg.OptGroup(name='dispatcher', title='dispatcher')
|
|
CONF.register_group(dispatcher_group)
|
|
CONF.register_opts(dispatcher_opts, dispatcher_group)
|
|
|
|
|
|
def launch(conf, config_file='etc/monasca/log-api-config.conf'):
|
|
if conf and 'config_file' in conf:
|
|
config_file = conf.get('config_file')
|
|
|
|
log.register_options(CONF)
|
|
log.set_defaults()
|
|
CONF(args=[],
|
|
project='monasca_log_api',
|
|
default_config_files=[config_file])
|
|
log.setup(CONF, 'monasca_log_api')
|
|
|
|
app = falcon.API()
|
|
|
|
load_versions_resource(app)
|
|
load_logs_resource(app)
|
|
load_healthcheck_resource(app)
|
|
|
|
LOG.debug('Dispatcher drivers have been added to the routes!')
|
|
|
|
return app
|
|
|
|
|
|
def load_healthcheck_resource(app):
|
|
healthchecks = simport.load(CONF.dispatcher.healthchecks)()
|
|
app.add_route('/healthcheck', healthchecks)
|
|
|
|
|
|
def load_logs_resource(app):
|
|
logs = simport.load(CONF.dispatcher.logs)()
|
|
app.add_route('/v2.0/log/single', logs)
|
|
|
|
logs_v3 = simport.load(CONF.dispatcher.logs_v3)()
|
|
app.add_route('/v3.0/logs', logs_v3)
|
|
|
|
|
|
def load_versions_resource(app):
|
|
versions = simport.load(CONF.dispatcher.versions)()
|
|
app.add_route("/", versions)
|
|
app.add_route("/{version_id}", versions)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
base_path = '%s/..' % os.getcwd()
|
|
global_conf = {'config_file': (
|
|
'%s/%s' % (base_path, 'etc/monasca/log-api-config.conf'))}
|
|
|
|
wsgi_app = (
|
|
paste.deploy.loadapp(
|
|
'config:etc/monasca/log-api-config.ini',
|
|
relative_to=base_path,
|
|
global_conf=global_conf
|
|
)
|
|
)
|
|
|
|
httpd = simple_server.make_server('127.0.0.1', 8074, wsgi_app)
|
|
httpd.serve_forever()
|