Added info for setting up InfluxDB

pull/7/head
Ben Rometsch 4 years ago
parent 0d23e8c434
commit 4f66c073e3

@ -48,6 +48,39 @@ docker-compose run --rm --entrypoint ".venv/bin/python src/manage.py createsuper
You can then access the admin dashboard at [http://localhost:8000/admin/](http://localhost:8000/admin/)
## InfluxDB
Flagsmith has a soft dependency on InfluxDB to store time-series data. You dont need to configure Influx to run the platform, but SDK traffic and flag analytics will not work without it being set up and configured correctly. Once your docker-compose is running:
1. Create a user account in influxdb. You can visit http://localhost:8086/ and do this. Create an Initial Bucket with the name `flagsmith_api`
2. Go into Data > Buckets and create a second bucket, `flagsmith_api_downsampled_15m`.
3. Go into Data > Tokens and grab your access token.
4. Edit the `docker-compose.yml` file and add the following `environment` variables in the api service to connect the api to InfluxDB:
* `INFLUXDB_TOKEN`: The token from the step above
* `INFLUXDB_URL`: `http://influxdb`
* `INFLUXDB_ORG`: The organisation ID - you can find it [here](https://docs.influxdata.com/influxdb/v2.0/organizations/view-orgs/)
* `INFLUXDB_BUCKET`: `flagsmith_api`
5. Restart `docker-compose`
6. Log into InfluxDB, create a new bucket called `flagsmith_api_downsampled_15m`
7. Create a new task with the following query. This will downsample your per millisecond data down to 15 minute blocks for faster queries. Set it to run every 15 minutes.
```
option task = {name: "Downsample", every: 15m}
data = from(bucket: "flagsmith_api")
|> range(start: -duration(v: int(v: task.every) * 2))
|> filter(fn: (r) =>
(r._measurement == "api_call"))
data
|> aggregateWindow(fn: sum, every: 15m)
|> filter(fn: (r) =>
(exists r._value))
|> to(bucket: "flagsmith_api_downsampled_15m")
```
Once this task has run you will see data coming into the Organisation API Usage area.
## Architecture
The docker-compose file runs the following containers:

@ -1,31 +1,46 @@
version: "3"
services:
db:
image: postgres:10.6-alpine
environment:
POSTGRES_PASSWORD: password
POSTGRES_DB: flagsmith
container_name: flagsmith_postgres
api:
image: flagsmith/flagsmith-api:latest
environment:
DJANGO_ALLOWED_HOSTS: "*" # Change this in production
DATABASE_URL: postgresql://postgres:password@db:5432/flagsmith
INFLUXDB_URL: http://influxdb:8086
INFLUXDB_BUCKET: flagsmith_api
INFLUXDB_ORG: # Add your influx org id here - see readme.md
INFLUXDB_TOKEN: # Add your influx token here - see readme.md
ports:
- "8000:8000"
depends_on:
- db
links:
- db:db
- influxdb:influxdb
container_name: flagsmith_api
frontend:
image: flagsmith/flagsmith-frontend:latest
environment:
# You might need to change the 2 host names below depending on your docker dns setup
API_URL: http://localhost:8000/api/v1/
ASSET_URL: http://locahost:8080/
ASSET_URL: http://localhost:8080/
ports:
- "8080:8080"
links:
- api:api
container_name: flagsmith_frontend
db:
image: postgres:10.6-alpine
environment:
POSTGRES_PASSWORD: password
POSTGRES_DB: flagsmith
container_name: flagsmith_postgres
influxdb:
image: quay.io/influxdb/influxdb:v2.0.3
container_name: flagsmith_influxdb
ports:
- "8086:8086"
Loading…
Cancel
Save