Version 3

This commit is contained in:
Eugene Bykov committed 2026-05-19 19:45:46 +03:00
1 parent 4fb88290a9
commit 9205bad184
7 files changed
+267 -224

No files matched your search

+29 -11
View File
@@ -1,24 +1,42 @@
# releases: https://www.postgresql.org/docs/release
# =============================================================================
# Image versions (pinned). Renovate/Dependabot
# =============================================================================
# PostgreSQL — https://www.postgresql.org/docs/release
POSTGRES_VERSION=17.10-alpine
# releases: https://github.com/keycloak/keycloak/releases
# Keycloak — https://github.com/keycloak/keycloak/releases
KC_VERSION=26.6.2
# The link that will be used by the Grafana to redirect to the Keycloak
# Prometheus — https://github.com/prometheus/prometheus/releases
PROMETHEUS_VERSION=v3.11.3
# Grafana — https://github.com/grafana/grafana/releases
GF_VERSION=13.0.1-security-01
# =============================================================================
# Keycloak
# =============================================================================
KC_HOSTNAME=http://localhost
KC_PORT=8080
KC_REALM_NAME=grafana
KC_LOG_LEVEL=INFO
KEYCLOAK_ADMIN=admin
KEYCLOAK_ADMIN_PASSWORD=keycloak
# releases: https://github.com/prometheus/prometheus/releases
PROMETHEUS_VERSION=v3.11.3
KC_BOOTSTRAP_ADMIN_USERNAME=admin
KC_BOOTSTRAP_ADMIN_PASSWORD=keycloak
# =============================================================================
# Prometheus
# =============================================================================
PROMETHEUS_PORT=9090
# releases: https://github.com/grafana/grafana/releases
GF_VERSION=13.0.1
GF_LOG_LEVEL=info
GF_SERVER_HTTP_PORT=3000
# =============================================================================
# Grafana
# =============================================================================
GF_HOSTNAME=http://localhost
GF_SERVER_HTTP_PORT=3000
GF_LOG_LEVEL=info
GF_ADMIN_USERNAME=admin
GF_ADMIN_PASSWORD=grafana
+107 -164
View File
@@ -1,220 +1,163 @@
# Keycloak Observability Stack
Production-ready monitoring stack for Keycloak with Prometheus metrics and Grafana dashboards, featuring OAuth2/OIDC authentication.
Local observability stack: Keycloak + Postgres + Prometheus + Grafana with OAuth/OIDC authentication for Grafana via Keycloak. Suitable as a reference for verifying Keycloak metrics and exercising the OAuth flow.
> [!WARNING]
> This is a **dev configuration**: Keycloak runs in `start-dev`, Postgres uses `tmpfs` (data does not survive a restart), default passwords live in `.env`. For production use, see the [Production checklist](#production-checklist).
## Architecture
- **Keycloak** - Identity and access management with metrics enabled
- **Prometheus** - Time-series metrics collection (15s scrape interval, 30d retention)
- **Grafana** - Metrics visualization with OAuth authentication
- **PostgreSQL** - Keycloak backend (ephemeral storage)
```
┌──────────────────────┐
Browser ──── http://localhost:3000 (GF_SERVER_HTTP_PORT) ─→ Grafana
│ └─────────┬────────────┘
│ OAuth │ backchannel (token/userinfo)
│ (frontchannel)│ http://keycloak:8080 (docker DNS)
▼ ▼
http://localhost:8080 (KC_PORT) ───→ Keycloak (start-dev, realm-import)
│ │
metrics :9000 ──┘ └── JDBC :5432 ──→ Postgres (tmpfs)
│
▼
Prometheus ──── scrape 15s ──┐
▲ │
└── Grafana datasource ◄──┘
```
Version changes are made via `.env`.
## Prerequisites
- [Docker](https://docs.docker.com/get-docker/) v20.10.7+
- [Docker Compose](https://docs.docker.com/compose/install/) v2.0.0+
- [Docker](https://docs.docker.com/get-docker/) ≥ 24.x
- [Docker Compose v2](https://docs.docker.com/compose/install/) (`docker compose`, not `docker-compose`)
- Free ports: `3000`, `8080`, `9090` (or override in `.env`)
## Quick Start
```sh
# Clone the repository
git clone https://github.com/ML-ZoneReaper/keycloak-compose.git
git clone git@github.com:ML-ZoneReaper/keycloak-compose.git
cd keycloak-compose
# Start the stack
# Start with health checks
docker compose up -d
docker compose ps # all services should be in healthy status
# Verify services are running
docker compose ps
# Follow logs in real-time
# Live logs
docker compose logs -f
```
## Access Points
The first start takes ~60 seconds (Keycloak imports the realm and runs migrations against an empty DB). Healthchecks with `start_period: 60s` handle this correctly — Grafana waits for Keycloak readiness thanks to `depends_on.condition: service_healthy`.
| Service | URL | Credentials |
|---------|-----|-------------|
| Grafana | http://localhost:3000 | admin / grafana |
| Keycloak | http://localhost:8080 | admin / keycloak |
| Prometheus | http://localhost:9090 | - |
## Access points
### First-Time Setup
| Service | URL | Credentials (default) |
|------------|------------------------------------|-----------------------|
| Grafana | http://localhost:3000 | OAuth via Keycloak |
| Keycloak | http://localhost:8080 | `admin` / `keycloak` |
| Prometheus | http://localhost:9090 | no authentication |
1. Access Keycloak Admin Console at http://localhost:8080
2. Log in with default credentials (`admin` / `keycloak`)
3. Grafana will authenticate through Keycloak OAuth automatically
The Grafana login form is disabled (`GF_AUTH_DISABLE_LOGIN_FORM=true`). Sign-in is only via the "Sign in with Keycloak" button → user `admin` / `grafana`.
## Configuration
## Key features
Environment variables in `.env`:
- **OAuth (PKCE)** — Grafana acts as a public client with PKCE `S256`, no client_secret.
- **Auto-provisioned dashboards** — Grafana pulls dashboards from `grafana/dashboards/` via provisioning. The datasource UID is hardcoded (`P02FBFF047EDBB13A`) and matches between `datasources.yml` and the dashboard JSON.
- **Realm import** — `keycloak/realm.json` is imported at startup, with `${VAR}` substitution from env.
- **JVM/Agroal/JGroups metrics** — exposed on management port `9000`, scraped by Prometheus every 15s, 30d retention.
- **Healthchecks with `start_period`** — correct startup ordering, `depends_on.condition: service_healthy`.
- **Security baseline** — `no-new-privileges:true` on all services, custom docker network, containers with explicit names.
**Important**: Modify credentials before deploying to production.
## OAuth flow (important to know)
## Key Features
The main classic pitfall is which URLs to use for OAuth endpoints.
- **Pre-configured OAuth** - Grafana authenticates via Keycloak OIDC
- **Auto-provisioned Dashboards** - Pre-loaded Keycloak monitoring dashboard
- **JVM Monitoring** - Heap memory, GC metrics, thread counts, class loading
- **Connection Pooling** - Agroal datasource metrics (idle, active, leak detection)
- **Structured Logging** - JSON logs with rotation (10MB × 3 files)
- **Data Retention** - 30-day metric retention in Prometheus
| Endpoint | Who calls it | URL |
|----------------------|-----------------|------------------------------------------------------|
| `auth_url` | browser (UA) | external `${KC_HOSTNAME}:${KC_PORT}` → `http://localhost:8080` |
| `token_url` | Grafana → KC | internal `http://keycloak:8080` (docker DNS) |
| `api_url` (userinfo) | Grafana → KC | internal `http://keycloak:8080` (docker DNS) |
| `signout_redirect` | browser (UA) | external `${KC_HOSTNAME}:${KC_PORT}` |
## Metrics Coverage
If you point `api_url`/`token_url` at `localhost`, Grafana will resolve `localhost` inside its own container and OAuth will break. On the backchannel, Keycloak's internal port is **always 8080**, regardless of which host port it's mapped to via `${KC_PORT}`.
### JVM Metrics
- **Memory**: heap usage, committed memory, max heap
- **Garbage Collection**: collection count/time by collector type
- **Threads**: live threads, daemon threads, peak thread count
- **Class Loading**: loaded classes, unloaded classes, current count
## Metrics
### Connection Pool (Agroal)
- Active/idle/awaiting connections
- Acquisition time (average, maximum, total)
- Connection creation time and count
- Leak detection events
- Flush and reap operations
- Maximum concurrent connections
Endpoint: `http://keycloak:9000/metrics` (inside the docker network), enabled via `KC_METRICS_ENABLED=true` + `KC_HEALTH_ENABLED=true` (the latter is required to open management port 9000).
### System Metrics
- Available processors
- System load average
- CPU utilization
The `keycloak-general.json` dashboard covers:
- **JVM:** heap (used/committed/max), GC pause count/duration, threads, classloader
- **Agroal (connection pool):** idle/acquired/awaiting connections, leak detection, acquisition time
- **System:** CPU, load average, available processors
## Management Commands
### Service Control
## Management commands
```sh
# Start services
docker compose up -d
# Full restart with rebuild
docker compose down && docker compose up -d
# Stop services
docker compose down
# Stop and remove volumes (destroys data)
# Tear down along with volumes (tmpfs is ephemeral anyway)
docker compose down -v
# Restart specific service
# Restart a single service (e.g. after editing realm.json)
docker compose restart keycloak
# View service status
docker compose ps
```
# Service health
docker compose ps --format "table {{.Name}}\t{{.Status}}\t{{.Health}}"
### Monitoring & Logs
```sh
# Follow all logs
docker compose logs -f
# Follow specific service logs
# Logs for a specific service
docker compose logs -f keycloak
docker compose logs -f prometheus
docker compose logs -f grafana
# View resource usage
docker stats
# Verify that Prometheus sees the Keycloak target
curl -s http://localhost:9090/api/v1/targets | jq '.data.activeTargets[] | {job: .labels.job, health}'
```
### Data Management
```sh
# Remove all containers, volumes, and images
docker compose down -v --rmi all
# Clean up Docker system (use with caution)
docker system prune -a -f --volumes
```
## Monitoring
Access the pre-configured Keycloak dashboard in Grafana after OAuth login:
**Dashboard Panels Include:**
- System resources (CPU, load average)
- Memory utilization trends over time
- Connection pool health and saturation
- Garbage collection behavior analysis
- Thread count and daemon threads
- Class loading statistics
**Prometheus Metrics Endpoint:**
- Keycloak metrics: http://keycloak:9000/metrics
- Prometheus self-metrics: http://prometheus:9090/metrics
## Security Notes
⚠️ **Development Configuration**
- Keycloak runs in dev mode (`start-dev`)
- PostgreSQL uses tmpfs (ephemeral storage - data lost on restart)
- SSL verification disabled for OAuth (local development only)
- Default credentials are insecure
🔒 **Production Recommendations**
- Change all default passwords in `.env`
- Enable production mode: replace `start-dev` with `start`
- Use persistent volumes for PostgreSQL
- Enable SSL/TLS for all services
- Configure proper network isolation
- Implement secret management (Vault, etc.)
- Review and harden Keycloak realm settings
## Troubleshooting
### Services Won't Start
### Grafana dashboard is empty ("No data" in panels)
**Check port conflicts:**
1. Check targets: `curl -s localhost:9090/api/v1/targets | jq '.data.activeTargets[].health'` — they should all be `up`.
2. Verify that the datasource UID in `grafana/datasources/datasources.yml` matches the UID referenced by the dashboard panels (`P02FBFF047EDBB13A`).
3. In the Grafana UI: Configuration → Data sources → Prometheus → Save & test.
### Grafana refuses to authenticate via OAuth
Most often this is a URL mismatch. Set `GF_LOG_LEVEL=debug` in `.env`, restart grafana, and inspect `docker compose logs grafana | grep -i oauth`.
Typical cases:
- `redirect_uri mismatch` → `redirectUris` in `realm.json` doesn't match Grafana's actual callback (`/login/generic_oauth`).
- `connection refused` to token_url → `token_url` is using `localhost` instead of `keycloak`.
- `invalid issuer` → `KC_HOSTNAME` is misconfigured.
### Keycloak takes a long time to start / healthcheck fails
A first start with realm import and migrations against an empty DB can take up to 60 seconds. If `start_period: 60s` is not enough (slow machine), increase it in `compose.yml`.
### Port conflict
```sh
# Verify ports 3000, 8080, 9090 are available
lsof -i :3000
lsof -i :8080
lsof -i :9090
lsof -i :3000 -i :8080 -i :9090
```
Override via `.env` (`KC_PORT`, `GF_SERVER_HTTP_PORT`, `PROMETHEUS_PORT`).
**Inspect service health:**
## Production checklist
```sh
# Check container status
docker compose ps
Before using this anywhere other than local dev:
# View recent logs
docker compose logs --tail=50 keycloak
```
**Verify no conflicting containers:**
```sh
docker ps -a | grep -E "keycloak|grafana|prometheus|postgres"
```
### Common Issues
| Issue | Solution |
|-------|----------|
| Port already in use | Stop conflicting services or change ports in `.env` |
| Keycloak won't connect to DB | Check PostgreSQL logs: `docker compose logs postgres` |
| Grafana OAuth fails | Verify `KC_HOSTNAME` and `GF_HOSTNAME` match your setup |
| Metrics not appearing | Check Prometheus targets: http://localhost:9090/targets |
### Health Checks
```sh
# PostgreSQL
docker compose exec postgres pg_isready -U keycloak
# Prometheus
curl http://localhost:9090/-/healthy
# Grafana
curl http://localhost:3000/api/health
```
- [ ] Change **all** default passwords in `.env` (Postgres, Keycloak bootstrap admin, Grafana admin)
- [ ] Switch `start-dev` → `start` in Keycloak's `command`, explicitly configure `KC_HOSTNAME`, `KC_HOSTNAME_STRICT=true`, `KC_PROXY_HEADERS=xforwarded` (if behind a reverse proxy)
- [ ] TLS across the whole perimeter; remove `GF_AUTH_GENERIC_OAUTH_TLS_SKIP_VERIFY_INSECURE`, set `sslRequired: external`/`all` in the realm
- [ ] Persistent storage for Postgres instead of tmpfs (named volume + backups; CloudNativePG for HA)
- [ ] Secrets via Vault / Docker secrets / SOPS, not from `.env`
- [ ] Keycloak — confidential client (with client_secret) instead of public + PKCE for sensitive realms
- [ ] Remove the bootstrap admin after first launch, create personal admin accounts
- [ ] Resource limits (`deploy.resources.limits.memory/cpus`)
- [ ] Prometheus — external `remote_write` to VictoriaMetrics/Thanos/Mimir; local 30d retention is not viable for production load
- [ ] Alerts (Alertmanager) on JVM heap saturation, GC pause spikes, Agroal pool exhaustion, scrape errors
## Resources
- [Keycloak Documentation](https://www.keycloak.org/documentation)
- [Keycloak Metrics](https://www.keycloak.org/server/configuration-metrics)
- [Prometheus Querying](https://prometheus.io/docs/prometheus/latest/querying/basics/)
- [Grafana Dashboards](https://grafana.com/grafana/dashboards/)
- [Docker Compose Reference](https://docs.docker.com/compose/compose-file/)
- [Keycloak docs](https://www.keycloak.org/documentation)
- [Keycloak metrics](https://www.keycloak.org/observability/configuration-metrics)
- [Grafana OAuth (generic)](https://grafana.com/docs/grafana/latest/setup-grafana/configure-security/configure-authentication/generic-oauth/)
- [Prometheus query basics](https://prometheus.io/docs/prometheus/latest/querying/basics/)
- [Docker Compose spec](https://docs.docker.com/compose/compose-file/)
+81 -26
View File
@@ -4,86 +4,141 @@ x-logging: &logging
max-size: "10m"
max-file: "3"
x-security-opt: &security-opt
- no-new-privileges:true
networks:
default:
name: keycloak-stack
services:
postgres:
image: postgres:${POSTGRES_VERSION}
container_name: keycloak-postgres
restart: unless-stopped
healthcheck:
test: ["CMD", "pg_isready", "-U", "keycloak"]
security_opt: *security-opt
environment:
POSTGRES_DB: keycloak
POSTGRES_USER: keycloak
POSTGRES_PASSWORD: password
volumes:
- type: tmpfs
target: /var/lib/postgresql/data
tmpfs:
size: 100000000
PGDATA: /var/lib/postgresql/data/pgdata
healthcheck:
test: ["CMD-SHELL", "pg_isready -U keycloak -d keycloak"]
interval: 10s
timeout: 5s
retries: 10
start_period: 15s
tmpfs:
- /var/lib/postgresql/data:size=256m
logging: *logging
keycloak:
image: keycloak/keycloak:${KC_VERSION}
container_name: keycloak
command: ["start-dev", "--import-realm"]
restart: unless-stopped
security_opt: *security-opt
depends_on:
postgres:
condition: service_healthy
environment:
KC_DB: postgres
KC_DB_USERNAME: keycloak
KC_DB_PASSWORD: password
KC_DB_URL: "jdbc:postgresql://postgres:5432/keycloak"
KC_METRICS_ENABLED: true
KC_METRICS_ENABLED: "true"
KC_HEALTH_ENABLED: "true"
KC_HTTP_MANAGEMENT_PORT: "9000"
KC_LOG_LEVEL: ${KC_LOG_LEVEL}
KC_BOOTSTRAP_ADMIN_USERNAME: ${KC_BOOTSTRAP_ADMIN_USERNAME}
KC_BOOTSTRAP_ADMIN_PASSWORD: ${KC_BOOTSTRAP_ADMIN_PASSWORD}
KC_REALM_NAME: ${KC_REALM_NAME}
KC_BOOTSTRAP_ADMIN_USERNAME: ${KEYCLOAK_ADMIN}
KC_BOOTSTRAP_ADMIN_PASSWORD: ${KEYCLOAK_ADMIN_PASSWORD}
GF_URL: ${GF_HOSTNAME}:${GF_SERVER_HTTP_PORT}
GF_ADMIN_USERNAME: ${GF_ADMIN_USERNAME}
GF_ADMIN_PASSWORD: ${GF_ADMIN_PASSWORD}
ports:
- ${KC_PORT}:8080
- "${KC_PORT}:8080"
volumes:
- ./keycloak:/opt/keycloak/data/import:ro
healthcheck:
test:
- "CMD-SHELL"
- >
exec 3<>/dev/tcp/127.0.0.1/9000 &&
printf 'GET /health/ready HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n' >&3 &&
head -n1 <&3 | grep -q '200'
interval: 15s
timeout: 5s
retries: 20
start_period: 60s
logging: *logging
prometheus:
image: prom/prometheus:${PROMETHEUS_VERSION}
container_name: keycloak-prometheus
restart: unless-stopped
security_opt: *security-opt
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--storage.tsdb.retention.time=30d'
- '--storage.tsdb.wal-compression'
- '--web.enable-lifecycle'
restart: unless-stopped
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
depends_on:
keycloak:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--tries=1", "--spider", "http://localhost:9090/-/healthy"]
test: ["CMD", "wget", "--tries=1", "--spider", "-q", "http://localhost:9090/-/healthy"]
interval: 15s
timeout: 5s
retries: 5
start_period: 10s
ports:
- ${PROMETHEUS_PORT}:9090
- "${PROMETHEUS_PORT}:9090"
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
logging: *logging
grafana:
image: grafana/grafana:${GF_VERSION}
container_name: keycloak-grafana
restart: unless-stopped
security_opt: *security-opt
depends_on:
keycloak:
condition: service_healthy
prometheus:
condition: service_healthy
ports:
- ${GF_SERVER_HTTP_PORT}:${GF_SERVER_HTTP_PORT}
- "${GF_SERVER_HTTP_PORT}:3000"
healthcheck:
test: ["CMD", "wget", "--spider", "http://localhost:${GF_SERVER_HTTP_PORT}/api/health"]
test: ["CMD-SHELL", "wget --spider -q http://localhost:3000/api/health || exit 1"]
interval: 15s
timeout: 5s
retries: 5
start_period: 20s
environment:
GF_SERVER_HTTP_PORT: ${GF_SERVER_HTTP_PORT}
GF_SERVER_HTTP_PORT: "3000"
GF_SERVER_ROOT_URL: ${GF_HOSTNAME}:${GF_SERVER_HTTP_PORT}
GF_LOG_LEVEL: ${GF_LOG_LEVEL}
GF_AUTH_BASIC_ENABLED: true
GF_AUTH_DISABLE_LOGIN_FORM: true
GF_AUTH_GENERIC_OAUTH_TLS_SKIP_VERIFY_INSECURE: true
GF_AUTH_GENERIC_OAUTH_ENABLED: true
GF_AUTH_GENERIC_OAUTH_NAME: Keycloak
GF_AUTH_GENERIC_OAUTH_ALLOW_SIGN_UP: true
GF_SECURITY_ADMIN_USER: ${GF_ADMIN_USERNAME}
GF_SECURITY_ADMIN_PASSWORD: ${GF_ADMIN_PASSWORD}
GF_AUTH_BASIC_ENABLED: "true"
GF_AUTH_DISABLE_LOGIN_FORM: "true"
GF_AUTH_GENERIC_OAUTH_ENABLED: "true"
GF_AUTH_GENERIC_OAUTH_NAME: "Keycloak"
GF_AUTH_GENERIC_OAUTH_ALLOW_SIGN_UP: "true"
GF_AUTH_GENERIC_OAUTH_CLIENT_ID: "grafana"
GF_AUTH_GENERIC_OAUTH_EMAIL_ATTRIBUTE_NAME: "email:primary"
GF_AUTH_GENERIC_OAUTH_USE_PKCE: "true"
GF_AUTH_GENERIC_OAUTH_EMAIL_ATTRIBUTE_NAME: "email"
GF_AUTH_GENERIC_OAUTH_SCOPES: "openid profile email"
GF_AUTH_GENERIC_OAUTH_TLS_SKIP_VERIFY_INSECURE: "true"
GF_AUTH_GENERIC_OAUTH_AUTH_URL: ${KC_HOSTNAME}:${KC_PORT}/realms/${KC_REALM_NAME}/protocol/openid-connect/auth
GF_AUTH_GENERIC_OAUTH_TOKEN_URL: http://keycloak:${KC_PORT}/realms/${KC_REALM_NAME}/protocol/openid-connect/token
GF_AUTH_GENERIC_OAUTH_API_URL: ${KC_HOSTNAME}:${KC_PORT}/realms/${KC_REALM_NAME}/protocol/openid-connect/userinfo
GF_AUTH_GENERIC_OAUTH_TOKEN_URL: http://keycloak:8080/realms/${KC_REALM_NAME}/protocol/openid-connect/token
GF_AUTH_GENERIC_OAUTH_API_URL: http://keycloak:8080/realms/${KC_REALM_NAME}/protocol/openid-connect/userinfo
GF_AUTH_GENERIC_OAUTH_SIGNOUT_REDIRECT_URL: ${KC_HOSTNAME}:${KC_PORT}/realms/${KC_REALM_NAME}/protocol/openid-connect/logout?post_logout_redirect_uri=${GF_HOSTNAME}:${GF_SERVER_HTTP_PORT}/login&client_id=grafana
volumes:
- ./grafana/dashboards:/etc/grafana/provisioning/dashboards:ro
- ./grafana/datasources:/etc/grafana/provisioning/datasources:ro
@@ -86,7 +86,7 @@
"uid": "P02FBFF047EDBB13A"
},
"editorMode": "code",
"expr": "base_cpu_availableProcessors",
"expr": "system_cpu_count",
"instant": false,
"legendFormat": "__auto",
"range": true,
@@ -155,7 +155,7 @@
"uid": "P02FBFF047EDBB13A"
},
"editorMode": "code",
"expr": "base_cpu_systemLoadAverage",
"expr": "system_load_average_1m",
"instant": false,
"legendFormat": "__auto",
"range": true,
@@ -283,7 +283,7 @@
"uid": "P02FBFF047EDBB13A"
},
"editorMode": "code",
"expr": "base_memory_usedHeap_bytes",
"expr": "jvm_memory_used_bytes{area=\"heap\"}",
"instant": false,
"legendFormat": "Used",
"range": true,
@@ -295,7 +295,7 @@
"uid": "P02FBFF047EDBB13A"
},
"editorMode": "code",
"expr": "base_memory_maxHeap_bytes",
"expr": "jvm_memory_max_bytes{area=\"heap\"}",
"hide": false,
"instant": false,
"legendFormat": "Max",
@@ -308,7 +308,7 @@
"uid": "P02FBFF047EDBB13A"
},
"editorMode": "code",
"expr": "base_memory_committedHeap_bytes",
"expr": "jvm_memory_committed_bytes{area=\"heap\"}",
"hide": false,
"instant": false,
"legendFormat": "Committed",
@@ -736,7 +736,7 @@
"uid": "P02FBFF047EDBB13A"
},
"editorMode": "code",
"expr": "agroal_blocking_time_max_seconds",
"expr": "(agroal_blocking_time_max_milliseconds / 1000)",
"legendFormat": "__auto",
"range": true,
"refId": "A"
@@ -837,7 +837,7 @@
"uid": "P02FBFF047EDBB13A"
},
"editorMode": "code",
"expr": "base_classloader_loadedClasses_total",
"expr": "jvm_classes_loaded_classes",
"instant": false,
"legendFormat": "__auto",
"range": true,
@@ -939,7 +939,7 @@
"uid": "P02FBFF047EDBB13A"
},
"editorMode": "code",
"expr": "base_classloader_unloadedClasses_total",
"expr": "jvm_classes_unloaded_classes_total",
"instant": false,
"legendFormat": "__auto",
"range": true,
@@ -1004,7 +1004,7 @@
"uid": "P02FBFF047EDBB13A"
},
"editorMode": "code",
"expr": "agroal_creation_time_average_seconds",
"expr": "(agroal_creation_time_average_milliseconds / 1000)",
"instant": false,
"legendFormat": "__auto",
"range": true,
@@ -1203,7 +1203,7 @@
"uid": "P02FBFF047EDBB13A"
},
"editorMode": "code",
"expr": "base_classloader_loadedClasses_count",
"expr": "jvm_classes_loaded_classes",
"instant": false,
"legendFormat": "__auto",
"range": true,
@@ -1268,7 +1268,7 @@
"uid": "P02FBFF047EDBB13A"
},
"editorMode": "code",
"expr": "agroal_creation_time_total_seconds",
"expr": "(agroal_creation_time_total_milliseconds / 1000)",
"instant": false,
"legendFormat": "__auto",
"range": true,
@@ -1398,7 +1398,7 @@
"uid": "P02FBFF047EDBB13A"
},
"editorMode": "code",
"expr": "agroal_blocking_time_average_seconds",
"expr": "(agroal_blocking_time_average_milliseconds / 1000)",
"instant": false,
"legendFormat": "__auto",
"range": true,
@@ -1887,7 +1887,7 @@
"uid": "P02FBFF047EDBB13A"
},
"editorMode": "code",
"expr": "agroal_blocking_time_total_seconds",
"expr": "(agroal_blocking_time_total_milliseconds / 1000)",
"instant": false,
"legendFormat": "__auto",
"range": true,
@@ -1952,7 +1952,7 @@
"uid": "P02FBFF047EDBB13A"
},
"editorMode": "code",
"expr": "agroal_creation_time_max_seconds",
"expr": "(agroal_creation_time_max_milliseconds / 1000)",
"instant": false,
"legendFormat": "__auto",
"range": true,
@@ -2090,7 +2090,7 @@
"uid": "P02FBFF047EDBB13A"
},
"editorMode": "code",
"expr": "base_thread_daemon_count",
"expr": "jvm_threads_daemon_threads",
"instant": false,
"legendFormat": "__auto",
"range": true,
@@ -2159,7 +2159,7 @@
"uid": "P02FBFF047EDBB13A"
},
"editorMode": "code",
"expr": "base_thread_max_count",
"expr": "jvm_threads_peak_threads",
"instant": false,
"legendFormat": "__auto",
"range": true,
@@ -2191,4 +2191,4 @@
"title": "keycloak-general",
"uid": "keycloak-general",
"version": 1
}
}
+7
View File
@@ -2,7 +2,14 @@ apiVersion: 1
datasources:
- name: datasource-prometheus
uid: P02FBFF047EDBB13A
type: prometheus
url: http://prometheus:9090
access: proxy
isDefault: true
editable: false
jsonData:
httpMethod: POST
timeInterval: 15s
manageAlerts: true
prometheusType: Prometheus
+19 -6
View File
@@ -1,6 +1,6 @@
{
"id": "${KC_REALM_NAME}",
"realm": "${KC_REALM_NAME}",
"displayName": "Grafana OAuth",
"sslRequired": "none",
"enabled": true,
"eventsEnabled": true,
@@ -12,26 +12,39 @@
},
"clients": [
{
"id": "grafana",
"clientId": "grafana",
"name": "grafana",
"name": "Grafana",
"enabled": true,
"publicClient": true,
"standardFlowEnabled": true,
"implicitFlowEnabled": false,
"directAccessGrantsEnabled": false,
"serviceAccountsEnabled": false,
"frontchannelLogout": true,
"protocol": "openid-connect",
"rootUrl": "${GF_URL}",
"adminUrl": "${GF_URL}",
"baseUrl": "${GF_URL}",
"redirectUris": [
"${GF_URL}/*"
"${GF_URL}/login/generic_oauth"
],
"webOrigins": [
"${GF_URL}"
],
"attributes": {
"pkce.code.challenge.method": "S256",
"post.logout.redirect.uris": "${GF_URL}/login"
},
"defaultClientScopes": [
"openid",
"profile",
"email"
]
}
],
"users": [
{
"id": "admin",
"email": "${GF_ADMIN_USERNAME}@admin",
"email": "${GF_ADMIN_USERNAME}@example.com",
"username": "${GF_ADMIN_USERNAME}",
"firstName": "DevOps",
"lastName": "SRE",
+7
View File
@@ -2,14 +2,21 @@ global:
scrape_interval: 15s
scrape_timeout: 10s
evaluation_interval: 15s
external_labels:
cluster: keycloak-compose
env: local
scrape_configs:
- job_name: prometheus
metrics_path: /metrics
static_configs:
- targets: ['localhost:9090']
labels:
service: prometheus
- job_name: keycloak
metrics_path: /metrics
static_configs:
- targets: ['keycloak:9000']
labels:
service: keycloak