Skip to content

Add Errorlog importer in SQL Nexus#511

Merged
PiJoCoder merged 8 commits intomasterfrom
ErrorlogImporter_pijocoder_042726
May 5, 2026
Merged

Add Errorlog importer in SQL Nexus#511
PiJoCoder merged 8 commits intomasterfrom
ErrorlogImporter_pijocoder_042726

Conversation

@PiJoCoder
Copy link
Copy Markdown
Collaborator

@PiJoCoder PiJoCoder commented Apr 27, 2026

Testing Plan

1. Build & Deploy Verification

  • Clean and rebuild the solution. Confirm ErrorLogImporter.dll is present in sqlnexus\bin\Release\.

2. Importer Discovery

  • Launch sqlnexus. Open the Import form and verify "ERRORLOG Importer" appears under Options > Importers with Enabled checked by default.

3. Basic Import (SQLLogScout output)

  • Point to a SQLLogScout output folder containing SERVERNAME_ERRORLOG through SERVERNAME_ERRORLOG.6.
  • Click Import. Verify:
    • All 7 or more ERRORLOG files appear in the file list and show green progress bars.
    • tbl_ERRORLOG is created with all 7 columns (RowNum, LogDateTime, Process, Message, ErrorNumber, State, FileName).
    • The composite index IX_tbl_ERRORLOG_LogDateTime_RowNum exists.
    • All files' data is present (query SELECT FileName, COUNT(*) FROM tbl_ERRORLOG GROUP BY FileName — should return 7 rows).

4. Multi-line / Continuation Lines

  • Query for entries where Message contains CHAR(13) or CHAR(10) (e.g., registry startup parameters). Verify continuation lines are correctly appended to the parent entry rather than creating separate rows.

5. Error and State Extraction

  • Query

    SELECT RowNum, LogDateTime, ErrorNumber, State, Message 
    FROM tbl_ERRORLOG 
    WHERE ErrorNumber IS NOT NULL
  • Verify that rows with messages like Error: 18456, Severity: 14, State: 38. have the correct ErrorNumber (e.g., 18456) and State (e.g., 38) values populated.

  • Verify that non-error rows have NULL for both ErrorNumber and State.

  • Also query with this to see summary stats on errors

    SELECT ErrorNumber , State, COUNT(*) ErrorCount 
    FROM tbl_ERRORLOG
    WHERE ErrorNumber is not null
    GROUP BY ErrorNumber, State
    ORDER BY ErrorCount desc

6. Re-import with "Drop existing tables" enabled

  • Import the same folder again. Verify the table is dropped and recreated (no duplicate data from previous import).

7. Disabled Importer

  • Uncheck Enabled under the ERRORLOG Importer options. Re-import. Verify ERRORLOG files do not appear in the file list and tbl_ERRORLOG is not created.

…dd RowNum identity column with composite index, and remove obsolete tblErrorlog rowset definition

- Remove unused sqlLogin, sqlPassword, server, database, useWindowsAuth fields from ErrorLogImporter to avoid storing credentials unnecessarily in memory
- Add RowNum bigint IDENTITY(1,1) column to tbl_ERRORLOG for deterministic row ordering
- Add composite nonclustered index IX_tbl_ERRORLOG_LogDateTime_RowNum on (LogDateTime, RowNum) for efficient time-range queries
- Remove obsolete tblErrorlog rowset definition from TextRowsets.xml (both copies) since ERRORLOG import is now handled by the dedicated ErrorLogImporter plugin
Comment thread ErrorLogImporter/ErrorLogImporter.cs Fixed
Comment thread ErrorLogImporter/ErrorLogImporter.cs Fixed
Comment thread ErrorLogImporter/ErrorLogImporter.cs Fixed
Comment thread ErrorLogImporter/ErrorLogImporter.cs Fixed
Comment thread ErrorLogImporter/ErrorLogImporter.cs Fixed
Comment thread ErrorLogImporter/ErrorLogImporter.cs Fixed
PiJoCoder and others added 2 commits April 26, 2026 22:37
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Comment thread ErrorLogImporter/ErrorLogImporter.cs Dismissed
…only to collection fields, remove dead variable

- Replace string concatenation in loop (`pendingMessage += ...`) with `StringBuilder` to avoid O(n²) allocations on multi-line ERRORLOG entries
- Mark `knownRowsets` and `options` fields as `readonly` since they are never reassigned
- Remove unused `pendingMessage` variable, pass regex group value directly to `StringBuilder` constructor
- Condense `pendingDateTime` assignment to ternary expression
… error extraction

- Add nullable `ErrorNumber` (int) and `State` (int) columns to `tbl_ERRORLOG`
- Add compiled regex to extract error number and state from messages matching `Error: NNNNN, Severity: NN, State: NN.`
- Parse error/state client-side at insert time; columns remain NULL for non-error log entries
@PiJoCoder
Copy link
Copy Markdown
Collaborator Author

Tested general ERRORLOG import - works fine.
Also tested ERRORLOG that contain Deadlock information - looks good

image

Copy link
Copy Markdown
Contributor

@hacitandogan hacitandogan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with multiple different scenarios , memory status outputs , dumps , database recovery failures (hekaton) , import is working fine for all those

Image Image Image Image

@PiJoCoder PiJoCoder merged commit b324a8f into master May 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create an ERRORLOG importer to import SQL Server error logs into SQL Nexus table

3 participants