Watchdog Middleware is a lightweight, pluggable .NET middleware component designed to intercept, monitor, and store API traffic with minimal configuration.
It captures request and response details, stores the data in InfluxDB, and offers real-time visualization and monitoring through Grafana. It's ideal for projects that require observability, error analysis, and performance tracking without intrusive instrumentation.
Inspired by both the electronic watchdog timer and the loyal API guardian, this middleware ensures your APIs are always under control. 🛡️
- 📡 Intercepts all API requests/responses
- 🗃️ Saves data in InfluxDB using customizable fields and tags
- 📊 Integrated with Grafana for real-time dashboards
- 🔐 Optional sensitive route exclusion and body encryption
- 🐳 Fully Docker-ready stack for local or cloud deployments
- 📍 IP Geolocation support out of the box
git clone https://github.com/RubenMartinezSiso/WatchdogMiddleware.git
cd WatchdogMiddleware/WatchdogMiddleware
docker compose up -d
Make sure Docker is installed and running.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseWatchdogMiddleware(options =>
{
options.ApiName = "MyAwesomeAPI";
options.ActivateLogs = true;
// Add more config if needed
});
app.UseRouting();
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
}
Grafana is preconfigured and accessible via:
http://localhost:3000
Use default credentials (
admin
/admin
) unless customized.
Navigate to the test project folder and run:
dotnet test
Tests cover:
- InfluxDB & Grafana connectivity
- API logging functionality
- Sensitive route exclusion
- Checkpoint system
- Data deletion verification
📦 WatchdogMiddleware
┣ 📁 Docker # Infrastructure (InfluxDB, Grafana, Prometheus...)
┣ 📁 Models # C# classes for intercepted data
┣ 📁 Tests # xUnit-based integration tests
┣ 🐶 WatchdogMiddleware.cs # Core middleware logic
┣ 📄 .env # Environment configuration
┗ 📄 docker-compose.yml
If you find this useful or want to contribute, feel free to reach out or fork the project!