Skip to content

Instantly share code, notes, and snippets.

@cy4n
Created October 11, 2018 19:27
Show Gist options
  • Save cy4n/4ae69918230415e293115d00c738491d to your computer and use it in GitHub Desktop.
Save cy4n/4ae69918230415e293115d00c738491d to your computer and use it in GitHub Desktop.
docker-compose file to setup local influxdb and grafana for TESTING purposes
version: "3.2"
services:
grafana:
image: "grafana/grafana:latest"
container_name: grafana
ports:
- "3000:3000"
volumes:
- grafana_var_lib:/var/lib/grafana
environment:
- GF_INSTALL_PLUGINS=grafana-piechart-panel
- GF_SECURITY_ADMIN_PASSWORD=secret
restart: always
links:
- influxdb
influxdb:
container_name: influx
image: "influxdb:1.5-alpine"
ports:
- "8086:8086"
volumes:
- influxdb_var_lib:/var/lib/influxdb
environment:
- INFLUXDB_HTTP_AUTH_ENABLED=true
- INFLUXDB_DB=foo
- INFLUXDB_ADMIN_USER=admin
- INFLUXDB_ADMIN_PASSWORD=admin
- INFLUXDB_WRITE_USER=foo-write
- INFLUXDB_WRITE_USER_PASSWORD=foo-write
- INFLUXDB_READ_USER=foo-read
- INFLUXDB_READ_USER_PASSWORD=foo-read
restart: always
volumes:
grafana_var_lib:
influxdb_var_lib:
@cy4n
Copy link
Author

cy4n commented Oct 11, 2018

run both with docker-compose up -d

run this curl to create a datasource in grafana that uses the foo database from influx

curl -X POST -u admin \
  -H "Content-Type: application/json" \
  --data @- http://localhost:3000/api/datasources <<-JSON
{
  "name": "foo-local",
  "type": "influxdb",
  "access": "proxy",
  "url": "http://influxdb:8086",
  "password": "foo-read",
  "user": "foo-read",
  "database": "foo",
  "basicAuth": false
}
JSON

@cy4n
Copy link
Author

cy4n commented Oct 11, 2018

then login to grafana at http://localhost:3000 with admin/secret and start making dashboards

point telegraf or collectd or micrometer (or however you push metrics) to localhost:8086 with user foo-write pass foo-write to start gathering

@cy4n
Copy link
Author

cy4n commented Oct 11, 2018

dont use in prod;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment