Commit 63880b54 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Configure grafana data source during bootstrap

parent 7105b227
......@@ -172,7 +172,7 @@ influxdb/meta/meta.db:
influxdb/influxdb.conf:
sed -e "s|/home/git|${gitlab_development_root}|g" $@.example > $@
grafana-setup: grafana/grafana.ini grafana/bin/grafana-server grafana/gdk-pg-created
grafana-setup: grafana/grafana.ini grafana/bin/grafana-server grafana/gdk-pg-created grafana/gdk-data-source-created
grafana/bin/grafana-server:
cd grafana && make
......@@ -186,6 +186,10 @@ grafana/gdk-pg-created:
PATH=${postgres_bin_dir}:${PATH} support/create-grafana-db
touch $@
grafana/gdk-data-source-created:
support/bootstrap-grafana
touch $@
performance-metrics-setup: influxdb-setup grafana-setup Procfile
printf ',s/^#influxdb/influxdb/\nwq\n' | ed -s Procfile
printf ',s/^#grafana/grafana/\nwq\n' | ed -s Procfile
......
......@@ -28,6 +28,10 @@ app() {
foreman_start -c all=0,rails-web=1,rails-background-jobs=1,gitlab-workhorse=1,workhorse-stunnel=1,grafana=1
}
grafana() {
foreman_start -c all=0,grafana=1
}
all() {
print_port
foreman_start
......@@ -40,6 +44,9 @@ xdb)
xapp)
app
;;
xgrafana)
grafana
;;
x*)
all
;;
......
#!/usr/bin/env ruby
require 'socket'
require 'net/http'
if !ARGV.empty?
abort "Usage: #$0"
end
host = '127.0.0.1'
port = '9999'
begin
db_pid = spawn('./run', 'db')
grafana_pid = spawn('./run', 'grafana')
socket_ready = false
30.times do
begin
TCPSocket.new(host, port)
socket_ready = true
break
rescue Errno::ECONNREFUSED
sleep 1
end
end
abort "#$0: could not connect to InfluxDB at #{host}:#{port}" unless socket_ready
http = Net::HTTP.new(host, port)
request = Net::HTTP::Post.new('/api/datasources')
request.basic_auth('admin', 'admin')
request.add_field('Content-Type', 'application/json')
request.body = <<EOS
{
"name": "InfluxDB",
"type": "influxdb",
"url": "http://localhost:8086",
"access": "direct",
"database": "gitlab",
"isDefault": true
}
EOS
puts http.request(request).body
ensure
Process.kill('TERM', db_pid)
Process.kill('TERM', grafana_pid)
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment