Install schemas in DevStack
Install the following schemas: mon in Influxdb mon in MySQL winchester in MySQL kafka topics in Kafka Change-Id: Ie3b263988256f7bcbda0616d1c8264b49c9e88b5
This commit is contained in:
parent
4046be46c6
commit
00597b5c83
24
devstack/files/env.sh
Normal file
24
devstack/files/env.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#
|
||||
# (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# Environment variables for use with python-monascaclient running via monaca-vagrant
|
||||
|
||||
. /opt/monasca/bin/activate
|
||||
export OS_USERNAME=mini-mon
|
||||
export OS_PASSWORD=password
|
||||
export OS_PROJECT_NAME=mini-mon
|
||||
export OS_AUTH_URL=http://127.0.0.1:35357/v3/
|
@ -1,2 +1,19 @@
|
||||
#
|
||||
# (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# Logging
|
||||
STDERR="/var/log/influxdb/influxd.log"
|
||||
|
@ -1,3 +1,20 @@
|
||||
#
|
||||
# (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
description "Kafka"
|
||||
|
||||
start on runlevel [2345]
|
||||
|
@ -1,3 +1,20 @@
|
||||
#
|
||||
# (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
############################# Server Basics #############################
|
||||
|
||||
# The id of the broker. This must be set to a unique integer for each broker.
|
||||
|
101
devstack/files/schema/influxdb_setup.py
Normal file
101
devstack/files/schema/influxdb_setup.py
Normal file
@ -0,0 +1,101 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#
|
||||
# (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
"""A simple script to setup influxdb user and roles. At some point this should
|
||||
become a more full featured module. Also this assumes that none of the
|
||||
python based influxdb clients are available on this system.
|
||||
"""
|
||||
|
||||
ADMIN = 'root'
|
||||
ADMIN_PASS = 'root'
|
||||
DBNAME = 'mon'
|
||||
USERS = {}
|
||||
USERS['mon_api'] = 'password'
|
||||
USERS['mon_persister'] = 'password'
|
||||
|
||||
URL = 'http://127.0.0.1:8086'
|
||||
|
||||
SHARDSPACE_NAME = 'persister_all'
|
||||
REPLICATION = 1
|
||||
RETENTION = '90d'
|
||||
|
||||
import json
|
||||
import sys
|
||||
import time
|
||||
import urllib
|
||||
import urllib2
|
||||
|
||||
|
||||
def influxdb_get(uri, query, db=None):
|
||||
"""Runs a query via HTTP GET and returns the response as a Python list."""
|
||||
|
||||
getparams = {"q": query}
|
||||
if db:
|
||||
getparams['db'] = db
|
||||
|
||||
try:
|
||||
params = urllib.urlencode(getparams)
|
||||
uri = "{}&{}".format(uri,params)
|
||||
req = urllib2.urlopen(uri)
|
||||
json_value = json.loads(req.read())
|
||||
|
||||
if (len(json_value['results'][0]) > 0 and
|
||||
'values' in json_value['results'][0]['series'][0]):
|
||||
return json_value['results'][0]['series'][0]['values']
|
||||
else:
|
||||
return []
|
||||
|
||||
except KeyError:
|
||||
print "Query returned a non-successful result: {0}".format(json_value['results'])
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
"""If necessary, create the database, retention policy, and users"""
|
||||
auth_str = '?u=%s&p=%s' % (ADMIN, ADMIN_PASS)
|
||||
api_uri = "{0}/query{1}".format(URL, auth_str)
|
||||
|
||||
# List current databases
|
||||
dbs = influxdb_get(uri=api_uri, query="SHOW DATABASES")
|
||||
if [DBNAME] not in dbs:
|
||||
print "Creating database '{}'".format(DBNAME)
|
||||
influxdb_get(uri=api_uri, query="CREATE DATABASE {0}".format(DBNAME))
|
||||
print "...created!"
|
||||
|
||||
# Check retention policy
|
||||
policies = influxdb_get(uri=api_uri,
|
||||
query="SHOW RETENTION POLICIES {0}".format(DBNAME))
|
||||
if not any(pol[0] == SHARDSPACE_NAME for pol in policies):
|
||||
# Set retention policy
|
||||
policy = "CREATE RETENTION POLICY {0} ON {1} DURATION {2} REPLICATION {3} DEFAULT".format(SHARDSPACE_NAME,
|
||||
DBNAME,
|
||||
RETENTION,
|
||||
REPLICATION)
|
||||
influxdb_get(uri=api_uri, db=DBNAME, query=policy)
|
||||
|
||||
# Create the users
|
||||
users = influxdb_get(uri=api_uri, query="SHOW USERS", db=DBNAME)
|
||||
for name, password in USERS.iteritems():
|
||||
if not any(user[0] == name for user in users):
|
||||
influxdb_get(uri=api_uri,
|
||||
query=unicode("CREATE USER {0} WITH PASSWORD '{1}'".format(name, password)),
|
||||
db=DBNAME)
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
277
devstack/files/schema/mon_mysql.sql
Normal file
277
devstack/files/schema/mon_mysql.sql
Normal file
@ -0,0 +1,277 @@
|
||||
/*
|
||||
* (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
DROP DATABASE IF EXISTS `mon`;
|
||||
|
||||
CREATE DATABASE IF NOT EXISTS `mon` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
USE `mon`;
|
||||
|
||||
SET foreign_key_checks = 0;
|
||||
|
||||
/*
|
||||
* Enum tables
|
||||
*/
|
||||
CREATE TABLE `alarm_state` (
|
||||
`name` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `alarm_definition_severity` (
|
||||
`name` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `notification_method_type` (
|
||||
`name` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `stream_actions_action_type` (
|
||||
`name` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `alarm` (
|
||||
`id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`alarm_definition_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`state` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`lifecycle_state` varchar(50) DEFAULT NULL,
|
||||
`link` varchar(512) DEFAULT NULL,
|
||||
`created_at` datetime NOT NULL,
|
||||
`state_updated_at` datetime,
|
||||
`updated_at` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `alarm_definition_id` (`alarm_definition_id`),
|
||||
CONSTRAINT `fk_alarm_definition_id` FOREIGN KEY (`alarm_definition_id`) REFERENCES `alarm_definition` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_alarm_alarm_state` FOREIGN KEY (`state`) REFERENCES `alarm_state` (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `alarm_action` (
|
||||
`alarm_definition_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`alarm_state` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`action_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`alarm_definition_id`,`alarm_state`,`action_id`),
|
||||
CONSTRAINT `fk_alarm_action_alarm_definition_id` FOREIGN KEY (`alarm_definition_id`) REFERENCES `alarm_definition` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_alarm_action_notification_method_id` FOREIGN KEY (`action_id`) REFERENCES `notification_method` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_alarm_action_alarm_state` FOREIGN KEY (`alarm_state`) REFERENCES `alarm_state` (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `alarm_definition` (
|
||||
`id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`tenant_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`expression` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`severity` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`match_by` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT '',
|
||||
`actions_enabled` tinyint(1) NOT NULL DEFAULT '1',
|
||||
`created_at` datetime NOT NULL,
|
||||
`updated_at` datetime NOT NULL,
|
||||
`deleted_at` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tenant_id` (`tenant_id`),
|
||||
KEY `deleted_at` (`deleted_at`),
|
||||
CONSTRAINT `fk_alarm_definition_severity` FOREIGN KEY (`severity`) REFERENCES `alarm_definition_severity` (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `alarm_metric` (
|
||||
`alarm_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`metric_definition_dimensions_id` binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
PRIMARY KEY (`alarm_id`,`metric_definition_dimensions_id`),
|
||||
KEY `alarm_id` (`alarm_id`),
|
||||
KEY `metric_definition_dimensions_id` (`metric_definition_dimensions_id`),
|
||||
CONSTRAINT `fk_alarm_id` FOREIGN KEY (`alarm_id`) REFERENCES `alarm` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `metric_definition` (
|
||||
`id` binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`tenant_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`region` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `metric_definition_dimensions` (
|
||||
`id` binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`metric_definition_id` binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`metric_dimension_set_id` binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
KEY `metric_definition_id` (`metric_definition_id`),
|
||||
KEY `metric_dimension_set_id` (`metric_dimension_set_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
/*
|
||||
* mysql limits the size of a unique key to 767 bytes. The utf8mb4 charset requires
|
||||
* 4 bytes to be allocated for each character while the utf8 charset requires 3 bytes.
|
||||
* The utf8 charset should be sufficient for any reasonable characters, see the definition
|
||||
* of supplementary characters for what it doesn't support.
|
||||
* Even with utf8, the unique key length would be 785 bytes so only a subset of the
|
||||
* name is used. Potentially the size of the name should be limited to 250 characters
|
||||
* which would resolve this issue.
|
||||
*
|
||||
* The unique key is required to allow high performance inserts without doing a select by using
|
||||
* the "insert into metric_dimension ... on duplicate key update dimension_set_id=dimension_set_id
|
||||
* syntax
|
||||
*/
|
||||
CREATE TABLE `metric_dimension` (
|
||||
`dimension_set_id` binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
|
||||
`value` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
|
||||
UNIQUE KEY `metric_dimension_key` (`dimension_set_id`,`name`(252)),
|
||||
KEY `dimension_set_id` (`dimension_set_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='PRIMARY KEY (`id`)';
|
||||
|
||||
CREATE TABLE `notification_method` (
|
||||
`id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`tenant_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`name` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`address` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`created_at` datetime NOT NULL,
|
||||
`updated_at` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_alarm_noticication_method_type` FOREIGN KEY (`type`) REFERENCES `notification_method_type` (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `sub_alarm_definition` (
|
||||
`id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`alarm_definition_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`function` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`metric_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`operator` varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`threshold` double NOT NULL,
|
||||
`period` int(11) NOT NULL,
|
||||
`periods` int(11) NOT NULL,
|
||||
`created_at` datetime NOT NULL,
|
||||
`updated_at` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `fk_sub_alarm_definition` (`alarm_definition_id`),
|
||||
CONSTRAINT `fk_sub_alarm_definition` FOREIGN KEY (`alarm_definition_id`) REFERENCES `alarm_definition` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `sub_alarm_definition_dimension` (
|
||||
`sub_alarm_definition_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`dimension_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`value` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
CONSTRAINT `fk_sub_alarm_definition_dimension` FOREIGN KEY (`sub_alarm_definition_id`) REFERENCES `sub_alarm_definition` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `sub_alarm` (
|
||||
`id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`alarm_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`sub_expression_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`expression` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`created_at` datetime NOT NULL,
|
||||
`updated_at` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `fk_sub_alarm` (`alarm_id`),
|
||||
KEY `fk_sub_alarm_expr` (`sub_expression_id`),
|
||||
CONSTRAINT `fk_sub_alarm` FOREIGN KEY (`alarm_id`) REFERENCES `alarm` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_sub_alarm_expr` FOREIGN KEY (`sub_expression_id`) REFERENCES `sub_alarm_definition` (`id`)
|
||||
);
|
||||
|
||||
CREATE TABLE `schema_migrations` (
|
||||
`version` varchar(255) NOT NULL,
|
||||
UNIQUE KEY `unique_schema_migrations` (`version`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
/*
|
||||
* The tables needed by Monasca for event stream definitions
|
||||
*/
|
||||
CREATE TABLE `stream_actions` (
|
||||
`stream_definition_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`action_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`action_type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`stream_definition_id`,`action_id`,`action_type`),
|
||||
KEY `stream_definition_id` (`stream_definition_id`),
|
||||
KEY `action_type` (`action_type`),
|
||||
KEY `fk_stream_action_notification_method_id` (`action_id`),
|
||||
CONSTRAINT `fk_stream_action_stream_definition_id` FOREIGN KEY (`stream_definition_id`) REFERENCES `stream_definition` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_stream_action_notification_method_id` FOREIGN KEY (`action_id`) REFERENCES `notification_method` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_stream_actions_action_type` FOREIGN KEY (`action_type`) REFERENCES `stream_actions_action_type` (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `stream_definition` (
|
||||
`id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`tenant_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`name` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`select_by` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`group_by` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`fire_criteria` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`expiration` int(10) UNSIGNED DEFAULT '0',
|
||||
`actions_enabled` tinyint(1) NOT NULL DEFAULT '1',
|
||||
`created_at` datetime NOT NULL,
|
||||
`updated_at` datetime NOT NULL,
|
||||
`deleted_at` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `tenant_name` (`tenant_id`,`name`),
|
||||
KEY `name` (`name`),
|
||||
KEY `tenant_id` (`tenant_id`),
|
||||
KEY `deleted_at` (`deleted_at`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `event_transform` (
|
||||
`id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`tenant_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`description` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`specification` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`enabled` bool DEFAULT NULL,
|
||||
`created_at` DATETIME NOT NULL,
|
||||
`updated_at` DATETIME NOT NULL,
|
||||
`deleted_at` DATETIME DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `tenant_name` (`tenant_id`,`name`),
|
||||
KEY `name` (`name`),
|
||||
KEY `tenant_id` (`tenant_id`),
|
||||
KEY `deleted_at` (`deleted_at`),
|
||||
KEY `created_at` (`created_at`),
|
||||
KEY `updated_at` (`updated_at`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
/*
|
||||
* To require ssl connections add 'REQUIRE SSL' to the end of all grant statements
|
||||
*/
|
||||
GRANT ALL ON mon.* TO 'notification'@'%' IDENTIFIED BY 'password';
|
||||
GRANT ALL ON mon.* TO 'notification'@'localhost' IDENTIFIED BY 'password';
|
||||
GRANT ALL ON mon.* TO 'monapi'@'%' IDENTIFIED BY 'password';
|
||||
GRANT ALL ON mon.* TO 'monapi'@'localhost' IDENTIFIED BY 'password';
|
||||
GRANT ALL ON mon.* TO 'thresh'@'%' IDENTIFIED BY 'password';
|
||||
GRANT ALL ON mon.* TO 'thresh'@'localhost' IDENTIFIED BY 'password';
|
||||
|
||||
SET foreign_key_checks = 1;
|
||||
|
||||
/* provide data for enum tables */
|
||||
insert into `alarm_state` values ('UNDETERMINED');
|
||||
insert into `alarm_state` values ('OK');
|
||||
insert into `alarm_state` values ('ALARM');
|
||||
|
||||
insert into `alarm_definition_severity` values ('LOW');
|
||||
insert into `alarm_definition_severity` values ('MEDIUM');
|
||||
insert into `alarm_definition_severity` values ('HIGH');
|
||||
insert into `alarm_definition_severity` values ('CRITICAL');
|
||||
|
||||
insert into `notification_method_type` values ('EMAIL');
|
||||
insert into `notification_method_type` values ('WEBHOOK');
|
||||
insert into `notification_method_type` values ('PAGERDUTY');
|
||||
|
||||
insert into `stream_actions_action_type` values ('FIRE');
|
||||
insert into `stream_actions_action_type` values ('EXPIRE');
|
||||
/* provide data for enum tables */
|
140
devstack/files/schema/winchester.sql
Normal file
140
devstack/files/schema/winchester.sql
Normal file
@ -0,0 +1,140 @@
|
||||
/*
|
||||
* (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
DROP DATABASE IF EXISTS `winchester`;
|
||||
CREATE DATABASE IF NOT EXISTS `winchester`;
|
||||
USE `winchester`;
|
||||
|
||||
/*
|
||||
* To require ssl connections add 'REQUIRE SSL' to the end of all grant statements
|
||||
*/
|
||||
GRANT ALL ON winchester.* TO 'notification'@'%' IDENTIFIED BY 'password';
|
||||
GRANT ALL ON winchester.* TO 'notification'@'localhost' IDENTIFIED BY 'password';
|
||||
GRANT ALL ON winchester.* TO 'monapi'@'%' IDENTIFIED BY 'password';
|
||||
GRANT ALL ON winchester.* TO 'monapi'@'localhost' IDENTIFIED BY 'password';
|
||||
GRANT ALL ON winchester.* TO 'thresh'@'%' IDENTIFIED BY 'password';
|
||||
GRANT ALL ON winchester.* TO 'thresh'@'localhost' IDENTIFIED BY 'password';
|
||||
|
||||
|
||||
CREATE TABLE alembic_version (
|
||||
version_num VARCHAR(32) NOT NULL
|
||||
);
|
||||
|
||||
-- Running upgrade None -> 3ab6d7bf80cd
|
||||
|
||||
CREATE TABLE event_type (
|
||||
id INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`desc` VARCHAR(255),
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE (`desc`)
|
||||
);
|
||||
|
||||
CREATE TABLE event (
|
||||
id INTEGER NOT NULL AUTO_INCREMENT,
|
||||
message_id VARCHAR(50),
|
||||
generated DECIMAL(20, 6),
|
||||
event_type_id INTEGER,
|
||||
PRIMARY KEY (id),
|
||||
FOREIGN KEY(event_type_id) REFERENCES event_type (id),
|
||||
UNIQUE (message_id)
|
||||
);
|
||||
|
||||
CREATE TABLE trait (
|
||||
event_id INTEGER NOT NULL,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
type INTEGER,
|
||||
t_string VARCHAR(255),
|
||||
t_float FLOAT,
|
||||
t_int INTEGER,
|
||||
t_datetime DECIMAL(20, 6),
|
||||
PRIMARY KEY (event_id, name),
|
||||
FOREIGN KEY(event_id) REFERENCES event (id)
|
||||
);
|
||||
|
||||
INSERT INTO alembic_version (version_num) VALUES ('3ab6d7bf80cd');
|
||||
|
||||
-- Running upgrade 3ab6d7bf80cd -> 44289d1492e6
|
||||
|
||||
CREATE TABLE stream (
|
||||
id INTEGER NOT NULL AUTO_INCREMENT,
|
||||
first_event DECIMAL(20, 6) NOT NULL,
|
||||
last_event DECIMAL(20, 6) NOT NULL,
|
||||
expire_timestamp DECIMAL(20, 6),
|
||||
fire_timestamp DECIMAL(20, 6),
|
||||
name VARCHAR(255) NOT NULL,
|
||||
state INTEGER NOT NULL,
|
||||
state_serial_no INTEGER NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE INDEX ix_stream_expire_timestamp ON stream (expire_timestamp);
|
||||
|
||||
CREATE INDEX ix_stream_fire_timestamp ON stream (fire_timestamp);
|
||||
|
||||
CREATE INDEX ix_stream_name ON stream (name);
|
||||
|
||||
CREATE INDEX ix_stream_state ON stream (state);
|
||||
|
||||
CREATE TABLE dist_trait (
|
||||
stream_id INTEGER NOT NULL,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
type INTEGER,
|
||||
dt_string VARCHAR(255),
|
||||
dt_float FLOAT,
|
||||
dt_int INTEGER,
|
||||
dt_datetime DECIMAL(20, 6),
|
||||
dt_timerange_begin DECIMAL(20, 6),
|
||||
dt_timerange_end DECIMAL(20, 6),
|
||||
PRIMARY KEY (stream_id, name),
|
||||
FOREIGN KEY(stream_id) REFERENCES stream (id)
|
||||
);
|
||||
|
||||
CREATE INDEX ix_dist_trait_dt_datetime ON dist_trait (dt_datetime);
|
||||
|
||||
CREATE INDEX ix_dist_trait_dt_float ON dist_trait (dt_float);
|
||||
|
||||
CREATE INDEX ix_dist_trait_dt_int ON dist_trait (dt_int);
|
||||
|
||||
CREATE INDEX ix_dist_trait_dt_string ON dist_trait (dt_string);
|
||||
|
||||
CREATE INDEX ix_dist_trait_dt_timerange_begin ON dist_trait (dt_timerange_begin);
|
||||
|
||||
CREATE INDEX ix_dist_trait_dt_timerange_end ON dist_trait (dt_timerange_end);
|
||||
|
||||
CREATE TABLE streamevent (
|
||||
stream_id INTEGER NOT NULL,
|
||||
event_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (stream_id, event_id),
|
||||
FOREIGN KEY(event_id) REFERENCES event (id),
|
||||
FOREIGN KEY(stream_id) REFERENCES stream (id)
|
||||
);
|
||||
|
||||
CREATE INDEX ix_event_generated ON event (generated);
|
||||
|
||||
CREATE INDEX ix_event_message_id ON event (message_id);
|
||||
|
||||
CREATE INDEX ix_event_type_id ON event (event_type_id);
|
||||
|
||||
CREATE INDEX ix_trait_t_datetime ON trait (t_datetime);
|
||||
|
||||
CREATE INDEX ix_trait_t_float ON trait (t_float);
|
||||
|
||||
CREATE INDEX ix_trait_t_int ON trait (t_int);
|
||||
|
||||
CREATE INDEX ix_trait_t_string ON trait (t_string);
|
||||
|
||||
UPDATE alembic_version SET version_num='44289d1492e6';
|
@ -1,3 +1,20 @@
|
||||
#
|
||||
# (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# Modified from http://packages.ubuntu.com/saucy/zookeeperd
|
||||
NAME=zookeeper
|
||||
ZOOCFGDIR=/etc/zookeeper/conf
|
||||
|
@ -1,3 +1,20 @@
|
||||
#
|
||||
# (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# From http://packages.ubuntu.com/saucy/zookeeperd
|
||||
|
||||
# ZooKeeper Logging Configuration
|
||||
|
@ -1,3 +1,19 @@
|
||||
#
|
||||
# (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# http://hadoop.apache.org/zookeeper/docs/current/zookeeperAdmin.html
|
||||
|
||||
# The number of milliseconds of each tick
|
||||
|
@ -53,6 +53,12 @@ function install_monasca {
|
||||
|
||||
install_influxdb
|
||||
|
||||
install_cli_creds
|
||||
|
||||
install_schema
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function post_config_monasca {
|
||||
@ -76,12 +82,16 @@ function clean_monasca {
|
||||
|
||||
unstack_monasca
|
||||
|
||||
clean_schema
|
||||
|
||||
clean_cli_creds
|
||||
|
||||
clean_influxdb
|
||||
|
||||
clean_kafka
|
||||
|
||||
clean_zookeeper
|
||||
|
||||
clean_influxdb
|
||||
|
||||
}
|
||||
|
||||
function install_zookeeper {
|
||||
@ -220,6 +230,11 @@ function install_influxdb {
|
||||
sudo cp -f /opt/stack/monasca/devstack/files/influxdb/influxdb /etc/default/influxdb
|
||||
|
||||
sudo /etc/init.d/influxdb start
|
||||
|
||||
echo "sleep for 5 seconds to let influxdb elect a leader"
|
||||
|
||||
sleep 5s
|
||||
|
||||
}
|
||||
|
||||
function clean_influxdb {
|
||||
@ -235,18 +250,100 @@ function clean_influxdb {
|
||||
sudo rm -f /opt/monasca_download_dir/influxdb_0.9.1_amd64.deb
|
||||
|
||||
sudo rm -rf /opt/monasca_download_dir
|
||||
|
||||
sudo rm -f /etc/init.d/influxdb
|
||||
}
|
||||
|
||||
function install_cli_creds {
|
||||
|
||||
sudo cp -f /opt/stack/monasca/devstack/files/env.sh /etc/profile.d/monasca_cli.sh
|
||||
|
||||
sudo chown root:root /etc/profile.d/monasca_cli.sh
|
||||
|
||||
sudo chmod 0644 /etc/profile.d/monasca_cli.sh
|
||||
|
||||
}
|
||||
|
||||
function clean_cli_creds {
|
||||
|
||||
sudo rm -f /etc/profile.d/monasca_cli.sh
|
||||
|
||||
}
|
||||
|
||||
function install_schema {
|
||||
|
||||
sudo mkdir -p /opt/monasca/sqls
|
||||
|
||||
sudo chmod 0755 /opt/monasca/sqls
|
||||
|
||||
sudo cp -f /opt/stack/monasca/devstack/files/schema/influxdb_setup.py /opt/influxdb/influxdb_setup.py
|
||||
|
||||
sudo chmod 0750 /opt/influxdb/influxdb_setup.py
|
||||
|
||||
sudo chown root:root /opt/influxdb/influxdb_setup.py
|
||||
|
||||
sudo /opt/influxdb/influxdb_setup.py
|
||||
|
||||
sudo cp -f /opt/stack/monasca/devstack/files/schema/mon_mysql.sql /opt/monasca/sqls/mon.sql
|
||||
|
||||
sudo chmod 0644 /opt/monasca/sqls/mon.sql
|
||||
|
||||
sudo chown root:root /opt/monasca/sqls/mon.sql
|
||||
|
||||
sudo mysql -uroot -ppassword < /opt/monasca/sqls/mon.sql || echo "Did the schema change? This process will fail on schema changes."
|
||||
|
||||
sudo cp -f /opt/stack/monasca/devstack/files/schema/winchester.sql /opt/monasca/sqls/winchester.sql
|
||||
|
||||
sudo chmod 0644 /opt/monasca/sqls/winchester.sql
|
||||
|
||||
sudo chown root:root /opt/monasca/sqls/winchester.sql
|
||||
|
||||
sudo mysql -uroot -ppassword < /opt/monasca/sqls/winchester.sql || echo "Did the schema change? This process will fail on schema changes."
|
||||
|
||||
sudo mkdir -p /opt/kafka/logs
|
||||
|
||||
sudo chown kafka:kafka /opt/kafka/logs
|
||||
|
||||
sudo chmod 0766 /opt/kafka/logs
|
||||
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 64 --topic metrics
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic events
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic raw-events
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic transformed-events
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic stream-definitions
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic transform-definitions
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic alarm-state-transitions
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic alarm-notifications
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 12 --topic stream-notifications
|
||||
/opt/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 3 --topic retry-notifications
|
||||
}
|
||||
|
||||
function clean_schema {
|
||||
|
||||
sudo echo "drop database winchester;" | mysql -uroot -ppassword
|
||||
|
||||
sudo echo "drop database mon;" | mysql -uroot -ppassword
|
||||
|
||||
sudo rm -f /opt/monasca/sqls/winchester.sql
|
||||
|
||||
sudo rm -f /opt/monasca/sqls/mon.sql
|
||||
|
||||
sudo rm -f /opt/influxdb/influxdb_setup.py
|
||||
|
||||
sudo rm -rf /opt/monasca/sqls
|
||||
|
||||
}
|
||||
|
||||
# Allows this script to be called directly outside of
|
||||
# the devstack infrastructure code. Uncomment to use.
|
||||
if [[ $(type -t) != 'function' ]]; then
|
||||
|
||||
function is_service_enabled {
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
fi
|
||||
#if [[ $(type -t) != 'function' ]]; then
|
||||
#
|
||||
# function is_service_enabled {
|
||||
#
|
||||
# return 0;
|
||||
#
|
||||
# }
|
||||
#fi
|
||||
|
||||
# check for service enabled
|
||||
if is_service_enabled monasca; then
|
||||
|
Loading…
Reference in New Issue
Block a user