Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added influxDB 2.x compatibility #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
INFLUXDB_USERNAME=admin
INFLUXDB_PASSWORD=admin

GRAFANA_USERNAME=admin
GRAFANA_PASSWORD=admin
INFLUXDB_USERNAME=admin
INFLUXDB_PASSWORD=secure_influx_adm_password
INFLUXDB_ORG=my_org
INFLUXDB_BUCKET=default_bucket
INFLUXDB_ADMIN_TOKEN=a_secure_admin_token
V1_DB_NAME=db0
V1_RP_NAME=v1-rp
V1_AUTH_USERNAME=v1_admin
V1_AUTH_PASSWORD=v1_secure_password

GRAFANA_USERNAME=root
GRAFANA_PASSWORD=root
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Multi-container Docker app built from the following services:

Useful for quickly setting up a monitoring stack for performance testing. Combine with [serverless-artillery](https://github.com/Nordstrom/serverless-artillery) and [artillery-plugin-influxdb](https://github.com/Nordstrom/artillery-plugin-influxdb) to create a performance testing environment in minutes.

Now with built-in support for influxDB 2.x

## Quick Start

To start the app:
Expand Down Expand Up @@ -68,10 +70,14 @@ The app creates a default InfluxDB database called `db0`.

## Data Sources

The app creates a Grafana data source called `InfluxDB` that's connected to the default IndfluxDB database (e.g. `db0`).
The app creates two Grafana data sources called `InfluxDB(GraphQL)` (with legacy authentication) and `InfluxDB(Flux)` which are connected to the default IndfluxDB database.

To provision additional data sources, see the Grafana [documentation](http://docs.grafana.org/administration/provisioning/#datasources) and add a config file to `./grafana-provisioning/datasources/` before starting the app.

## InfluxDB scripts

Scripts located in `influxDB-scripts` are excuted after the inital setup task of influxDB. At the moment, the script `setup-v1.sh` takes care of the `dbrp` mappings and the creation of v1 compatible users.

## Dashboards

By default, the app does not create any Grafana dashboards. An example dashboard that's configured to work with [artillery-plugin-influxdb](https://github.com/Nordstrom/artillery-plugin-influxdb) is located at `./grafana-provisioning/dashboards/artillery.json.example`. To use this dashboard, rename it to `artillery.json`.
Expand Down
22 changes: 18 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ services:
- '8086:8086'
volumes:
- influxdb-storage:/var/lib/influxdb

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- influxdb-storage:/var/lib/influxdb
- influxdb-storage:/var/lib/influxdb2

https://hub.docker.com/_/influxdb

- ./influxDB-scripts:/docker-entrypoint-initdb.d
environment:
- INFLUXDB_DB=db0
- INFLUXDB_ADMIN_USER=${INFLUXDB_USERNAME}
- INFLUXDB_ADMIN_PASSWORD=${INFLUXDB_PASSWORD}
- DOCKER_INFLUXDB_INIT_MODE=setup
- DOCKER_INFLUXDB_INIT_USERNAME=${INFLUXDB_USERNAME}
- DOCKER_INFLUXDB_INIT_PASSWORD=${INFLUXDB_PASSWORD}
- DOCKER_INFLUXDB_INIT_ORG=${INFLUXDB_ORG}
- DOCKER_INFLUXDB_INIT_BUCKET=${INFLUXDB_BUCKET}
- DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=${INFLUXDB_ADMIN_TOKEN}
- V1_DB_NAME=${V1_DB_NAME}
- V1_RP_NAME=${V1_RP_NAME}
- V1_AUTH_USERNAME=${V1_AUTH_USERNAME}
- V1_AUTH_PASSWORD=${V1_AUTH_PASSWORD}
chronograf:
image: chronograf:latest
ports:
Expand All @@ -28,12 +36,18 @@ services:
- '3000:3000'
volumes:
- grafana-storage:/var/lib/grafana
- ./grafana-provisioning/:/etc/grafana/provisioning
- ./grafana-provisioning/:/etc/grafana/provisioning/
depends_on:
- influxdb
environment:
- GF_SECURITY_ADMIN_USER=${GRAFANA_USERNAME}
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD}
- V1_DB_NAME=${V1_DB_NAME}
- V1_AUTH_USERNAME=${V1_AUTH_USERNAME}
- V1_AUTH_PASSWORD=${V1_AUTH_PASSWORD}
- DOCKER_INFLUXDB_INIT_ORG=${INFLUXDB_ORG}
- DOCKER_INFLUXDB_INIT_BUCKET=${INFLUXDB_BUCKET}
- DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=${INFLUXDB_ADMIN_TOKEN}
volumes:
influxdb-storage:
chronograf-storage:
Expand Down
22 changes: 18 additions & 4 deletions grafana-provisioning/datasources/datasource.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
apiVersion: 1
datasources:
- name: InfluxDB
- name: InfluxDB(GraphQL)
type: influxdb
access: proxy
database: db0
user: admin
password: admin
database: $V1_DB_NAME
user: $V1_AUTH_USERNAME
secureJsonData:
password: $V1_AUTH_PASSWORD
url: http://influxdb:8086
isDefault: true
editable: true

- name: InfluxDB(Flux)
version: 2
type: influxdb
access: proxy
url: http://influxdb:8086
jsonData:
defaultBucket: $DOCKER_INFLUXDB_INIT_BUCKET
httpMode: POST
organization: $DOCKER_INFLUXDB_INIT_ORG
version: Flux
secureJsonData:
token: $DOCKER_INFLUXDB_INIT_ADMIN_TOKEN
19 changes: 19 additions & 0 deletions influxDB-scripts/setup-v1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -e

BUCKET_ID=`influx bucket list --name $DOCKER_INFLUXDB_INIT_BUCKET | tail -1 | head -c 16`

influx v1 dbrp create \
--bucket-id ${BUCKET_ID} \
--db ${V1_DB_NAME} \
--rp ${V1_RP_NAME} \
--default \
--org ${DOCKER_INFLUXDB_INIT_ORG}


influx v1 auth create \
--username ${V1_AUTH_USERNAME} \
--password ${V1_AUTH_PASSWORD} \
--write-bucket ${BUCKET_ID} \
--read-bucket ${BUCKET_ID} \
--org ${DOCKER_INFLUXDB_INIT_ORG}