Start using grafana from fuel-ccp-grafana

Change-Id: Ic8b059b95c0956a92abfc9fc754071a60c66649e
Depends-on: I89540f8dd656dd930c8b4d999aa195a295592ba4
This commit is contained in:
Bartosz Kupidura 2017-01-10 11:41:31 +01:00
parent 9bc92a39dc
commit 0d1024c807
8 changed files with 29 additions and 57 deletions

View File

@ -1,19 +0,0 @@
FROM {{ image_spec("base-tools") }}
MAINTAINER {{ maintainer }}
# NOTE(elemoine): the Grafana package is downloaded from
# grafanarel.s3.amazonaws.com. Do we want to host the package instead?
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libfontconfig \
&& curl https://grafanarel.s3.amazonaws.com/builds/grafana_{{ grafana_version }}_amd64.deb -o /tmp/grafana.deb \
&& dpkg -i /tmp/grafana.deb \
&& usermod -a -G microservices grafana \
&& rm /tmp/grafana.deb \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY dashboards /dashboards
USER grafana

View File

@ -12,6 +12,7 @@ RUN gpg \
&& gpg --batch --verify /tmp/influxdb.deb.asc /tmp/influxdb.deb \
&& dpkg -i /tmp/influxdb.deb \
&& chown -R influxdb: /etc/influxdb \
&& usermod -a -G microservices influxdb \
&& rm -f /tmp/influxdb.deb.asc /tmp/influxdb.deb
USER influxdb

View File

@ -13,12 +13,6 @@ configs:
service_pattern: "^k8s_(.-)%..*"
hindsight_heka_tcp_port:
cont: 5565
grafana:
host: "grafana"
port:
cont: 3000
user: "admin"
password: "admin"
influxdb:
database: "ccp"
host: "influxdb"
@ -36,7 +30,6 @@ configs:
maxsize: "100M"
versions:
influxdb_version: "0.13.0"
grafana_version: "3.0.3-1463994644"
elasticsearch_version: "2.4.0"
kibana_version: "4.6.1"
elasticsearch_curator_version: "4.1.0"

View File

@ -1,14 +1,16 @@
#!/bin/bash
GRAFANA_URL="http://{{ grafana.user }}:{{ grafana.password }}@{{ address('grafana') }}:{{ grafana.port.cont }}"
echo "Waiting for Grafana to come up..."
until $(curl --fail --output /dev/null --silent http://{{ grafana.user }}:{{ grafana.password }}@localhost:{{ grafana.port.cont }}/api/org); do
until $(curl --fail --output /dev/null --silent ${GRAFANA_URL}/api/org); do
printf "."
sleep 2
done
echo -e "Grafana is up and running.\n"
echo "Creating InfluxDB datasource..."
curl -i -XPOST -H "Accept: application/json" -H "Content-Type: application/json" "http://{{ grafana.user }}:{{ grafana.password }}@localhost:{{ grafana.port.cont }}/api/datasources" -d '
curl -i -XPOST -H "Accept: application/json" -H "Content-Type: application/json" "${GRAFANA_URL}/api/datasources" -d '
{
"name": "CCP InfluxDB",
"type": "influxdb",
@ -26,9 +28,9 @@ fi
echo -e "InfluxDB datasource was successfully created.\n"
echo "Importing default dashboards..."
for dashboard in /dashboards/*.json; do
for dashboard in /tmp/*.dashboard.json; do
echo -e "\tImporting ${dashboard}..."
curl -i -XPOST --data "@${dashboard}" -H "Accept: application/json" -H "Content-Type: application/json" "http://{{ grafana.user }}:{{ grafana.password}}@localhost:{{ grafana.port.cont }}/api/dashboards/db"
curl -i -XPOST --data "@${dashboard}" -H "Accept: application/json" -H "Content-Type: application/json" "${GRAFANA_URL}/api/dashboards/db"
if [ $? -ne 0 ]; then
echo "Error importing ${dashboard}"
exit 1

View File

@ -1,27 +0,0 @@
dsl_version: 0.1.0
service:
name: grafana
ports:
- {{ grafana.port }}
containers:
- name: grafana
image: grafana
daemon:
command: /usr/sbin/grafana-server --homepath=/usr/share/grafana --config=/etc/grafana/grafana.ini
cfg:default.paths.data=/var/lib/grafana
cfg:default.paths.logs=/var/log/grafana
files:
- grafana-configure.sh
post:
- name: grafana-configure
type: local
command: /opt/ccp/bin/grafana-configure.sh
volumes:
- name: grafana-data
type: empty-dir
path: /var/lib/grafana
files:
grafana-configure.sh:
path: /opt/ccp/bin/grafana-configure.sh
content: grafana-configure.sh.j2
perm: "0755"

View File

@ -10,6 +10,18 @@ service:
command: influxd -config /etc/influxdb/influxdb.conf
files:
- influxdb.conf
# {% if grafana.enable == true %}
post:
- name: stacklight-grafana-configure
command: /opt/ccp/bin/grafana-configure.sh
type: single
dependencies:
- grafana
files:
- grafana-configure.sh
- kubernetes-dashboard
- system-dashboard
# {% endif %}
volumes:
- name: influxdb-data
type: empty-dir
@ -19,3 +31,13 @@ files:
path: /etc/influxdb/influxdb.conf
content: influxdb.conf.j2
perm: "0600"
grafana-configure.sh:
path: /opt/ccp/bin/grafana-configure.sh
content: grafana-configure.sh.j2
perm: "0755"
kubernetes-dashboard:
path: /tmp/kubernetes.dashboard.json
content: kubernetes.dashboard.json
system-dashboard:
path: /tmp/system.dashboard.json
content: system.dashboard.json