IMD SolutionComputing LibraryShop main store

Troubleshooting

OpenEMS InfluxDB password versus API token in Docker

Edge computing and IIoT Published 8 min read

Short answer

The password in the documented influx setup command initializes InfluxDB's first user account; it is not what OpenEMS sends. On a v2 server such as the reported v2.7.12 container, OpenEMS authorizes with an API token in the Timedata.InfluxDB ApiKey field, so you choose your own secret password at setup and enter the token, not the password, in the connector.

On this page
  1. Why does the OpenEMS Docker setup ask for an InfluxDB password?
  2. Should I replace the example password with a secret one?
  3. Is my container running InfluxDB v1 or v2?
  4. Where does the OpenEMS token come from, and where does it go?
  5. Why is my component green but the UI shows "Error retrieving the data. Please try again later."?
  6. Does the token have permission to write and read the bucket?
  7. How do I change the InfluxDB password later without breaking OpenEMS?
  8. Questions asked

The password in the OpenEMS Docker documentation's InfluxDB setup command is easy to misread as a credential the application will later send to the database. It is not. That flag initializes InfluxDB's first user account; the OpenEMS backend authorizes against a v2 server with an API token entered in the connector's ApiKey field. Choose your own secret password when you run setup, note the token the setup prints, and put only the token in the connector. This article walks the checks that decide which credential your deployment uses, why a green component can still end with a history error in the UI, and what changes when the container reports InfluxDB v1.8 instead of v2.

Why does the OpenEMS Docker setup ask for an InfluxDB password? #

The --password flag on the documented influx setup command creates the database's first user account, so it authenticates a database user, while OpenEMS itself authorizes its reads and writes with an InfluxDB v2 API token set in the connector's ApiKey field. The vendor's Docker backend guide initializes the whole stack with one command:

docker exec openems_influxdb influx setup \
  --username openems \
  --password WKeuIhl0deIJjrjoY62M \
  --org openems.io \
  --bucket openems \
  --force

That single run creates four things: the initial user openems with the listed password, the organization openems.io, the bucket openems, and an API token that the same guide tells you to note down. The --org and --bucket flags themselves mark a v2 initialization, because a v1 server organizes data as databases and retention policies and has neither organizations nor buckets.

Setup artifact What it does Who uses it afterwards
Account password Opens the initial user account on the database Humans and CLI sessions logging in to InfluxDB, never the OpenEMS application
API token Authorizes API operations on the permitted resources OpenEMS, pasted whole into the ApiKey field
Organization and bucket Name where the time series lives The OpenEMS component must carry the same two values
Username:password pair Authenticates requests on a v1 server The ApiKey field only when the server reports v1

A common misreading says the password is only needed for v1. That mixes two layers: a v2 server still requires a password to bootstrap its first account, and the v2 application ignores that same password once its token takes over. The decision is simply which layer a given string belongs to.

Should I replace the example password with a secret one? #

Yes: the password printed in the vendor's Docker guide is public documentation, so treat it as known to anyone who can reach the port, choose your own secret when you run setup, and expect no other OpenEMS configuration field to need the account password on v2.

The setup command is where you choose it. Any password you like works there, because the flag creates the account rather than retrieving a fixed one — the guide's value is a sample, nothing more. Nothing else in the Compose files or the OpenEMS configuration references the account password, which is why a search through a deployed stack finds no second mention of it: the application path is token-based from end to end. Keep the finished password and the setup token out of committed Compose files, screenshots and pasted terminal output, because both are live credentials on a plant network. The decision is one edit, made once, at setup time.

Is my container running InfluxDB v1 or v2? #

Ask the endpoint OpenEMS actually uses, not the Compose file: a request to the /ping endpoint answers with an X-Influxdb-Version header, and a v2.x.y value such as the reported v2.7.12 means token authentication, while 1.8.x means the password path.

The guide, the Compose definition and the running image can describe different database generations, and the running server is the one that answers requests. From the host, the check is one request:

curl -sL -l -v localhost:8086/ping

One reported OpenEMS-on-Docker deployment received this exchange:

HTTP/1.1 204 No Content
X-Influxdb-Build: OSS
X-Influxdb-Version: v2.7.12

Worked example: read that header as a version number. It splits into major version 2, minor 7, patch 12, so the server speaks the v2 API and the deployment authorizes OpenEMS with a token in the ApiKey field, alongside the organization and bucket names that setup printed. A header reading 1.8.x would have major version 1 and flips the decision to the username:password form in the same field, with no organization or bucket involved.

Two traps sit around the test: the 204 response needs no token, so it proves reachability and version only, and inside a container localhost names that container rather than the database container, so test from the host or against the address exactly as OpenEMS is configured to use it. If the guide, the Compose file and the running image keep drifting apart, pin the database image deliberately; the page on configuring InfluxDB Docker tags for OpenEMS updates explains what those tags mean and which one survives an upgrade.

Where does the OpenEMS token come from, and where does it go? #

The token is printed once when influx setup initializes the database and the setup guide tells you to note it down; that same string goes, unmodified, into the Timedata.InfluxDB component's ApiKey field in the OpenEMS backend configuration.

Record it at setup, because a v2 token cannot be displayed again afterwards; if it is lost, the database's token management issues a replacement with the permissions you choose. In the backend configuration, the Timedata.InfluxDB component takes the token in its ApiKey setting together with the organization and bucket names, and every history write and read then travels as a v2 API request authorized by that token — the same scheme as when you connect Node-RED to InfluxDB 2.6 with the v2 API, where the token in the connection settings decides whether writes are accepted at all. The decision at this step: ApiKey holds the token exactly as printed, not the account password and not a truncated copy.

Why is my component green but the UI shows "Error retrieving the data. Please try again later."? #

The green check mark reports only that the Timedata.InfluxDB component initialized, and the yellow message that the history view prints comes from a later query failing on token validity, permissions or bucket selection rather than from the component failing to start.

That message is generic by design, so it cannot distinguish an authentication rejection from an empty result or a broken query. One reported deployment ran the whole sequence: the ping answered 204 from the v2 server, the database ran without errors, the UI showed the green check mark, and every history view returned the yellow message; the same deployment later reported history loading normally, which is the signature of a configuration or query fault rather than a broken server. A walkthrough of why OpenEMS charts come up empty with InfluxDB on a Pi works the same component-healthy, history-failing split from the write side. To locate the operation that actually fails on your stack:

  1. Confirm the endpoint OpenEMS is configured to use is the one the ping test answered, not a localhost that resolves inside the wrong container.
  2. Confirm the ApiKey field holds a complete token for a v2 server, or a username:password pair for v1, copied without truncation.
  3. Confirm the organization and bucket in the component match the names the setup command printed.
  4. Watch one known write land in the bucket, then query that exact timestamp back.
  5. Read the OpenEMS backend log and the InfluxDB log around the failed history request and match the rejected or empty query to it.

A rejected response moves the fault to credentials and permissions; a successful but empty response moves it to time range, channel selection or destination bucket.

Does the token have permission to write and read the bucket? #

Permission is a separate check from a valid token: the credential must allow both writing the measurements and querying them back, and a writer that works proves nothing about the reader, which may hold a different token or point at a different bucket.

A v2 token carries explicit permissions per resource, and the token created during setup holds broad operator rights — more than a time-series writer needs. Issue a token scoped to the OpenEMS bucket with read and write on it for the component, and keep the wide setup token for administration. Then verify both directions with one value: write a known measurement at a known timestamp, read that same timestamp back through the history path, and confirm endpoint, organization, bucket and credential are identical on both paths. The same split between an authenticated transport and an empty destination appears when a Telegraf MQTT consumer connects but writes no data to InfluxDB. The decision here: the component carries the narrow bucket-scoped token, and a passing write test is not a passing read test.

How do I change the InfluxDB password later without breaking OpenEMS? #

Change an account password through the database's own user-management command or interface after initialization, because setup runs once and is not a rotation procedure; an API token rotates separately, and OpenEMS keeps working only if the ApiKey field gets the new value.

On a v2 deployment the two edits are independent: OpenEMS sends the token, so a password change leaves it untouched, and only humans and CLI sessions need the new password. Check the two exceptions. A v1-mode ApiKey holding a username:password pair must receive the new password at the same time. Any other tool that logs in with the account, such as CLI scripts or the web UI, needs it as well. Token rotation follows its own sequence: issue the replacement with identical permissions, paste it into ApiKey, confirm one write and one read succeed, then revoke the old token last. For a running stack the decision is to rotate password and token on their own schedules and to repeat one write and one read after either change.

Questions asked

Why does setup still create a password if OpenEMS only uses a token?

The password belongs to the database's account layer, which exists alongside tokens in InfluxDB v2. The command-line interface, the web UI login and administrative tasks authenticate as a user, while applications authenticate with tokens. One setup command initializes both layers at once, which is why it asks for a password the OpenEMS application itself never sends.

What does the ApiKey field hold for each InfluxDB version?

For a v2 server it holds the API token exactly as setup printed it. For a v1 server it holds a username and password in user:password form instead, because v1 authenticates requests with accounts rather than tokens and organizes data as databases and retention policies rather than organizations and buckets. Let the version header your own container reports pick the form.

What if the setup token was never written down?

Issue a replacement through the database's token management, paste it into the ApiKey field unchanged, and confirm one write and one read before relying on it. The original cannot be displayed again: a v2 server stores only a hash of each token, so a token is visible exactly once, at the moment it is created.

Can OpenEMS and other writers share one InfluxDB token?

They can if the token's permissions cover the bucket, but a separate token per application is the cleaner pattern. Revoking or rotating one application's token then leaves the others untouched, and a leaked credential traces to a single consumer. Give each writer a token scoped to its own bucket with read and write permission on that bucket only.

My stack already runs with the published setup password. What now?

Change the account password through the database's documented user management, then audit where the public string may have traveled: Compose files in version control, terminal transcripts, screenshots and support tickets. On a v2 deployment the OpenEMS component needs no follow-up edit because it authenticates with its token; only a v1-mode username:password pair takes the new password.

Keep reading

  • Troubleshooting

    Fix Telegraf authorization not found on InfluxDB 2

    authorization not found every 10 s means InfluxDB 2 is receiving Telegraf's writes and rejecting the token: the Windows service never saw INFLUX_TOKEN set in a separate CMD session, and token = "$INFLUX_TOKEN" is not the documented substitution form. Reference the variable as "${INFLUX_TOKEN}", deliver its value in the service's startup environment, restart, and confirm the Unauthorized lines stop and the bucket fills.

    Edge computing and IIoT

  • Troubleshooting

    Troubleshoot missing data in a Node-RED InfluxDB Grafana stack

    Work the chain in order: acquisition into Node-RED, the InfluxDB service and its storage mount, the write settings, then the Grafana query. In a 2.x stack most empty panels trace to a wrong token, bucket, URL or a controller clock that stamps points outside the panel's time range.

    Edge computing and IIoT

  • Comparison

    Canary historian export paths: MQTT publisher or API read

    Canary gives you two confirmed ways to move historian data out: the Publisher service, which pushes real-time values to MQTT or Kafka as Sparkplug B or JSON, and the Read API, which an external client calls to pull stored data. An outbound OPC UA server is not a confirmed option.

    Edge computing and IIoT