Skip to content

eabykov/keycloak-compose

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Keycloak with PostgreSQL, Prometheus & Grafana

Containerized solution for running Keycloak with PostgreSQL, monitoring via Prometheus and Grafana.

🚀 Quick Start

  1. Prerequisites:

  2. Clone repository:

    git clone https://github.com/eabykov/keycloak-compose.git
    cd keycloak-compose
  3. Start the system:

    docker compose up -d
  4. Access services:

⚙️ Configuration

Configure using the .env file. Key parameters:

Variable Default Description
POSTGRES_DB keycloak PostgreSQL database name
POSTGRES_USER keycloak PostgreSQL user
POSTGRES_PASSWORD password PostgreSQL password
KEYCLOAK_ADMIN admin Keycloak admin username
KEYCLOAK_ADMIN_PASSWORD keycloak Keycloak admin password
GRAFANA_ADMIN_PASSWORD grafana Grafana admin password

Modify .env before first launch.

🔌 Service Access

Service URL Credentials
Keycloak http://localhost:8080 admin / keycloak
Grafana http://localhost:3000 admin / grafana
Prometheus http://localhost:9090 No authentication

📊 Monitoring

Automatically configured:

  • Prometheus scrapes Keycloak metrics every 15s
  • Grafana with pre-configured Keycloak Dashboard
  • Ready-to-use dashboards for:
    • JVM metrics
    • Database queries
    • Active sessions
    • Authentication errors

🛠 Management

Core Commands

Command Description
docker compose up -d Start all services in background
docker compose down Stop services (add -v to remove volumes)
docker compose logs -f Follow service logs in real-time
docker compose restart keycloak Restart Keycloak container

Resource Monitoring

# Live container resource usage
docker stats

# Check service status
docker compose ps

Keycloak Administration

After launch:

  1. Access Keycloak Admin Console
  2. Create new realm
  3. Configure clients and users

🧹 Cleanup

Remove all containers, images, and volumes:

docker compose down -v --rmi all
docker system prune -a -f --volumes

Warning
These commands permanently destroy all data!

⁉️ Troubleshooting

If services fail to start:

  1. Check port conflicts (8080, 9090, 3000)
  2. Inspect logs:
    docker compose logs keycloak
  3. Verify no conflicting containers:
    docker ps -a

📚 Resources

About

Keycloak with PostgreSQL, which includes Keycloak's monitoring using Prometheus and Grafana

Topics

Resources

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •