diff options
author | Loïc Hoguin <[email protected]> | 2018-04-20 12:15:43 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2018-04-20 12:15:43 +0200 |
commit | 281b412eea700902562615ce0be693fe087e1f14 (patch) | |
tree | b34af6282a422c9e9f17964d5101860d2b6c0bb8 | |
parent | 9fb9738884c0bbd21716a587ef2fc51b6ef9d5d4 (diff) | |
download | ci-281b412eea700902562615ce0be693fe087e1f14.tar.gz ci-281b412eea700902562615ce0be693fe087e1f14.tar.bz2 ci-281b412eea700902562615ce0be693fe087e1f14.zip |
Add the prometheus/grafana container script
It only creates an environment looking at Grafana and
Prometheus themselves. More will be added as load testing
environments get created.
-rw-r--r-- | priv/grafana_prometheus_data_source.json | 11 | ||||
-rwxr-xr-x | prometheus.sh | 50 |
2 files changed, 61 insertions, 0 deletions
diff --git a/priv/grafana_prometheus_data_source.json b/priv/grafana_prometheus_data_source.json new file mode 100644 index 0000000..3811d8b --- /dev/null +++ b/priv/grafana_prometheus_data_source.json @@ -0,0 +1,11 @@ +{ + "name": "Prometheus", + "type": "prometheus", + "access": "proxy", + "url": "http://localhost:9090", + "basicAuth": false, + "isDefault": true, + "jsonData": {"timeInterval": "5s"}, + "version": 2, + "readOnly": false +} diff --git a/prometheus.sh b/prometheus.sh new file mode 100755 index 0000000..31f3d91 --- /dev/null +++ b/prometheus.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env sh + +set -e +#set -x + +NAME=$1 +DIST=archlinux +RELEASE=current +ARCH=amd64 +PACKAGES="git sudo base-devel grafana" + +for f in ci.d/*; do source "$f"; done + +lxc_destroy +lxc_create $DIST $RELEASE $ARCH +lxc_wait_for_ip +pacman_upgrade +pacman_install $PACKAGES + +echo "[auth.anonymous]" >> /etc/grafana.ini +echo "enabled = true" >> /etc/grafana.ini +echo "org_role = Admin" >> /etc/grafana.ini + +lxc_do git clone https://aur.archlinux.org/prometheus-bin.git /tmp/prometheus-bin +lxc_do chown -R nobody:nobody /tmp/prometheus-bin +lxc_do sudo -u nobody bash -c 'cd /tmp/prometheus-bin && makepkg' +lxc_do bash -c 'pacman --noconfirm -U /tmp/prometheus-bin/prometheus-bin*.pkg.tar.xz' + +lxc_do bash -c "printf \"%s\n\" \ + \"\" \ + \" - job_name: 'grafana'\" \ + \"\" \ + \" static_configs:\" \ + \" - targets: ['localhost:3000']\" >> /etc/prometheus/prometheus.yml" + +lxc_do systemctl enable grafana +lxc_do systemctl enable prometheus + +lxc_restart + +until lxc_do curl http://admin:admin@localhost:3000/api/org +do + sleep 1 +done + +echo +<$( cd "$( dirname "$0" )" && pwd )/priv/grafana_prometheus_data_source.json \ + lxc_do curl -H "content-type: application/json" --data-binary @- \ + http://admin:admin@localhost:3000/api/datasources +echo |