DotGenie.Tracking.Monitoring 1.0.7

dotnet add package DotGenie.Tracking.Monitoring --version 1.0.7
                    
NuGet\Install-Package DotGenie.Tracking.Monitoring -Version 1.0.7
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DotGenie.Tracking.Monitoring" Version="1.0.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DotGenie.Tracking.Monitoring" Version="1.0.7" />
                    
Directory.Packages.props
<PackageReference Include="DotGenie.Tracking.Monitoring" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DotGenie.Tracking.Monitoring --version 1.0.7
                    
#r "nuget: DotGenie.Tracking.Monitoring, 1.0.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DotGenie.Tracking.Monitoring@1.0.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DotGenie.Tracking.Monitoring&version=1.0.7
                    
Install as a Cake Addin
#tool nuget:?package=DotGenie.Tracking.Monitoring&version=1.0.7
                    
Install as a Cake Tool

DotGenie.Tracking.Monitoring

A production-ready .NET monitoring package that sends logs and health signals from your app to a central Node.js monitoring service. It handles app-key auth automatically, runs background health checks, and provides simple APIs for logs and metrics.

πŸ”‘ Getting Started - Get Your Application Key

To get your unique application key:

Your application key is required for authentication. Once you receive your key, you can start monitoring your application immediately.


β€’ Target: .NET 6.0 β€’ Transport: HTTPS JSON to your monitoring service base URL (default provided) β€’ Authentication: Application key automatically appended as ?key=...

What this package does

  • Database health monitoring: lightweight connectivity checks every 5 minutes
  • API health monitoring: pings your API health endpoints and measures latency
  • Centralized logging: info/warning/error/debug + typed logs for DB/API health
  • Error capture: middleware records unhandled exceptions and 4xx/5xx responses
  • App-key management: your key is appended to every call; you never handle it manually

Install

dotnet add package DotGenie.Tracking.Monitoring

Quick start

πŸ“§ First: Request your application key from mailstoumer@gmail.com or visit https://monitoring-dashboard-t3lc.onrender.com/

  1. Configuration (appsettings.json)
{
    "DotGenieMonitoring": {
        "ApplicationKey": "your-app-key",             
        "ApplicationName": "My Awesome App",
        "MonitoringServiceUrl": "https://monitoring-dashboard-t3lc.onrender.com/api/",
        "ApiBaseUrl": "https://localhost:5001",
        "HealthCheckIntervalMinutes": 5
    }
}
  1. Register services (Program.cs)
using DotGenie.Tracking.Application.Api.Monitoring;

builder.Services.AddDotGenieMonitoring(builder.Configuration);

// Optional: Make DbContext available if you want DB health checks
builder.Services.AddScoped<DbContext>(sp => sp.GetRequiredService<YourDbContext>());
  1. (Optional) Use the middleware to capture API errors
app.UseMiddleware<ErrorLoggingMiddleware>();

Done. Health checks start automatically and logs/metrics go to your monitoring service with your key appended.

Components overview

  • MonitoringService

    • Low-level HTTP client for the monitoring service
    • Methods: SendLog, SendError, SendInfo, SendDatabaseStatus, SendApiHealth
    • App key is appended via ?key=... automatically
  • SimpleMonitoringService (IHostedService, ISimpleMonitoringService)

    • Runs periodic DB and API health checks on a timer
    • Exposes methods: CheckDatabaseHealthAsync, CheckApiHealthAsync, SendApplicationMetricAsync
    • Keeps last-known health status in memory and returns via getters
  • DbHealthMonitor (BackgroundService)

    • Independent background worker that checks EF Core DbContext connectivity
    • Sends database_health logs via MonitoringService
  • ApiHealthMonitor (BackgroundService)

    • Independent background worker that checks API endpoints (/health, /api/health, /api/status)
    • Sends api_health specialized logs and a general info/warning log with details
    • Detects DB root-cause from a health payload and switches category to "Database" when appropriate
  • ErrorLoggingMiddleware

    • Captures unhandled exceptions and 4xx/5xx responses
    • Sends structured logs with request details
  • MonitoringServiceExtensions

    • Extension methods to register everything in one line: AddDotGenieMonitoring(...)
  • LogTypes

    • Constants for safe log types accepted by the server: info, warning, error, debug, database_health, api_health

Public APIs

MonitoringService:

  • Task SendLog(string type, string message, object? details = null)
  • Task SendError(string message, Exception exception)
  • Task SendInfo(string message, object? details = null)
  • Task SendDatabaseStatus(bool isHealthy, string message, object? details = null)
  • Task SendApiHealth(string url, string status, int responseTime, string message)

ISimpleMonitoringService:

  • Task CheckDatabaseHealthAsync()
  • Task CheckApiHealthAsync()
  • Task SendApplicationMetricAsync(string metricType, string message, object? additionalData = null)
  • Task<HealthStatus> GetDatabaseHealthStatusAsync()
  • Task<HealthStatus> GetApiHealthStatusAsync()
  • Task<OverallHealthStatus> GetOverallHealthStatusAsync()

Usage examples

Inject ISimpleMonitoringService into your controllers/services:

public class OrdersController : ControllerBase
{
        private readonly ISimpleMonitoringService _monitoring;
        public OrdersController(ISimpleMonitoringService monitoring) => _monitoring = monitoring;

        [HttpPost("/orders")]
        public async Task<IActionResult> Create([FromBody] CreateOrder req)
        {
                try
                {
                        // ... your logic
                        await _monitoring.SendApplicationMetricAsync(
                                metricType: LogTypes.Info,
                                message: "Order created",
                                additionalData: new { orderId = 123, amount = 99.99 }
                        );
                        return Ok();
                }
                catch (Exception ex)
                {
                        await _monitoring.SendApplicationMetricAsync(
                                metricType: LogTypes.Error,
                                message: $"Order failed: {ex.Message}",
                                additionalData: new { error = ex.Message }
                        );
                        throw;
                }
        }
}

Manually trigger health checks and read status:

await _monitoring.CheckDatabaseHealthAsync();
await _monitoring.CheckApiHealthAsync();
var overall = await _monitoring.GetOverallHealthStatusAsync();

Configuration

DotGenieMonitoring section in appsettings.json:

  • ApplicationKey (required) – Your app’s key for the monitoring service
  • ApplicationName – Human-friendly name (default: "Unknown Application")
  • MonitoringServiceUrl – Base URL for the monitoring API (default provided)
  • ApiBaseUrl – Your API base used by health checks (if provided)
  • HealthCheckIntervalMinutes – Period for SimpleMonitoringService checks (default: 5)
  • EnableDatabaseMonitoring – true/false (default: true)
  • EnableApiMonitoring – true/false (default: true)
  • HealthCheckTimeoutSeconds – timeout for health requests (default: 30)

Environment variables:

  • DOTGENIE_MONITORING__APPLICATIONKEY, DOTGENIE_MONITORING__APPLICATIONNAME, DOTGENIE_MONITORING__MONITORINGSERVICEURL, DOTGENIE_MONITORING__APIBASEURL, etc.

Payloads (to /api/logs)

All logs are posted as JSON to {MonitoringServiceUrl}/logs?key={ApplicationKey}

Common envelope:

  • type: string (see LogTypes)
  • message: string
  • details: object or null
  • timestamp: ISO-8601 string
  • source: "ApplicationApi"
  • environment: value of ASPNETCORE_ENVIRONMENT or "Unknown"

Examples:

  • database_health
    • message: "Database is healthy"
    • details: { isHealthy: true, additionalInfo: { ... } }
  • api_health
    • message: "API health check passed"
    • details: { url, status, responseTime, source, environment }

Notes on metric types

When calling SendApplicationMetricAsync(metricType, ...), use supported types:

  • info, warning, error, debug, database_health, api_health

If a different value is provided (e.g., "order_created"), the client falls back to info and includes your original value at details.originalMetricType so your event is still visible.

Troubleshooting

  • Not seeing logs? Check application logs for lines starting with "Failed to send monitoring log"β€”they include status code and server response.
  • 404 on API health? The package posts API health via /api/logs (type: api_health). Ensure your Node app handles that type.
  • Key rejected? Verify the ApplicationKey matches the one registered in your monitoring service. Contact mailstoumer@gmail.com if you need a new key.
  • Health URL wrong? Set ApiBaseUrl or set ApiHealthMonitor:BaseUrl if you're using ApiHealthMonitor directly.
  • Need help? Email mailstoumer@gmail.com or visit https://monitoring-dashboard-t3lc.onrender.com/

Security

  • Connection strings are never sent; DB details are sanitized
  • All calls use HTTPS (when your MonitoringServiceUrl uses https)
  • Errors are logged but do not crash your app (graceful degradation)

Support & Dashboard

πŸ“§ Get Your App Key: mailstoumer@gmail.com
🌐 Monitoring Dashboard: https://monitoring-dashboard-t3lc.onrender.com/
πŸ“š Integration Guide: see INTEGRATION_GUIDE.md
πŸ› Issues: https://github.com/Herofab/MonitoringSoftwaresNuget

β€” Happy monitoring!

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.7 228 11/4/2025
1.0.6 232 11/3/2025
1.0.5 241 11/3/2025
1.0.4 224 11/3/2025
1.0.3 232 11/3/2025
1.0.2 193 10/31/2025
1.0.1 197 10/31/2025
1.0.0 205 10/31/2025