github ChrispyBacon-dev/DockFlare v1.9.1
DockFlare v1.9.1 - Prometheus Metrics & Major Stability Enhancements

latest releases: v2.1.7, v2.1.6, v2.1.5...
2 months ago

DockFlare v1.9.1 - Prometheus Metrics & Major Stability Enhancements

I'm thrilled to release DockFlare v1.9.1! This version introduces a highly requested feature for monitoring and observability: Prometheus Metrics.

This release is also packed with critical bug fixes and stability improvements that significantly enhance the reliability of core features like automatic rule cleanup and Access Policy management.

✨ New Feature: Prometheus Metrics Endpoint

You can now enable the built-in Prometheus metrics endpoint on the managed cloudflared agent to export a wide range of valuable data for use in tools like Grafana.

How to Use It:
Simply add the new CLOUDFLARED_METRICS_PORT variable to your .env file:

# .env file
# Enables the metrics endpoint on port 2000.
# The port will be exposed to the Docker host.
CLOUDFLARED_METRICS_PORT=2000

🤖 Agent & Rule Management Improvements

  • Automatic Reconciliation: DockFlare will now automatically detect any changes to your metrics configuration (CLOUDFLARED_METRICS_PORT) and recreate the agent container with the correct settings on restart.
  • Rewritten Rule Cleanup Logic: The background cleanup task has been completely rewritten to be resource-aware. It now intelligently handles multi-path services, ensuring that shared resources (like a DNS record) are only deleted when no other active rules depend on them.
  • Improved Cleanup Responsiveness: The default interval for the cleanup task (CLEANUP_INTERVAL_SECONDS) has been reduced from 300 to 60 seconds, making the automatic deletion of expired rules much more responsive.

🛠️ Bug Fixes

  • allowed_idps Label Fixed: Resolved a critical bug that caused API errors when using the access.allowed_idps label. DockFlare now correctly constructs Access Policy rules using the modern login_method keyword, making the feature fully functional.
  • Multi-Path UI Policy Management: Fixed an issue where managing Access Policies from the web UI would fail for rules that included a path.
  • Manual Rule Creation: Corrected a bug that prevented manually created ingress rules from being properly configured in the Cloudflare Tunnel.

📊 Example Grafana Dashboard Included

grafana_dashboard_example

To help you get started immediately, a pre-configured and detailed Grafana dashboard is now included in the repository.

  • Location: You can find dashboard.json in the examples/ directory of the repository.
  • How to Use: Simply import this JSON file into your Grafana instance.

How to Upgrade

To upgrade your Docker Compose deployment, run the following commands:

# Pull the latest stable image
docker compose pull

# Recreate the DockFlare container to apply the new code
docker compose up -d

After upgrading, you can add the CLOUDFLARED_METRICS_PORT variable to your .env file, and DockFlare will handle the rest.


Quick Guide: How to Set Up a Local Prometheus & Grafana Stack

If you don't already have a monitoring stack, here is a minimal docker-compose setup to get you started quickly.

1. Directory Structure

Create the following folders and files alongside your main docker-compose.yml:

.
├── docker-compose.yml   # Your main compose file
├── prometheus.yml         # New file for Prometheus configuration
└── grafana-provisioning/  # New folder
    └── datasources/       # New sub-folder
        └── datasource.yml # New file for Grafana configuration

2. File Contents

A) docker-compose.yml

Add the following services to your existing docker-compose.yml file:

services:
  # ... your existing dockflare service ...

  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    restart: unless-stopped
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
      - ./prometheus_data:/prometheus # Persistent data for Prometheus
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
    networks:
      - your-dockflare-network # <-- IMPORTANT: Use the same network as DockFlare
    labels:
      - "dockflare.enable=true"
      - "dockflare.hostname=prometheus.your-domain.com"
      - "dockflare.service=http://prometheus:9090"

  grafana:
    image: grafana/grafana-oss:latest
    container_name: grafana
    restart: unless-stopped
    volumes:
      - ./grafana_data:/var/lib/grafana # Persistent data for Grafana
      - ./grafana-provisioning:/etc/grafana/provisioning
    networks:
      - your-dockflare-network # <-- IMPORTANT: Use the same network as DockFlare
    labels:
      - "dockflare.enable=true"
      - "dockflare.hostname=metrics.your-domain.com" # Exposes Grafana
      - "dockflare.service=http://grafana:3000"

Permissions Tip: If Grafana or Prometheus fail to start with a "Permission denied" error, you may need to set the ownership of the host directories. Run sudo chown -R 472:472 ./grafana_data for Grafana and sudo chown -R 65534:65534 ./prometheus_data for Prometheus.

B) prometheus.yml

This file tells Prometheus where to find your cloudflared agent.

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: 'cloudflared'
    static_configs:
      - targets: ['your-cloudflared-agent-name:2000']
        # --- IMPORTANT ---
        # 1. Replace 'your-cloudflared-agent-name' with the actual name of your agent container (e.g., 'cloudflared-agent-green-bern').
        # 2. Replace '2000' with the port you set for CLOUDFLARED_METRICS_PORT.

C) grafana-provisioning/datasources/datasource.yml

This automatically adds Prometheus as a data source in Grafana.

apiVersion: 1

datasources:
  - name: Prometheus
    type: prometheus
    access: proxy
    url: http://prometheus:9090
    isDefault: true

3. How to Use

  1. Start the Stack: Run docker-compose up -d.
  2. Check Prometheus: Navigate to your Prometheus URL (e.g., http://prometheus.your-domain.com). Go to Status -> Targets. The cloudflared endpoint should be UP.
  3. Import Dashboard: Navigate to your Grafana URL (e.g., http://metrics.your-domain.com), log in (default: admin/admin), and import the dashboard.json file provided in the examples/ directory of the DockFlare repository.
  4. View Your Metrics!

Don't miss a new DockFlare release

NewReleases is sending notifications on new releases.