Skip to content

Commit

Permalink
Create Grafana's data source through the API
Browse files Browse the repository at this point in the history
  • Loading branch information
gbts committed Apr 20, 2017
1 parent 4f4a4b1 commit 787beb0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions Dockerfile.grafana
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
FROM grafana/grafana

RUN apt-get update && apt-get -y install sqlite3
RUN apt-get update && apt-get -y install curl

# Change the default data directory (otherwise grafana.db won't persist)
RUN mkdir /var/lib/grafanadb
ENV GF_PATHS_DATA /var/lib/grafanadb
RUN bash -c "/run.sh & sleep 15 && kill -SIGINT %%"

# Init Grafana sqlite db and preconfigure our data source to be our influxdb k6 db
RUN echo "INSERT INTO \"data_source\" VALUES(1,1,0,'influxdb','myinfluxdb','proxy','http://influxdb:8086','','','k6',0,'','',1,X'7B7D','2016-12-29 15:19:32','2016-12-29 15:19:37',0,'{}');" |sqlite3 /var/lib/grafanadb/grafana.db
RUN bash -c '/run.sh & sleep 15 && curl -s -X POST \
--data "name=myinfluxdb&type=influxdb&access=proxy&url=http://influxdb:8086&database=k6&isDefault=true" http://admin:admin@localhost:3000/api/datasources \
&& kill -SIGINT %%'

CMD ["/run.sh"]

CMD ["/run.sh"]
2 changes: 1 addition & 1 deletion Dockerfile.influxdb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ FROM influxdb:1.2.2
# Create a k6 db
RUN /bin/bash -c "influxd run & sleep 5 && influx -execute 'CREATE DATABASE k6' && kill %1 && sleep 5"

CMD ["influxd"]
CMD ["influxd"]

0 comments on commit 787beb0

Please sign in to comment.