Watch for Login failure in windows events with watcher

I want to alert when there is some number of windows authentication failure events within certain period of time. Can somebody help me with the code? i am new to this.