Sign inSign up

monasca/api

By monasca

•Updated over 1 year ago

Monasca RESTful API server

Image
0

100K+

monasca/api repository overview

⁠monasca-api Dockerfile

This image contains a containerized version of the Monasca API.

There are two implementations of the monasca-api:

Currently the python images are recommended. For more information on the Monasca project, see the wiki⁠.

Source repositories: monasca-api⁠ · monasca-docker⁠

⁠Tags

The images in this repository follow a few tagging conventions:

  • latest: refers to the latest stable Python point release, e.g. 1.5.0-python
  • latest-python, latest-java: as above, but specifically referring to the latest stable Python or Java point release, e.g. 1.5.0
  • 1.5.0, 1.5, 1: standard semver tags, based on git tags in the official repository⁠
  • 1.5.0-python, 1.5-python, 1-python: as above, but specifically referring to python-based images
  • mitaka, newton, etc: named versions following OpenStack release names built from the tip of the stable/RELEASENAME branches in the repository
  • mitaka-python, newton-python: as above, but specifically Python-based images
  • master, master-DATESTAMP: unstable builds from the master branch, not intended for general use

Note that unless otherwise specified, images will be Python-based. All Java-based images will be tagged as such, and likely will not support the configuration options described below.

⁠Usage

To run, the API needs to connect to working instances of Kafka, Influx, and MySQL. For metrics to be processed, one or more monasca-persister⁠ instances should be running as well. Alarming and alarm management management additionally require an instance of storm and monasca-thresh⁠ as well as monasca-notification⁠.

In environments resembling the official Kubernetes environment⁠ the image does not require additional configuration parameters, and can be run like so:

docker run -p 8070:8070 -it monasca/api:latest

NOTE: due to recent config file changes, this Docker container only supports API versions greater than 1.5.0. That is to say, as of this writing, there are no formal API releases supported by this Dockerfile. As such, the latest and latest-python tags will point to the latest master image until the next monasca-api release is published.

⁠Configuration

A number of environment variables can be passed to the container:

VariableDefaultDescription
LOG_LEVEL_ROOTWARNThe level of the root logger
LOG_LEVEL_CONSOLEINFOMinimum level for console output
LOG_LEVEL_ACCESSINFOMinimum level for access output
MONASCA_CONTAINER_API_PORT8070The API's HTTP port
KAFKA_URIkafka:9092The host and port for kafka
KAFKA_WAIT_FOR_TOPICSalarm-state-transitions,metricsTopics to wait on at startup
KAFKA_WAIT_RETRIES24# of kafka wait attempts
KAFKA_WAIT_DELAY5seconds to wait between attempts
INFLUX_HOSTinfluxdbThe host for influxdb
INFLUX_PORT8086The port for influxdb
INFLUX_USERmon_apiThe influx username
INFLUX_PASSWORDpasswordThe influx password
INFLUX_DBmonThe influx database name
MYSQL_HOSTmysqlAlarm DB connection string
MYSQL_USERmonapiMySQL DB username
MYSQL_PASSWORDpasswordMySQL DB password
MYSQL_DBmonMySQL database name
MYSQL_WAIT_RETRIES24# of MySQL connection attempts
MYSQL_WAIT_DELAY5seconds to wait between attempts
API_MYSQL_DISABLEDunsetif 'true' do not use a mysql database. Only metric API will work
KEYSTONE_IDENTITY_URIhttp://keystone:35357Keystone identity address
KEYSTONE_AUTH_URIhttp://keystone:5000Keystone auth address
KEYSTONE_ADMIN_USERadminKeystone admin account user
KEYSTONE_ADMIN_PASSWORDsecretadminKeystone admin account password
KEYSTONE_ADMIN_TENANTadminKeystone admin account tenant
KEYSTONE_INSECUREfalseAllow insecure Keystone connection
KEYSTONE_REGION_NAMEundefinedKeystone admin account region
GUNICORN_WORKERS9number of API worker processes
GUNICORN_WORKER_CLASSgeventasync worker class
GUNICORN_WORKER_CONNECTIONS2000no. connections for async worker
GUNICORN_BACKLOG1000gunicorn backlog size
AUTHORIZED_ROLESuser, domainuser, domainadmin, monasca-userRoles for admin Users
AGENT_AUTHORIZED_ROLESmonasca-agentRoles for metric write only users
READ_ONLY_AUTHORIZED_ROLESmonasca-read-only-userRoles for read only users
DELEGATE_AUTHORIZED_ROLESadminRoles allow to read/write cross tenant ID
ADD_ACCESS_LOGtrueif true, produce an access log on stderr
ACCESS_LOG_FORMAT%(asctime)s [%(process)d] gunicorn.access [%(levelname)s] %(message)sLog format for access log
ACCESS_LOG_FIELDS%(h)s %(l)s %(u)s %(t)s %(r)s %(s)s %(b)s "%(f)s" "%(a)s" %(L)sAccess log fields

If additional values need to be overridden, new config files or jinja2 templates can be provided by mounting a replacement on top of the original template:

  • /etc/monasca/api-config.conf.j2
  • /etc/monasca/api-config.ini.j2
  • /etc/monasca/api-logging.conf.j2

If jinja2 formatting is not desired, the environment variable CONFIG_TEMPLATE can be set to false. Note that the jinja2 template should still be overwritten (rather than the target file without the .j2 suffix) as it will be copied at runtime.

The config file sources are available in the repository⁠. If necessary, the generated config files can be viewed at runtime by running:

docker exec -it some_container_id cat /etc/monasca/api-config.conf
docker exec -it some_container_id cat /etc/monasca/api-config.ini
docker exec -it some_container_id cat /etc/monasca/api-logging.conf

⁠Troubleshooting

Container status can be checked by the following command (example):

docker ps --filter 'name=monasca' --format '{{.Names}}\t{{.Image}}\t{{.Status}}'

Result of health check can be get by the following command:

docker inspect --format '{{json .State.Health}}' monasca | python -m json.tool

Health check ExitCodes:

  • 1: Keystone authentication error
  • 2: Monasca API error

Tag summary

Content type

Image

Digest

sha256:65d149586…

Size

76.2 MB

Last updated

over 1 year ago

docker pull monasca/api:master