add support to store events in elasticsearch in ceilometer.
Change-Id: I9c9801d2b83af8332df21f221c2ac8579898d56b
| ... | ... |
@@ -13,21 +13,16 @@ |
| 13 | 13 |
# |
| 14 | 14 |
# enable_service ceilometer-alarm-notifier ceilometer-alarm-evaluator |
| 15 | 15 |
# |
| 16 |
-# To ensure events are stored, add the following section to local.conf: |
|
| 17 |
-# |
|
| 18 |
-# [[post-config|$CEILOMETER_CONF]] |
|
| 19 |
-# [notification] |
|
| 20 |
-# store_events=True |
|
| 21 |
-# |
|
| 22 | 16 |
# Several variables set in the localrc section adjust common behaviors |
| 23 | 17 |
# of Ceilometer (see within for additional settings): |
| 24 | 18 |
# |
| 25 | 19 |
# CEILOMETER_USE_MOD_WSGI: When True, run the api under mod_wsgi. |
| 26 | 20 |
# CEILOMETER_PIPELINE_INTERVAL: The number of seconds between pipeline processing |
| 27 | 21 |
# runs. Default 600. |
| 28 |
-# CEILOMETER_BACKEND: The database backend (e.g. 'mysql', 'mongodb') |
|
| 22 |
+# CEILOMETER_BACKEND: The database backend (e.g. 'mysql', 'mongodb', 'es') |
|
| 29 | 23 |
# CEILOMETER_COORDINATION_URL: The URL for a group membership service provided |
| 30 | 24 |
# by tooz. |
| 25 |
+# CEILOMETER_EVENTS: Enable event collection |
|
| 31 | 26 |
|
| 32 | 27 |
|
| 33 | 28 |
# Dependencies: |
| ... | ... |
@@ -80,6 +75,7 @@ CEILOMETER_USE_MOD_WSGI=$(trueorfalse False CEILOMETER_USE_MOD_WSGI) |
| 80 | 80 |
|
| 81 | 81 |
# To enable OSprofiler change value of this variable to "notifications,profiler" |
| 82 | 82 |
CEILOMETER_NOTIFICATION_TOPICS=${CEILOMETER_NOTIFICATION_TOPICS:-notifications}
|
| 83 |
+CEILOMETER_EVENTS=${CEILOMETER_EVENTS:-True}
|
|
| 83 | 84 |
|
| 84 | 85 |
CEILOMETER_COORDINATION_URL=${CEILOMETER_COORDINATION_URL:-}
|
| 85 | 86 |
CEILOMETER_PIPELINE_INTERVAL=${CEILOMETER_PIPELINE_INTERVAL:-}
|
| ... | ... |
@@ -137,8 +133,10 @@ function _cleanup_ceilometer_apache_wsgi {
|
| 137 | 137 |
# cleanup_ceilometer() - Remove residual data files, anything left over from previous |
| 138 | 138 |
# runs that a clean run would need to clean up |
| 139 | 139 |
function cleanup_ceilometer {
|
| 140 |
- if [ "$CEILOMETER_BACKEND" != 'mysql' ] && [ "$CEILOMETER_BACKEND" != 'postgresql' ] ; then |
|
| 140 |
+ if [ "$CEILOMETER_BACKEND" = 'mongodb' ] ; then |
|
| 141 | 141 |
mongo ceilometer --eval "db.dropDatabase();" |
| 142 |
+ elif [ "$CEILOMETER_BACKEND" = 'es' ] ; then |
|
| 143 |
+ curl -XDELETE "localhost:9200/events_*" |
|
| 142 | 144 |
fi |
| 143 | 145 |
if [ "$CEILOMETER_USE_MOD_WSGI" == "True" ]; then |
| 144 | 146 |
_cleanup_ceilometer_apache_wsgi |
| ... | ... |
@@ -206,11 +204,21 @@ function configure_ceilometer {
|
| 206 | 206 |
|
| 207 | 207 |
configure_auth_token_middleware $CEILOMETER_CONF ceilometer $CEILOMETER_AUTH_CACHE_DIR |
| 208 | 208 |
|
| 209 |
+ iniset $CEILOMETER_CONF notification store_events $CEILOMETER_EVENTS |
|
| 210 |
+ |
|
| 209 | 211 |
if [ "$CEILOMETER_BACKEND" = 'mysql' ] || [ "$CEILOMETER_BACKEND" = 'postgresql' ] ; then |
| 210 | 212 |
iniset $CEILOMETER_CONF database alarm_connection $(database_connection_url ceilometer) |
| 211 | 213 |
iniset $CEILOMETER_CONF database event_connection $(database_connection_url ceilometer) |
| 212 | 214 |
iniset $CEILOMETER_CONF database metering_connection $(database_connection_url ceilometer) |
| 213 | 215 |
iniset $CEILOMETER_CONF DEFAULT collector_workers $API_WORKERS |
| 216 |
+ elif [ "$CEILOMETER_BACKEND" = 'es' ] ; then |
|
| 217 |
+ # es is only supported for events. we will use sql for alarming/metering. |
|
| 218 |
+ iniset $CEILOMETER_CONF database alarm_connection $(database_connection_url ceilometer) |
|
| 219 |
+ iniset $CEILOMETER_CONF database event_connection es://localhost:9200 |
|
| 220 |
+ iniset $CEILOMETER_CONF database metering_connection $(database_connection_url ceilometer) |
|
| 221 |
+ iniset $CEILOMETER_CONF DEFAULT collector_workers $API_WORKERS |
|
| 222 |
+ ${TOP_DIR}/pkg/elasticsearch.sh start
|
|
| 223 |
+ cleanup_ceilometer |
|
| 214 | 224 |
else |
| 215 | 225 |
iniset $CEILOMETER_CONF database alarm_connection mongodb://localhost:27017/ceilometer |
| 216 | 226 |
iniset $CEILOMETER_CONF database event_connection mongodb://localhost:27017/ceilometer |
| ... | ... |
@@ -264,7 +272,7 @@ function init_ceilometer {
|
| 264 | 264 |
rm -f $CEILOMETER_AUTH_CACHE_DIR/* |
| 265 | 265 |
|
| 266 | 266 |
if is_service_enabled mysql postgresql; then |
| 267 |
- if [ "$CEILOMETER_BACKEND" = 'mysql' ] || [ "$CEILOMETER_BACKEND" = 'postgresql' ] ; then |
|
| 267 |
+ if [ "$CEILOMETER_BACKEND" = 'mysql' ] || [ "$CEILOMETER_BACKEND" = 'postgresql' ] || [ "$CEILOMETER_BACKEND" = 'es' ] ; then |
|
| 268 | 268 |
recreate_database ceilometer |
| 269 | 269 |
$CEILOMETER_BIN_DIR/ceilometer-dbsync |
| 270 | 270 |
fi |
| ... | ... |
@@ -293,6 +301,11 @@ function install_ceilometer {
|
| 293 | 293 |
elif echo $CEILOMETER_COORDINATION_URL | grep -q '^redis:'; then |
| 294 | 294 |
install_redis |
| 295 | 295 |
fi |
| 296 |
+ |
|
| 297 |
+ if [ "$CEILOMETER_BACKEND" = 'es' ] ; then |
|
| 298 |
+ ${TOP_DIR}/pkg/elasticsearch.sh download
|
|
| 299 |
+ ${TOP_DIR}/pkg/elasticsearch.sh install
|
|
| 300 |
+ fi |
|
| 296 | 301 |
} |
| 297 | 302 |
|
| 298 | 303 |
# install_ceilometerclient() - Collect source and prepare |
| ... | ... |
@@ -47,11 +47,20 @@ function configure_elasticsearch {
|
| 47 | 47 |
: |
| 48 | 48 |
} |
| 49 | 49 |
|
| 50 |
+function _check_elasticsearch_ready {
|
|
| 51 |
+ # poll elasticsearch to see if it's started |
|
| 52 |
+ if ! wait_for_service 30 http://localhost:9200; then |
|
| 53 |
+ die $LINENO "Maximum timeout reached. Could not connect to ElasticSearch" |
|
| 54 |
+ fi |
|
| 55 |
+} |
|
| 56 |
+ |
|
| 50 | 57 |
function start_elasticsearch {
|
| 51 | 58 |
if is_ubuntu; then |
| 52 | 59 |
sudo /etc/init.d/elasticsearch start |
| 60 |
+ _check_elasticsearch_ready |
|
| 53 | 61 |
elif is_fedora; then |
| 54 | 62 |
sudo /bin/systemctl start elasticsearch.service |
| 63 |
+ _check_elasticsearch_ready |
|
| 55 | 64 |
else |
| 56 | 65 |
echo "Unsupported architecture...can not start elasticsearch." |
| 57 | 66 |
fi |