TRACK IP UNBAN EVENTS FROM CLOUDFLARE OR AWS WAF축구중계

Track IP Unban Events from Cloudflare or AWS WAF축구중계

Track IP Unban Events from Cloudflare or AWS WAF축구중계

Blog Article

Track IP 축구중계 Unban Events from Cloudflare or AWS WAF


1.1 Track IP Unbans via Cloudflare API


You can use a Python script (or similar) to send IP unban events to Prometheus whenever Fail2Ban or another service triggers an unban action in Cloudflare.



Example Python Script for Cloudflare IP Unban:



python






from prometheus_client import Counter, start_http_server import requests import time # Create a counter to track unban events unban_counter = Counter('cloudflare_unban_events', 'Number of IPs unbanned from Cloudflare', ['ip']) # Function to unban IP and update the Prometheus counter def unban_ip(ip): # Call Cloudflare API to unban IP (replace with your own API call) url = "https://api.cloudflare.com/client/v4/zones/YOUR_ZONE_ID/firewall/access_rules/rules/<rule_id>" headers = {"Authorization": "Bearer YOUR_API_TOKEN"} response = requests.delete(url, headers=headers) # Increment the unban counter in Prometheus unban_counter.labels(ip=ip).inc() # Start the Prometheus HTTP server start_http_server(8000) # Simulate unban events (you can replace this with real-time data) while True: ip_to_unban = "192.168.1.1" # Example IP unban_ip(ip_to_unban) time.sleep(60) # Simulate every minute


Exposing Metrics:




  • The script will expose the cloudflare_unban_events counter at http://localhost:8000/metrics.




  • Prometheus can scrape this endpoint and store the unban events as metrics.




1.2 Track IP Unbans via AWS


축구중계  


WAF API


Use AWS Lambda (or another backend service) to call AWS WAF APIs for IP unbans and update the Prometheus metrics using the Prometheus Python client.

Report this page