picasso/examples/openstack-alarms
Ian Wienand 20d75c95e7 Replace openstack.org git:// URLs with https://
This is a mechanically generated change to replace openstack.org
git:// URLs with https:// equivalents.

This is in aid of a planned future move of the git hosting
infrastructure to a self-hosted instance of gitea (https://gitea.io),
which does not support the git wire protocol at this stage.

This update should result in no functional change.

For more information see the thread at

 http://lists.openstack.org/pipermail/openstack-discuss/2019-March/003825.html

Change-Id: I22490685609bd102d3c4e263777c753e65c843e4
2019-03-24 20:35:35 +00:00
..
README.md Replace openstack.org git:// URLs with https:// 2019-03-24 20:35:35 +00:00

README.md

Integrating OpenStack Telemetry alarming with Picasso

OpenStack Aodh is the alarming service for OpenStack Telemetry. The Ceilometer service collects and transforms data from OpenStack services. Using Aodh, users/operators are able to setup alarms to trigger based on custom rules.

Deploying DevStack

To see how Aodh can be integrated with Picasso, we recommend using DevStack as the simplest and fastest way to get both Aodh and Picasso services running along with Nova, Glance and Neutron services. In order to get DevStack use following commands:

export DEVSTACK_DIR=~/devstack
git clone https://git.openstack.org/openstack-dev/devstack.git $DEVSTACK_DIR

Create a file, $DEVSTACK_DIR/local.conf with the following text:

[[local|localrc]]

enable_plugin aodh https://git.openstack.org/openstack/aodh
enable_plugin picasso git@github.com:openstack/picasso.git

# Picasso configuration
PICASSO_REPO=${PICASSO_REPO:-git@github.com:openstack/picasso.git}
PICASSO_BRANCH=${PICASSO_BRANCH:-master}
PICASSO_DIR=${PICASSO_DIR:-${DEST}/picasso}
PICASSO_PORT=${PICASSO_PORT:-10001}
PICASSO_LOG_LEVEL=${PICASSO_LOG_LEVEL:-DEBUG}
PICASSO_LOG_FILE=${PICASSO_LOG_FILE:-/var/log/picasso-api.log}

# Picasso client configuration
PICASSO_CLIENT_REPO=${PICASSO_CLIENT_REPO:-git@github.com:openstack/python-picassoclient.git}
PICASSO_CLIENT_DIR=${PICASSO_CLIENT_DIR:-${DEST}/python-picassoclient}
PICASSO_CLIENT_BRANCH=${PICASSO_CLIENT_BRANCH:-master}

# Functions parameters
FUNCTIONS_REPO=${FUNCTIONS_REPO:-git@github.com:iron-io/functions.git}
FUNCTIONS_BRANCH=${FUNCTIONS_BRANCH:-master}
FUNCTIONS_PORT=${FUNCTIONS_PORT:-10501}
FUNCTIONS_DB=${FUNCTIONS_DBPATH:-bolt://$FUNCTIONS_DIR/devstack.functions.storage.db?bucket=funcs}
FUNCTIONS_MQ=${FUNCTIONS_DBPATH:-bolt://$FUNCTIONS_DIR/devstack.functions.queue.db}
FUNCTIONS_LOG_LEVEL=${FUNCTIONS_LOG_LEVEL:-DEBUG}

DOCKERD_OPTS=${DOCKERD_OPTS:---dns 8.8.8.8 --dns 8.8.4.4 --storage-driver=overlay2 -H fd://}

Start DevStack installation

./stack.sh

Creating app and route

Once DevStack is installed, create a Picasso app:

openstack fn apps create alarm-notifier-app

+-------------+--------------------------------------------------+
| Field       | Value                                            |
+-------------+--------------------------------------------------+
| name        | alarm-notifier-app-f6fdaab020e                   |
| created_at  | 2016-12-12 18:08:26.077455                       |
| updated_at  | 2016-12-12 18:08:26.077477                       |
| project_id  | f6fdaab020ec4cdf85db3740520ec658                 |
| config      | None                                             |
| id          | f012ff74ea1c43b6a12c3c946fe96de5                 |
| description | App for project f6fdaab020ec4cdf85db3740520ec658 |
+-------------+--------------------------------------------------+

Create a route:

openstack fn routes create alarm-notifier-app-f6fdaab020e /hello async iron/hello --is-public

+-----------------+------------+
| Field           | Value      |
+-----------------+------------+
| image           | iron/hello |
| memory          | 128        |
| max_concurrency | 1          |
| timeout         | 30         |
| path            | /hello     |
| is_public       | True       |
| type            | async      |
+-----------------+------------+

Bootstrap VM on cirros image:

nova boot --image $(glance image-list | awk '/cirros-0.3.4-x86_64-uec / {print $2}') --flavor 42 test_alarms

+--------------------------------------+----------------------------------------------------------------+
| Property                             | Value                                                          |
+--------------------------------------+----------------------------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                                         |
| OS-EXT-AZ:availability_zone          |                                                                |
| OS-EXT-STS:power_state               | 0                                                              |
| OS-EXT-STS:task_state                | scheduling                                                     |
| OS-EXT-STS:vm_state                  | building                                                       |
| OS-SRV-USG:launched_at               | -                                                              |
| OS-SRV-USG:terminated_at             | -                                                              |
| accessIPv4                           |                                                                |
| accessIPv6                           |                                                                |
| adminPass                            | C9bfvqY4p3Lz                                                   |
| config_drive                         |                                                                |
| created                              | 2016-12-12T22:17:56Z                                           |
| description                          | -                                                              |
| flavor                               | m1.nano (42)                                                   |
| hostId                               |                                                                |
| id                                   | 7a4822c5-9fd4-44af-a54e-daef65650ca7                           |
| image                                | cirros-0.3.4-x86_64-uec (b60ad91d-2917-46b2-881c-0c5a277c6f8d) |
| key_name                             | -                                                              |
| locked                               | False                                                          |
| metadata                             | {}                                                             |
| name                                 | test_alarms                                                    |
| os-extended-volumes:volumes_attached | []                                                             |
| progress                             | 0                                                              |
| security_groups                      | default                                                        |
| status                               | BUILD                                                          |
| tags                                 | []                                                             |
| tenant_id                            | f6fdaab020ec4cdf85db3740520ec658                               |
| updated                              | 2016-12-12T22:17:56Z                                           |
| user_id                              | d0ec76f99e3c4e588119c8f6858a4ba3                               |
+--------------------------------------+----------------------------------------------------------------+

Create Aodh alarm:

aodh alarm create \
    --type threshold \
    --name cpu_high \
    --description 'instance running hot' \
    --meter-name cpu_util \
    --threshold 20.0 \
    --comparison-operator gt \
    --statistic max \
    --period 600 \
    --evaluation-periods 1 \
    --alarm-action $(openstack fn routes expose-url testapp-f6fdaab020ec4cdf85db37 /hello) \
    --query resource_id=$(nova list | grep test_alarms | awk '{print $2}')

+---------------------------+------------------------------------------------------------------------+
| Field                     | Value                                                                  |
+---------------------------+------------------------------------------------------------------------+
| alarm_actions             | [u'http://192.168.0.114:10001/r/testapp-f6fdaab020ec4cdf85db37/hello'] |
| alarm_id                  | f3460bad-2b5c-4c2f-b6e0-e82973e6ec71                                   |
| comparison_operator       | gt                                                                     |
| description               | instance running hot                                                   |
| enabled                   | True                                                                   |
| evaluation_periods        | 1                                                                      |
| exclude_outliers          | False                                                                  |
| insufficient_data_actions | []                                                                     |
| meter_name                | cpu_util                                                               |
| name                      | cpu_high                                                               |
| ok_actions                | []                                                                     |
| period                    | 600                                                                    |
| project_id                | f6fdaab020ec4cdf85db3740520ec658                                       |
| query                     | resource_id = 7a4822c5-9fd4-44af-a54e-daef65650ca7 AND                 |
|                           | project_id = f6fdaab020ec4cdf85db3740520ec658                          |
| repeat_actions            | False                                                                  |
| severity                  | low                                                                    |
| state                     | insufficient data                                                      |
| state_timestamp           | 2016-12-12T22:20:48.030596                                             |
| statistic                 | max                                                                    |
| threshold                 | 20.0                                                                   |
| time_constraints          | []                                                                     |
| timestamp                 | 2016-12-12T22:20:48.030596                                             |
| type                      | threshold                                                              |
| user_id                   | d0ec76f99e3c4e588119c8f6858a4ba3                                       |
+---------------------------+------------------------------------------------------------------------+

To trigger the alarm, generate CPU load on the provisioned VM:

ssh cirros@10.0.0.7
cirros@10.0.0.7 password: 
dd if=/dev/zero of=/dev/null

Once our threshold has been reached, Aodh will notify with an HTTP Callback to our async function assigned to the route we created.

Conclusion

Picasso's ability to provide public sync/async function routes can be used to integrate with web hooks, such as Aodh, the OpenStack Telemetry alarming service.