Skip to content

Support Influx V2 on Docker#68

Open
AarC10 wants to merge 3 commits into
mainfrom
feature/Aaron/InfluxV2Docker
Open

Support Influx V2 on Docker#68
AarC10 wants to merge 3 commits into
mainfrom
feature/Aaron/InfluxV2Docker

Conversation

@AarC10
Copy link
Copy Markdown
Member

@AarC10 AarC10 commented Apr 3, 2026

Description

Adds support for InfluxV2 on Docker

How Has This Been Tested?

Ran the docker compose and ran some queries on Influx through docker

Checklist:

  • New functionality is documented in the necessary spots (i.e new functions documented in the header)
  • Unit tests cover any new functionality or edge cases that the PR was meant to resolve (if applicable)
  • The CI checks are passing
  • I reviewed my own code in the GitHub diff and am sure that each change is intentional

@AarC10 AarC10 requested review from a team and Copilot April 3, 2026 15:31
@AarC10 AarC10 linked an issue Apr 3, 2026 that may be closed by this pull request
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Docker Compose support for running the stack against InfluxDB v2 (2.7) while preserving InfluxQL/Grafana compatibility via DBRP (v1 compatibility) mapping.

Changes:

  • Switch Docker Compose InfluxDB service to InfluxDB v2.7 with setup env + healthchecks, and add an init job to create v1 DBRP mappings.
  • Update Grafana provisioning to use InfluxQL against InfluxDB v2 via Authorization token header.
  • Improve gsw_service DB config resolution to correctly detect v2 config from environment variables; add unit tests and refresh documentation/examples.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
README.md Updates InfluxDB CLI usage examples for InfluxDB v2 (bucket list + Flux query).
data/influxdb/init-v1-compat.sh New init script to create InfluxDB v1 DBRP mapping for InfluxQL compatibility.
data/grafana/provisioning/datasources/gsw-influxdb-provider.yaml Switch Grafana datasource config to InfluxQL-over-v2 using an Authorization token header.
data/config/gsw_service.yaml.example Updates example v2 DB config defaults (URL/token/org/bucket).
compose.yaml Updates gsw service env to use InfluxDB v2 connection settings; depends on healthy InfluxDB.
compose-services.yaml Switches InfluxDB container to v2.7 setup mode, adds healthcheck and an init sidecar for DBRP mapping; updates Grafana env wiring.
cmd/gsw_service.go Makes v2 config detection robust for env-var based configuration.
cmd/gsw_service_test.go Adds tests ensuring v2 config is selected from env vars and preferred over v1 when both are present.
cmd/Containerfile Switches container default DB env vars from v1 UDP to v2 HTTP config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/Containerfile
ENV GSW_DATABASE_HOST_NAME=influxdb
ENV GSW_DATABASE_PORT_NUMBER=8089
ENV GSW_DATABASE_V2_URL=http://influxdb:8086
ENV GSW_DATABASE_V2_TOKEN=gsw-local-dev-token
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

The Containerfile bakes a fixed InfluxDB admin token into the image layer via ENV GSW_DATABASE_V2_TOKEN=.... This is effectively a hardcoded credential and can be unintentionally reused outside local dev (and is retrievable from the built image metadata/history). Prefer leaving the token unset in the image and requiring it to be provided at runtime (e.g., via docker run -e ... / compose env), or set a placeholder value that forces explicit override.

Suggested change
ENV GSW_DATABASE_V2_TOKEN=gsw-local-dev-token
ENV GSW_DATABASE_V2_TOKEN=CHANGE_ME_AT_RUNTIME

Copilot uses AI. Check for mistakes.
database_v2:
url: http://localhost:8086
token: your-token-here
token: gsw-local-dev-token
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

This example config now includes a concrete token value (gsw-local-dev-token). Even in example files, committing an actual token encourages copying it into real deployments and makes it easy to end up with shared credentials. Consider using a clear placeholder (e.g. your-token-here) and/or referencing the GSW_INFLUXDB_ADMIN_TOKEN/GSW_DATABASE_V2_TOKEN environment variable so users are nudged to set their own.

Suggested change
token: gsw-local-dev-token
token: your-token-here

Copilot uses AI. Check for mistakes.
Comment thread README.md
Comment on lines +65 to +69
To query the `gsw` bucket directly, run:
```shell
docker compose exec influxdb influx query \
--org gsw \
--token gsw-local-dev-token \
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

The README hardcodes --token gsw-local-dev-token in the query example. If someone overrides the admin token via compose env (which the compose files support), this command will fail and can be confusing. Consider updating the docs to reference the configured env var (e.g. $GSW_INFLUXDB_ADMIN_TOKEN) or instructing how to retrieve the token used by the current compose setup.

Suggested change
To query the `gsw` bucket directly, run:
```shell
docker compose exec influxdb influx query \
--org gsw \
--token gsw-local-dev-token \
To query the `gsw` bucket directly, use the admin token configured for your current compose setup (for example, `$GSW_INFLUXDB_ADMIN_TOKEN` if you exported that environment variable before starting the containers):
```shell
docker compose exec influxdb influx query \
--org gsw \
--token "$GSW_INFLUXDB_ADMIN_TOKEN" \

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hardcoded token is probably fine in the docs

--org "${org}" \
--token "${token}" \
--db "${database}" \
--hide-headers | grep -Eq "[[:space:]]${retention_policy}([[:space:]]|$)"; then
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

retention_policy is interpolated directly into an extended regex passed to grep -E. If the value contains regex metacharacters, the check can produce false positives/negatives (or even fail to compile). Consider avoiding regex here (e.g., parse columns with awk and compare exact fields, or use fixed-string matching) so the existence check is reliable for any retention policy name.

Suggested change
--hide-headers | grep -Eq "[[:space:]]${retention_policy}([[:space:]]|$)"; then
--hide-headers | awk -v database="${database}" -v retention_policy="${retention_policy}" '
$2 == database && $3 == retention_policy { found = 1; exit }
END { exit found ? 0 : 1 }
'; then

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

@AarC10 AarC10 Apr 3, 2026

Choose a reason for hiding this comment

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

Note this file should be blasted once we blast influx v1 from existence. This is just a bandaid to maintain compatibility with the current Grafana dashboards (technically can blast when that happens actually)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

honestly wouldn't hurt to have this in general

Copy link
Copy Markdown
Contributor

@K3das K3das left a comment

Choose a reason for hiding this comment

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

lgtm- just some slightly subjective changes.

Comment thread compose-services.yaml
- grafana-data:/var/lib/grafana
influxdb:
image: influxdb:1.11-alpine
image: influxdb:2.7-alpine
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2.8-alpine is latest, could probably be bumped unless there are breaking changes in 2.8.

Comment thread README.md
Comment on lines +65 to +69
To query the `gsw` bucket directly, run:
```shell
docker compose exec influxdb influx query \
--org gsw \
--token gsw-local-dev-token \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hardcoded token is probably fine in the docs

Comment thread README.md
docker compose exec influxdb influx query \
--org gsw \
--token gsw-local-dev-token \
'from(bucket: "gsw") |> range(start: -15m)'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this could potentially be changed to start: 0 to maintain compatibility with previous docs but it's like no big deal

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

honestly wouldn't hurt to have this in general

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could this be moved to an init script in the influx container? Would make it a lot simpler on the docker-compose and config side of things.

https://docs.influxdata.com/influxdb/v2/install/use-docker-compose/#:~:text=Runs%20any%20custom%20initialization%20scripts%20mounted%20inside%20the%20container%E2%80%99s%20/docker%2Dentrypoint%2Dinitdb.d/%20path.

Comment thread cmd/Containerfile
Comment on lines -46 to +49
ENV GSW_DATABASE_HOST_NAME=influxdb
ENV GSW_DATABASE_PORT_NUMBER=8089
ENV GSW_DATABASE_V2_URL=http://influxdb:8086
ENV GSW_DATABASE_V2_TOKEN=gsw-local-dev-token
ENV GSW_DATABASE_V2_ORG=gsw
ENV GSW_DATABASE_V2_BUCKET=gsw
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe I had the database environment variables in the Dockerfile so that the GSW container could start without a database config, but that was patched previously so now I think all of the database config could be left out of the Dockerfile.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docker support for influx v2

3 participants