Multiple Event IDs

Hello,
Why does the following Alloy configuration only send ID 4663?

loki.process "windows_event_logs" {
  forward_to = [loki.write.default.receiver]

  stage.regex {
    expression = ".*EventID=\"(4660|4663)\".*SubjectUserName=\"(?P<username>[^\"]+)\".*ObjectName=\"(?P<file>[^\"]+)\".*ObjectType=\"(?P<folder>[^\"]+)\".*Computer=\"(?P<hostname>[^\"]+)\".*IpAddress=\"(?P<ip_address>[^\"]+)\".*TimeCreated=\"(?P<timestamp>[^\"]+)\".*"
  }

  stage.labels {
    values = {
      file       = "file",
      folder     = "folder",
      hostname   = "hostname",
      ip_address = "ip_address",
      timestamp  = "timestamp",
      username   = "username",
    }
  }

  stage.timestamp {
    source = "timestamp"
    format = "RFC3339"
  }
}

loki.relabel "windows_event_logs" {
  forward_to = [loki.process.windows_event_logs.receiver]

  rule {
    source_labels = ["__name__"]
    target_label  = "__name__"
  }
}

loki.source.windowsevent "windows_event_logs" {
  eventlog_name          = "Security"
  xpath_query            = "*[System[(EventID=4660 or EventID=4663)]]"
  poll_interval          = "0s"
  use_incoming_timestamp = true
  forward_to             = [loki.relabel.windows_event_logs.receiver]
  labels                 = {
    job = "windows_event_logs",
  }
  legacy_bookmark_path = "./bookmark.xml"
}

loki.write "default" {
  endpoint {
    url = "http://192.168.1.2:3100/loki/api/v1/push"
  }
  external_labels = {}
}

Thank you.

Hello @hack3rcon,

The issue you're experiencing, where only Event ID 4663 is being sent, could be due to several factors. Here are a few things to check and consider:

  1. Event Log Content: Ensure that both Event IDs 4660 and 4663 are actually present in the Windows Event Log. If Event ID 4660 is not being logged or is less frequent, it might not appear in the output.

  2. Regex Expression: Your regex pattern seems correct for capturing both Event IDs 4660 and 4663. However, ensure that the events in the log match the structure expected by your regex. If the structure of Event ID 4660 logs differs significantly from Event ID 4663, the regex might not match.

  3. XPath Query: The xpath_query in your loki.source.windowsevent configuration is correctly set to capture both Event IDs. Double-check that the query is correctly formed and that the event log is being queried as expected.

  4. Log Processing: Check if there are any additional processing stages or filters in your pipeline that might be inadvertently filtering out Event ID 4660 logs. For example, ensure that no other stages are dropping or modifying logs in a way that excludes Event ID 4660.

  5. Bookmark Path: The legacy_bookmark_path is used to keep track of the last processed event. If there was an issue with the bookmark file, it might not be processing all events correctly. Try resetting or deleting the bookmark file to see if it changes the behavior.

  6. Debugging: Add some logging or debugging statements to your configuration to see what events are being processed at each stage. This can help identify where the filtering might be occurring.

If after checking these points the issue persists, consider simplifying the configuration to isolate the problem. For example, temporarily remove the regex stage to see if both Event IDs are being captured by the loki.source.windowsevent component.

Let me know if you need further assistance!

grot is still learning and improving, please let me know how I did by reacting below.

👍🏽 or 👎🏽

Both IDs are present in Event Logs and I removed the regex line, but problem is exist.

Hello @hack3rcon,

Since you've confirmed that both Event IDs 4660 and 4663 are present in the logs and removing the regex line didn't resolve the issue, let's explore a few more possibilities:

  1. Check the Bookmark File: The legacy_bookmark_path is crucial for tracking the last processed event. If this file is corrupted or not updating correctly, it might cause issues with event processing. Try deleting or resetting the bookmark file to ensure it starts fresh.

  2. Poll Interval: Your configuration sets poll_interval to "0s", which might cause issues with event polling. Consider setting it to a non-zero value like "3s" to ensure the events are being polled correctly.

  3. Event Log Permissions: Ensure that the service or user running the Grafana Agent has the necessary permissions to read from the Windows Event Log. Lack of permissions might prevent certain events from being read.

  4. Debugging Output: Enable more verbose logging in your Grafana Agent configuration to see if there are any errors or warnings that might indicate why Event ID 4660 is not being processed.

  5. Simplify Configuration: Temporarily simplify your configuration to the bare minimum to isolate the issue. For example, remove all processing stages and just log the raw events to see if both Event IDs are captured.

  6. Check for Errors in Logs: Look at the logs of the Grafana Agent for any errors or warnings that might indicate why Event ID 4660 is not being processed.

If none of these steps resolve the issue, consider testing with a different set of Event IDs to see if the problem persists, which might help identify if the issue is specific to these Event IDs or a broader configuration problem.

Let me know if you need further assistance!

grot is still learning and improving, please let me know how I did by reacting below.

👍🏽 or 👎🏽

Please rewrite it.

Hello @hack3rcon,

Let's try to address the issue where only Event ID 4663 is being sent, even though both Event IDs 4660 and 4663 are present in your Windows Event Logs. Here are some steps and considerations to help troubleshoot and resolve the problem:

  1. Verify Event Log Content: Double-check that both Event IDs 4660 and 4663 are indeed present in the Windows Event Log. You can do this by manually inspecting the logs using the Windows Event Viewer.

  2. Bookmark File: The legacy_bookmark_path is used to track the last processed event. If this file is not updating correctly or is corrupted, it might cause issues. Try deleting or resetting the bookmark file to ensure it starts fresh and processes all events.

  3. Poll Interval: Your configuration sets poll_interval to "0s", which might not be ideal for event polling. Set it to a non-zero value like "3s" to ensure events are being polled correctly.

  4. Permissions: Ensure that the Grafana Agent has the necessary permissions to read from the Windows Event Log. Lack of permissions might prevent certain events from being read.

  5. Debugging and Logging: Enable verbose logging in your Grafana Agent configuration to capture more detailed information. This can help identify any errors or warnings that might indicate why Event ID 4660 is not being processed.

  6. Simplify Configuration: Temporarily simplify your configuration to isolate the issue. Remove all processing stages and just log the raw events to see if both Event IDs are captured. This can help determine if the issue is with the event capture or the processing stages.

  7. Check for Errors: Review the logs of the Grafana Agent for any errors or warnings that might indicate why Event ID 4660 is not being processed.

  8. Test with Different Event IDs: If the issue persists, try testing with a different set of Event IDs to see if the problem is specific to these Event IDs or a broader configuration issue.

By following these steps, you should be able to identify and resolve the issue. If you continue to experience problems, please provide additional details or logs, and I'll be happy to assist further.

Let me know if you need more help!

grot is still learning and improving, please let me know how I did by reacting below.

👍🏽 or 👎🏽

Multiple event IDs might signal several problems occurring at one go, and it might become very challenging to pinpoint the one main cause. Careful review of all event logs helps identify patterns and solve problems efficiently.

Hello @hack3rcon,

It seems like you're still facing issues with only Event ID 4663 being sent, despite both Event IDs 4660 and 4663 being present in your Windows Event Logs. Let's try to address this with a more focused approach:

  1. Verify Event Log Content: Since you've confirmed both Event IDs are present, ensure that the logs for Event ID 4660 are not being filtered out due to any specific conditions or differences in their structure compared to Event ID 4663.

  2. Bookmark File: The legacy_bookmark_path is crucial for tracking the last processed event. If this file is not updating correctly or is corrupted, it might cause issues. Try deleting or resetting the bookmark file to ensure it starts fresh and processes all events.

  3. Poll Interval: Your configuration sets poll_interval to "0s", which might not be ideal for event polling. Set it to a non-zero value like "3s" to ensure events are being polled correctly.

  4. Permissions: Ensure that the Grafana Agent has the necessary permissions to read from the Windows Event Log. Lack of permissions might prevent certain events from being read.

  5. Debugging and Logging: Enable verbose logging in your Grafana Agent configuration to capture more detailed information. This can help identify any errors or warnings that might indicate why Event ID 4660 is not being processed.

  6. Simplify Configuration: Temporarily simplify your configuration to isolate the issue. Remove all processing stages and just log the raw events to see if both Event IDs are captured. This can help determine if the issue is with the event capture or the processing stages.

  7. Check for Errors: Review the logs of the Grafana Agent for any errors or warnings that might indicate why Event ID 4660 is not being processed.

  8. Test with Different Event IDs: If the issue persists, try testing with a different set of Event IDs to see if the problem is specific to these Event IDs or a broader configuration issue.

By following these steps, you should be able to identify and resolve the issue. If you continue to experience problems, please provide additional details or logs, and I'll be happy to assist further.

Let me know if you need more help!

grot is still learning and improving, please let me know how I did by reacting below.

👍🏽 or 👎🏽

Hello,
What is the solution? I need both ID 4660 and 4663 to get the information I need. Unfortunately, I could not find an example of a configuration file on the Internet that would do it.