Skip to content
Documentation
Updated 6 minutes to read
Markdown

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.

  • 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 @errorLimit and @warningLimit to match your operational tolerances
  • Lookback window: Set @lookbackHours to 0 for 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 = OK
CREATE PROCEDURE dbo.MonitorFailedLogEvents
AS
BEGIN
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;
GO

How 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

  • Go to the SQL Databases tab and select your connection
  • Click the SQL Statements tab
  • Click Add to create a new SQL Statement configuration
  • Enabled: ✅ Checked
  • Display Name: LogEvents - Failed Validation Monitor
  • Description: Monitors the LogEvents table for validation failures and triggers alerts when thresholds are exceeded
  • Command Type: Stored Procedure
  • Execute Command: [dbo].[MonitorFailedLogEvents]
  • 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 Monitor resource
  • 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?”
  1. Insert an invalid LogEvent (malformed JSON):

    INSERT INTO dbo.LogEvents (LogEvent, ValidationFailed)
    VALUES (N'{invalid-json', 0);
  2. Wait for the next monitoring cycle (60-300 seconds)

  3. Check the resource status in your Monitor View

  4. Verify that alerts are triggered if thresholds are exceeded

  5. Clean up the test data:

    DELETE FROM dbo.LogEvents
    WHERE LogEvent = N'{invalid-json';
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

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 failures

Recommendations:

  • 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 = 168 for 7 days)

...

Version:
Release date: N/A
Loading...

Explore Nodinite for 30 days – completely free

  • Find out why this is the leading O&M software
  • Prove your business case
  • Test the self-service for the business side

Loading...

See how Nodinite resolves your technical issues, in a LIVE Demo!

Once you submit this request:

  • We will give you a short call to understand the issues you want to tackle.
  • Understand solutions you have tried and why were you not happy with them.
  • Book a convenient slot for a LIVE demo!

Loading...