Jump to content

Generate Web Safe Keys

From Game in the Brain Wiki
Revision as of 14:54, 27 February 2026 by Justinaquino (talk | contribs) (Created page with "= Tracking User Prompts and Enabling Analytics in Open WebUI = If you are an administrator for an Open WebUI instance, you may want to know who is prompting the most or using the most tokens. This guide explains how to find the built-in Analytics dashboard, how to update your instance if the dashboard is missing, and how to properly secure your users' login sessions so they don't get kicked out when the server restarts. == 1. Finding the Analytics Dashboard == Open Web...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Tracking User Prompts and Enabling Analytics in Open WebUI

If you are an administrator for an Open WebUI instance, you may want to know who is prompting the most or using the most tokens. This guide explains how to find the built-in Analytics dashboard, how to update your instance if the dashboard is missing, and how to properly secure your users' login sessions so they don't get kicked out when the server restarts.

1. Finding the Analytics Dashboard

Open WebUI has a built-in Analytics dashboard that shows user message counts, token usage, and active users.

To access it:

Click your Profile Icon (bottom-left).

Go to the Admin Panel.

Look at the top-left menu bar. You should see Users, Evaluations, Functions, Settings, and Analytics.

Why is Analytics missing? If you do not see the Analytics tab, you are likely running an older version of Open WebUI (older than v0.8.0). You will need to update your Docker container to access this feature.

2. Updating Open WebUI via Docker

To reveal the Analytics tab, update your instance to the latest version. Run these commands in the terminal, inside the folder containing your docker-compose.yml file:

docker compose pull
docker compose up -d

3. Securing User Sessions (Generating a Secret Key)

When reviewing your docker-compose.yml file, you might notice an empty environment variable: WEBUI_SECRET_KEY=.

If this is left blank, Open WebUI will auto-generate a new key every time the container restarts, which will log out all your users. To keep sessions stable, you must provide a permanent, cryptographically secure key.

Generating the Key with Python

You do not need a virtual environment (venv) or any external libraries to generate this key. Python has a built-in module called secrets.

⚠️ CRITICAL WARNING: Do NOT name your Python file secrets.py. If you do, Python will try to import your file instead of the built-in security module, and the script will crash. Name it something like generate_key.py.

Method A: The Terminal One-Liner (Fastest) You can paste this directly into your terminal to instantly generate a key:

Mac/Linux:

python3 -c "import secrets; print('WEBUI_SECRET_KEY=' + secrets.token_urlsafe(48))"

Windows:

python -c "import secrets; print('WEBUI_SECRET_KEY=' + secrets.token_urlsafe(48))"

Method B: Using a Python Script If you prefer to run a script, save the following code as generate_key.py and run it (using python3 generate_key.py or python generate_key.py):

import secrets

Generate a cryptographically secure URL-safe text string

48 bytes of randomness produces a 64-character string

secure_key = secrets.token_urlsafe(48)

print("Copy and paste the line below into your docker-compose.yml:")
print("-" * 50)
print(f"WEBUI_SECRET_KEY={secure_key}")
print("-" * 50)

Updating your docker-compose.yml

Once you have your generated key (it will look something like a1B2c3D4e5F6g7H8i9J0...), paste it into your configuration file:

services:
open-webui:
environment:
- OLLAMA_BASE_URL=http://192.168.196.226:11434
- WEBUI_SECRET_KEY=a1B2c3D4e5F6g7H8i9J0YourSecureKeyHere  # <-- Paste your new key here

After saving the file, run the update commands (docker compose up -d) to apply the changes. Your users will now stay logged in permanently, and your new Analytics dashboard will be available!