Monitoring Failed LogEvents
Section titled “Monitoring Failed LogEvents”How do I monitor failed LogEvents?
Section titled “How do I monitor failed LogEvents?”You can use the Nodinite Database Monitoring Agent to monitor the LogEvents table for failed entries. The Database Monitoring Agent provides automated, continuous monitoring with instant alerts through Nodinite Alarm Plugins, eliminating the need for manual SQL Server Agent job configuration.
Why should I use the Database Monitoring Agent?
Section titled “Why should I use the Database Monitoring Agent?”✅ Automated monitoring - Continuously evaluates your LogEvents table without manual SQL Agent setup
✅ Instant alerts - Trigger notifications via email, Slack, Teams, or custom webhooks when thresholds are exceeded
✅ Centralized visibility - View LogEvents monitoring status alongside all other integration resources in Nodinite Monitor Views
✅ Self-service management - Empower teams to execute troubleshooting scripts on-demand via Remote Actions
How do I create a monitoring stored procedure?
Section titled “How do I create a monitoring stored procedure?”The stored procedure below follows the Nodinite Database Monitoring Agent conventions for SQL Statements monitoring. Deploy this procedure to your SQL Server database, then configure it in Nodinite as described in the SQL Statements documentation.
Key concepts
Section titled “Key concepts”- Return codes:
-10= ERROR,10= WARNING,0= OK - SELECT output: The first column of the first row becomes the Log Text displayed in Nodinite resources
- Thresholds: Adjust
@errorLimitand@warningLimitto match your operational tolerances - Lookback window: Set
@lookbackHoursto0for all-time counts, or limit to recent failures (e.g., 24 hours)
Run this query on a schedule via the Database Monitoring Agent, or deploy it as a stored procedure in SQL Server Agent. Tune thresholds and the lookback window to match your operational needs.
-- Monitor failed LogEvents and return status codes:-- -10 = ERROR, 10 = WARNING, 0 = OKCREATE PROCEDURE dbo.MonitorFailedLogEventsASBEGIN SET NOCOUNT ON;
DECLARE @failedCount INT, @errorLimit INT = 50, -- Adjust to your environment @warningLimit INT = 10, -- Adjust to your environment @lookbackHours INT = 24, -- 0 = count all; otherwise limit to recent window @ret INT = 0, @log NVARCHAR(400);
SELECT @failedCount = COUNT(1) FROM dbo.LogEvents WHERE ValidationFailed = 1 AND ( @lookbackHours = 0 OR Created >= DATEADD(hour, -@lookbackHours, SYSUTCDATETIME()) );
IF (@failedCount > @errorLimit) BEGIN SET @log = N'ERROR: ' + CAST(@failedCount AS NVARCHAR(12)) + N' failed LogEvents in last ' + CAST(@lookbackHours AS NVARCHAR(6)) + N'h (threshold ' + CAST(@errorLimit AS NVARCHAR(12)) + N')'; SELECT @log; SET @ret = -10; END ELSE IF (@failedCount > @warningLimit) BEGIN SET @log = N'WARNING: ' + CAST(@failedCount AS NVARCHAR(12)) + N' failed LogEvents in last ' + CAST(@lookbackHours AS NVARCHAR(6)) + N'h (threshold ' + CAST(@warningLimit AS NVARCHAR(12)) + N')'; SELECT @log; SET @ret = 10; END ELSE BEGIN SELECT N'OK'; END
RETURN @ret;END;GOHow do I configure monitoring in Nodinite?
Section titled “How do I configure monitoring in Nodinite?”Once the stored procedure is deployed, configure it in Nodinite to enable automated monitoring:
Step 1: Open Database Monitoring Agent configuration
Section titled “ Step 1: Open Database Monitoring Agent configuration”Navigate to Administration → Monitor Management → Monitor Agents → Select your Database Monitoring Agent
Step 2: Add SQL Statement
Section titled “ Step 2: Add SQL Statement”- Go to the SQL Databases tab and select your connection
- Click the SQL Statements tab
- Click Add to create a new SQL Statement configuration
Step 3: Configure General settings
Section titled “ Step 3: Configure General settings”- Enabled: ✅ Checked
- Display Name:
LogEvents - Failed Validation Monitor - Description:
Monitors the LogEvents table for validation failures and triggers alerts when thresholds are exceeded
Step 4: Configure Monitoring Script
Section titled “ Step 4: Configure Monitoring Script”- Command Type:
Stored Procedure - Execute Command:
[dbo].[MonitorFailedLogEvents]
Step 5: Save and synchronize
Section titled “ Step 5: Save and synchronize”- Click Save and close
- The agent will automatically pick up the new configuration on the next sync cycle
- The stored procedure will appear as a new Resource in your Monitor Views
Step 6: Assign to Monitor View (optional)
Section titled “ Step 6: Assign to Monitor View (optional)”Add the new resource to a Monitor View to enable alerting:
- Navigate to Administration → Monitor Management → Monitor Views
- Select or create a Monitor View
- Add the
LogEvents - Failed Validation Monitorresource - Configure Alarm Plugins to receive notifications (email, Slack, Teams, webhooks)
How do I test my monitoring configuration?
Section titled “How do I test my monitoring configuration?”Test steps
Section titled “Test steps”-
Insert an invalid LogEvent (malformed JSON):
INSERT INTO dbo.LogEvents (LogEvent, ValidationFailed)VALUES (N'{invalid-json', 0); -
Wait for the next monitoring cycle (60-300 seconds)
-
Check the resource status in your Monitor View
-
Verify that alerts are triggered if thresholds are exceeded
-
Clean up the test data:
DELETE FROM dbo.LogEventsWHERE LogEvent = N'{invalid-json';
What do the return codes mean?
Section titled “What do the return codes mean?”Return code meanings
Section titled “Return code meanings”| Return Code | State | Description |
|---|---|---|
-10 |
❌ Error | Failed LogEvents exceed error threshold (@errorLimit) |
10 |
⚠️ Warning | Failed LogEvents exceed warning threshold (@warningLimit) |
0 |
✅ OK | Failed LogEvents below warning threshold or none found |
How do I adjust monitoring thresholds?
Section titled “How do I adjust monitoring thresholds?”Edit the stored procedure and modify these variables to match your environment:
@errorLimit INT = 50, -- Trigger error state above this count@warningLimit INT = 10, -- Trigger warning state above this count@lookbackHours INT = 24, -- Time window for counting failuresRecommendations:
- High-volume environments: Increase thresholds (e.g.,
@errorLimit = 500,@warningLimit = 100) - Low-volume environments: Decrease thresholds (e.g.,
@errorLimit = 10,@warningLimit = 3) - Real-time monitoring: Use shorter lookback windows (e.g.,
@lookbackHours = 1) - Trend analysis: Use longer lookback windows (e.g.,
@lookbackHours = 168for 7 days)