Started grafana provisioning and corrected template creation by influx start

main
Keegan 2 years ago
parent 56512b3086
commit 429ce92207

@ -23,13 +23,14 @@ services:
volumes: volumes:
- influx-data:/var/lib/influxdb2 - influx-data:/var/lib/influxdb2
- ./influxdb/startup:/docker-entrypoint-initdb.d - ./influxdb/startup:/docker-entrypoint-initdb.d
- server-config:/server-config - server-config:/configs
- grafana-provisioning:/grafana
env_file: env_file:
- ./internal/configs/db.env - ./internal/configs/db.env
environment: environment:
- DOCKER_INFLUXDB_INIT_MODE=setup - DOCKER_INFLUXDB_INIT_MODE=setup
- DOCKER_INFLUXDB_INIT_USERNAME=admin - DOCKER_INFLUXDB_INIT_USERNAME=admin
- DOCKER_INFLUXDB_INIT_PASSWORD=admin - DOCKER_INFLUXDB_INIT_PASSWORD=F0r3l1ght
- DOCKER_INFLUXDB_INIT_ORG=ForeLight - DOCKER_INFLUXDB_INIT_ORG=ForeLight
- DOCKER_INFLUXDB_INIT_BUCKET=default - DOCKER_INFLUXDB_INIT_BUCKET=default
grafana: grafana:
@ -37,8 +38,10 @@ services:
ports: ports:
- "3000:3000" - "3000:3000"
volumes: volumes:
- grafana-provisioning:/etc/grafana/provisioning
- grafana-data:/var/lib/grafana - grafana-data:/var/lib/grafana
volumes: volumes:
grafana-data: grafana-data:
grafana-provisioning:
influx-data: influx-data:
server-config: server-config:

@ -1,16 +1,12 @@
#!/bin/bash #!/bin/bash
TOKEN=$(influx auth list --user ${DOCKER_INFLUXDB_INIT_USER_ID} --hide-headers | cut -f 3) TOKEN=$(influx auth list --user ${DOCKER_INFLUXDB_INIT_USER_ID} --hide-headers | cut -f 3)
ORG=$(influx org list | grep ${DOCKER_INFLUXDB_INIT_ORG_ID} | awk '{print $2}')
# creating starting server YAML
echo -e "server:\n\tdb-url:${INFLUX_HOST}\n\tdb-org:${ORG}\n\tdb-token:${TOKEN}" >/configs/server.yaml;
export db_url=$INFLUX_HOST # creating grafana yaml
export db_org=$DOCKER_INFLUXDB_INIT_ORG_ID influx user create -n grafana -o ${ORG}
export db_token=$TOKEN GRAFANA_USER_ID=$(influx user list --hide-headers --name grafana)
GRAFANA_TOKEN=$(influx auth list --user ${GRAFANA_USER_ID} --hide-headers | cut -f 3)
rm -f temp.yaml echo -e "datasources:\n\t- name: INFLUXDB\n\ttype: influxdb\n\turl:${INFLUX_HOST}\n\tdatabase: test\n\t jsonData:\n\t\thttpMode: GET\n\t\thttpHeaderName1: 'Authorization'\n\tsecureJsonData:\n\t\thttpHeaderValue1: 'Token ${GRAFANA_TOKEN}'"
( echo "cat <<EOF >final.yaml";
cat template.yaml;
echo "EOF";
) >temp.yaml
. temp.yaml
cat final.yaml
mv final.yaml /server-config/server.yaml

Loading…
Cancel
Save