MS SQL Server send performance condition alerts to Windows Event Viewer

I have performance condition alerts successfully being sent via email however I would like certain alerts to log in the Windows Event Log.
I have tried using 'sp_update_alert' to set  @severity=19 but I receive and error from sp_verify_alert
'Msg 14500, Level 16, State 1, Procedure sp_verify_alert, Line 67
Supply either a non-zero message ID, non-zero severity, non-null performance condition, or non-null WMI namespace and query.'

Below is one of the alerts that I would like to send to event logs
EXEC msdb.dbo.sp_add_alert @name=N'TransLog:LogGrowing',
            @message_id=0,
            @severity=0,
            @enabled=1,
            @delay_between_responses=14400,
            @include_event_description_in=1,
            @notification_message=N'Proactive Alert:  DB Transaction log size growing too large',
            @category_name=N'[Uncategorized]',
            @performance_condition=N'Databases|Log File(s) Size (KB)|P21|>|20000',
            @job_id=N'00000000-0000-0000-0000-000000000000'
nexxtepAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PadawanDBAOperational DBACommented:
Alerts are essentially used for notifications.  They are recorded in the msdb.dbo.sysalerts table, not the event log.  The @severity option is used to define an alert for errors that generate at that severity level, not define the severity level of the alert.

In order to log events in the event log, you would need to essentially create a SQL Agent job that is polling for the condition that you would like to alert on and raise a user defined error, that is event logged.  Or extended events.
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
nexxtep, do you still need help with this question?
0
nexxtepAuthor Commented:
I am interested to know of a more direct method but I did the following
1. Created Agent job 'Custom_EventLog'    to execute the below which writes to Windows Event Viewer
     'EXEC xp_logevent 50001, 'Custom Msg: Proactive Warning Database Files Growing Check File Sizes and Disk  Space',         warning;'
2. Created SQL Server performance condition alert
     Object: Databases, Counter: Log Files Size, Alert counter rises above: 2000000
     Response: Calls Agent Job 'Custom_EventLog'

This works but I feel there must be a better way. The whole intent is to get "proactive" performance alerts into Event Viewer to be picked up by a management application.
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
xp_logevent is the correct way when using SQL Server to write in Event Logs.
I don't know a better way and don't know if exists any.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nexxtepAuthor Commented:
Thanks for the confirmation I will continue with this solution and close the question
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.