A small Java service that periodically queries InfluxDB metrics, asks Google Gemini to produce a short human‑friendly summary (2–4 sentences), and writes that summary back to InfluxDB for display on dashboards.
- Pulls metrics from InfluxDB with configurable measurement/field filters
- Aggregates over a fixed time window (mean/min/max/last)
- Sends a compact JSON payload to Gemini with optional system instruction
- Writes the generated summary to an output measurement in the same bucket
- Can run once (batch mode) or on a fixed schedule
- Java 21+ (the Docker image uses Temurin 21 JRE but the app targets 17)
- InfluxDB 2.x with an API token and bucket/org
- Google Generative Language (Gemini) API key
- Gradle (wrapper included)
Configuration (Environment Variables) The application reads configuration from environment variables at startup.
INFLUX_URL: URL of InfluxDB (e.g., http://localhost:8086)INFLUX_TOKEN: InfluxDB API token with read/write access to the bucketINFLUX_ORG: InfluxDB organization name/IDINFLUX_BUCKET: InfluxDB bucket nameGOOGLE_API_KEY: Google Gemini API key
INFLUX_MEASUREMENT_REGEX: Regex for measurements to include (default: .*)INFLUX_FIELD_REGEX: Regex for fields to include (default: unset = all fields)GOOGLE_MODEL: Gemini model (default: gemini-2.5-flash)OUTPUT_MEASUREMENT: Measurement to write summaries to (default: dashboard_summary)INTERVAL_MINUTES: Window size and schedule period in minutes (default: 15)TIMEZONE: IANA timezone for scheduling (default: system timezone)RUN_ONCE: If true, runs a single cycle and exits (default: false)SYSTEM_INSTRUCTION: System prompt sent to Gemini (default: "You are a concise observability assistant.")
export INFLUX_URL="http://localhost:8086"
export INFLUX_TOKEN="<your-token>"
export INFLUX_ORG="<your-org>"
export INFLUX_BUCKET="<your-bucket>"
export GOOGLE_API_KEY="<your-gemini-api-key>"
export INFLUX_MEASUREMENT_REGEX="^telemetry_.*$"
export INFLUX_FIELD_REGEX="^(temperature|humidity)$"
export INTERVAL_MINUTES=15
export RUN_ONCE=false
./gradlew run
To build a distribution you can run:
./gradlew installDist
./build/install/DashboardSummary/bin/DashboardSummary
Set RUN_ONCE=true to execute a single summary cycle and exit.
RUN_ONCE=true ./gradlew run
RUN_ONCE=true ./build/install/DashboardSummary/bin/DashboardSummary
Build the image (multi-stage Dockerfile provided):
docker build -t dashboard-summary:latest .
Run the container (pass env variables):
docker run --rm \
-e INFLUX_URL=http://influxdb:8086 \
-e INFLUX_TOKEN=YOUR_TOKEN \
-e INFLUX_ORG=YOUR_ORG \
-e INFLUX_BUCKET=YOUR_BUCKET \
-e GOOGLE_API_KEY=YOUR_GEMINI_KEY \
-e INFLUX_MEASUREMENT_REGEX=".*" \
-e INTERVAL_MINUTES=15 \
-e OUTPUT_MEASUREMENT=dashboard_summary \
--name dashboard-summary dashboard-summary:latest
- For the last
INTERVAL_MINUTES, the app queries InfluxDB for each matching measurement/field and computes mean, min, max, and last values. - It composes a compact JSON payload with these stats and asks Gemini to write a short summary.
- The summary is written back to InfluxDB in
OUTPUT_MEASUREMENTwith fields: text (string) and interval_minutes (int), and tag: model.
- Ensure the Influx token has read permission for source measurement(s) and write permission for
OUTPUT_MEASUREMENTin the target bucket. TIMEZONEonly affects when periodic runs are scheduled; the data range is relative to "now" per InfluxDB.- If you need stricter control over prompting, set
SYSTEM_INSTRUCTIONto guide the model’s tone and focus.
- Missing configuration: the app logs a clear list of missing variables and exits with code 1.
- Gemini API errors: you will see the HTTP status and body in logs; verify
GOOGLE_API_KEYand model. - Influx query failures: the app logs a warning per failed query and continues with available data.
- Build and test: ./gradlew build
- Code entry point: com.pathvariable.smartgarden.summary.Main
- Key classes: Config, GeminiClient, SummaryJob, TimeUtil, MetricKey