UsageMonitor.Core
0.3.0
dotnet add package UsageMonitor.Core --version 0.3.0
NuGet\Install-Package UsageMonitor.Core -Version 0.3.0
<PackageReference Include="UsageMonitor.Core" Version="0.3.0" />
paket add UsageMonitor.Core --version 0.3.0
#r "nuget: UsageMonitor.Core, 0.3.0"
// Install UsageMonitor.Core as a Cake Addin #addin nuget:?package=UsageMonitor.Core&version=0.3.0 // Install UsageMonitor.Core as a Cake Tool #tool nuget:?package=UsageMonitor.Core&version=0.3.0
UsageMonitor
UsageMonitor is a .NET library that provides API usage monitoring, rate limiting, and analytics capabilities for ASP.NET Core applications. It allows you to easily track API usage, implement rate limiting, and provide usage insights through a built-in dashboard.
Features
- ⚡ Rate Limiting per API Client
- 📊 Usage Analytics Dashboard
- 📈 Request Logging
- 🕒 Response Time Tracking
- 💾 Multiple Database Support (SQLite, PostgreSQL, SQL Server)
- 🔍 Built-in Admin Interface
- 📱 Usage Monitoring UI
Installation
dotnet add package UsageMonitor.Core
Quick Start
- Add UsageMonitor to your services in
Program.cs
:
builder.Services.AddUsageMonitor(options =>
{
options.ConnectionString = "Data Source=requests.db";
options.DatabaseProvider = DatabaseProvider.SQLite;
});
- Configure the middleware and endpoints:
app.UseUsageMonitor();
app.MapUsageMonitorEndpoints();
app.MapUsageMonitorPages();
- Add the
[MonitorUsage]
attribute to controllers or actions you want to monitor:
[ApiController]
[Route("[controller]")]
[MonitorUsage]
public class WeatherForecastController : ControllerBase
{
// Your controller code
}
Configuration
Database Providers
UsageMonitor supports SQLite, PostgreSQL, and SQL Server:
// For SQLite
options.DatabaseProvider = DatabaseProvider.SQLite;
options.ConnectionString = "Data Source=usagemonitor.db";
// For PostgreSQL
options.DatabaseProvider = DatabaseProvider.PostgreSQL;
options.ConnectionString = "Host=localhost;Database=usagemonitor;Username=user;Password=password";
// For SQL Server
options.DatabaseProvider = DatabaseProvider.SQLServer;
options.ConnectionString = "Server=localhost;Database=usagemonitor;Trusted_Connection=True;TrustServerCertificate=True";
Features
Rate Limiting
- Configure usage limits per API client
- Automatic rate limit enforcement
- Monthly usage tracking
Usage Monitoring
- Request/response logging
- Response time tracking
- Error rate monitoring
- Usage statistics
Admin Dashboard
- View all API clients
- Manage usage limits
- Monitor API usage
- Generate usage reports
Client Usage Page
- Self-service usage monitoring
- Usage statistics visualization
- Request history
Security
- Secure admin interface with username/password authentication
Example Implementation
Check out the UsageMonitor.TestApi
project in the solution for a complete example of how to integrate and use the library.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.AspNetCore.Http (>= 2.2.2)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.AspNetCore.Routing (>= 2.2.2)
- Microsoft.EntityFrameworkCore (>= 8.0.10)
- Microsoft.EntityFrameworkCore.Sqlite (>= 8.0.10)
- Microsoft.EntityFrameworkCore.SqlServer (>= 8.0.10)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 8.0.10)
- QuestPDF (>= 2024.10.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.