Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Events by Type #30

Open
wymangr opened this issue Aug 3, 2021 · 0 comments
Open

Get Events by Type #30

wymangr opened this issue Aug 3, 2021 · 0 comments

Comments

@wymangr
Copy link

wymangr commented Aug 3, 2021

Is there a way to filter the events that are searched to only the "Error" and not "warning" or "info"?

I'm trying to count the number of "disk" errors in my event log and trying to speed up the code a little bit by not having to iterate through every event in the event log.

Here is my code:

	diskErrors := 0.0

	t, _ := evtx.Open(`C:\Windows\System32\winevt\Logs\System.evtx`)
	defer t.Close()

	e := t.FastEvents()
	path := evtx.Path("Event/System/EventID/Qualifiers")

	for a := range e {
		d, _ := a.GetMap(&path)

		if d != nil {

			var providerData map[string]interface{} = *d
			switch providerData["Qualifiers"] {
			case "49156":
				switch providerData["Value"] {
				case "7":
					diskErrors += 1
				}
			}
		}
	}

Any help would be appreciated!

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

No branches or pull requests

1 participant