Added shard config to database creation
Change-Id: I966a1712a0f26eb0324426aa842832267590892b
This commit is contained in:
parent
0968f094a2
commit
2f97d0e925
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"spaces": [
|
||||
{
|
||||
"name": "everything",
|
||||
"retentionPolicy": "7d",
|
||||
"shardDuration": "1d",
|
||||
"regex": "/.*/",
|
||||
"replicationFactor": 3,
|
||||
"split": 1
|
||||
},
|
||||
{
|
||||
"name": "grouped",
|
||||
"retentionPolicy": "inf",
|
||||
"shardDuration": "1d",
|
||||
"regex": "/^grouped.*/",
|
||||
"replicationFactor": 3,
|
||||
"split": 1
|
||||
}
|
||||
],
|
||||
"continuousQueries": [
|
||||
"select mean(value), mode(value), max(value) from /^(?:$|[^g]|g(?:$|[^r]|r(?:$|[^o]|o(?:$|[^u]|u(?:$|[^p]|p(?:$|[^e]|e(?:$|[^d]))))))).*/ group by time(1h) into grouped.:series_name",
|
||||
"select sum(value) from /^net.bytes_(in|out)/ group by time(1h) into grouped.:series_name"
|
||||
]
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
#
|
||||
# Class for bootstrapping influxdb for monasca
|
||||
#
|
||||
class monasca::influxdb::bootstrap
|
||||
class monasca::influxdb::bootstrap(
|
||||
$influxdb_shard_config_source = 'puppet:///modules/monasca/shard_config.json'
|
||||
)
|
||||
{
|
||||
#
|
||||
# TODO: pull these from hiera (encrypt pwds)
|
||||
|
@ -12,6 +14,7 @@ class monasca::influxdb::bootstrap
|
|||
$influxdb_user = 'root'
|
||||
$influxdb_password = 'root'
|
||||
$influxdb_dbuser_password = 'password'
|
||||
$influxdb_shard_config = '/tmp/config.json'
|
||||
|
||||
ensure_packages('python-pip')
|
||||
|
||||
|
@ -29,6 +32,14 @@ class monasca::influxdb::bootstrap
|
|||
group => 'root',
|
||||
}
|
||||
|
||||
file { "/tmp/${influxdb_shard_config}":
|
||||
ensure => file,
|
||||
source => $influxdb_shard_config_source,
|
||||
mode => '0755',
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
}
|
||||
|
||||
Package['influxdb'] ->
|
||||
exec { "/tmp/${script}":
|
||||
subscribe => File["/tmp/${script}"],
|
||||
|
@ -37,6 +48,6 @@ class monasca::influxdb::bootstrap
|
|||
user => 'root',
|
||||
group => 'root',
|
||||
refreshonly => true,
|
||||
require => Service['influxdb'],
|
||||
require => [Service['influxdb'], File["/tmp/${influxdb_shard_config}"]],
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import argparse
|
||||
import subprocess
|
||||
import time
|
||||
import urllib2
|
||||
from influxdb import InfluxDBClient
|
||||
|
||||
def main():
|
||||
|
@ -24,7 +25,7 @@ def main():
|
|||
print("Database %s already exists, not adding." % dbname)
|
||||
else:
|
||||
print("Adding %s database." % dbname)
|
||||
client.create_database(dbname)
|
||||
create_database(host, port, dbname, user, password)
|
||||
|
||||
for monuser in monusers:
|
||||
add_user(client, monuser, dbuser_password)
|
||||
|
@ -68,6 +69,15 @@ def wait_for_influx():
|
|||
print("Influxdb didn't come up after waiting 60 seconds.")
|
||||
exit(1)
|
||||
|
||||
def create_database(host, port, dbname, user, password):
|
||||
urlparts = ['http://',host,':',str(port),'/cluster/database_configs/',dbname,'?u=',user,'&p=',password]
|
||||
url = "".join(urlparts)
|
||||
data = open('<%= influxdb_shard_config %>','rb').read()
|
||||
result = urllib2.urlopen(url, data)
|
||||
if result.msg != 'Created':
|
||||
print("Database creation failed.")
|
||||
exit(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
wait_for_influx()
|
||||
main()
|
||||
|
|
Loading…
Reference in New Issue