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

VCenter Parser: Hostname not being extracted #11642

Open
kevintamlsWork opened this issue Jan 8, 2025 · 4 comments
Open

VCenter Parser: Hostname not being extracted #11642

kevintamlsWork opened this issue Jan 8, 2025 · 4 comments
Assignees
Labels
Parser Parser specialty review needed

Comments

@kevintamlsWork
Copy link

Describe the bug
The vCenter parser does not extract the hostname of the vCenter Syslog.

To Reproduce
Steps to reproduce the behavior:

  1. Execute KQL search
    vCenterV2
  2. See error

Expected behavior
Hostname (in the example below, VDIVCSA-P-01-01) should be extracted with a field name "Hostname"

Screenshots
Image

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser: Google Chrome
  • Version: 131.0.6778.205

Additional context
We have had a modified version of the parser provided from issue#11542. If any modifications are required, please use the latest version of the modified parser from that issue.

Modified Parser Code

 let vCenter_Login =() {
        vcenter_CL
        | where Message has ("UserLoginSessionEvent")
        | parse Message with * "Event [" EventId:string "] [1-1] [" EventTime:datetime "] [" EventType:string "] [" EventSeverity "]" * "[User " DomainName:string "\\" Username:string "@" SourceIP " logged in as " UserAgent:string "]" *
        | extend DomainName = iff(isnull(DomainName), "", DomainName)
        | extend Username = iff(isnull(Username), DomainName, Username)
        | parse Message with * "Event [" EventId:string "] [1-1] [" EventTime:datetime "] [" EventType:string "] [" EventSeverity "]" * "[User " Username:string "@" SourceIP " logged in as " UserAgent:string "]" *
        | extend Username = iff(isnull(Username), DomainName, Username)
    };
    let vCenter_Logout =() {
        vcenter_CL
        | where Message has ("UserLogoutSessionEvent")
        | parse Message with * "Event [" EventId:string "] [1-1] [" EventTime:datetime "] [" EventType:string "] [" EventSeverity "]" * "[User " DomainName:string "\\" Username:string "@" SourceIP " logged out (login time:" LoginTime:string ", number of API invocations: " APIInvocationCount:dynamic ", user agent:" UserAgent:string ")]" *
        | extend DomainName = iff(isnull(DomainName), "", DomainName)
        | extend Username = iff(isnull(Username), DomainName, Username)
        | parse Message with * "Event [" EventId:string "] [1-1] [" EventTime:datetime "] [" EventType:string "] [" EventSeverity "]" * "[User " Username:string "@" SourceIP " logged out (login time:" LoginTime:string ", number of API invocations: " APIInvocationCount:dynamic ", user agent:" UserAgent:string ")]" *
        | extend Username = iff(isnull(Username), DomainName, Username)
    };
    let vCenter_Role=() {
        vcenter_CL
        | where Message has_any("RoleAddedEvent","RoleRemovedEvent")
        | parse Message with * " " * " " Hostname:string "vpxd" * "Event [" EventId:string "] [1-1] [" EventTime:datetime "] [" EventType:string "] [" EventSeverity:string "]" * "[New role " RoleName:string " " Operation:string  "]" *
    };
    let vCenter_RoleModified=() {
        vcenter_CL
        | where Message has ("RoleUpdatedEvent")
        | parse Message with * " " * " " Hostname:string "vpxd" * "Event [" EventId:string "] [1-1] [" EventTime:datetime "] [" EventType:string "] [" EventSeverity:string "]" * "Previous name: " OldRoleName:string ", new name "NewRoleName:string " Added privileges: " AddedPriviledges:string " Removed privileges: " RemovedPriviledges:string "]" *
    };
    union vCenter_Login,vCenter_Logout,vCenter_Role,vCenter_RoleModified
    | extend ClientIP = SourceIP

Syslog Message Example

Jan 8 11:56:13 VDIVCSA-P-01-01 vpxd[7058] Event [50736315] [1-1] [2025-01-08T11:56:13.977736Z] [vim.event.UserLogoutSessionEvent] [info] [VDIP.LOCAL\Administrator] [] [50736315] [User VDIP.LOCAL\[email protected] logged out (login time: Wednesday, 08 January, 2025 11:56:13 AM, number of API invocations: 1, user agent: Apache-CXF/3.4.10)]
@v-sudkharat v-sudkharat added the Parser Parser specialty review needed label Jan 9, 2025
@v-sudkharat
Copy link
Contributor

Hi @kevintamlsWork, Thanks for flagging this issue, we will investigate this issue and get back to you with some updates. Thanks!

@v-sudkharat
Copy link
Contributor

@kevintamlsWork, Updated the Parser by adding the Hostname in it, Could you please test and let us know is it working for you :


 let vCenter_Login =() {
        vcenter_CL
        | where Message has ("UserLoginSessionEvent")
        | parse Message with * " " * " " * " " Hostname:string "vpxd" * "Event [" EventId:string "] [1-1] [" EventTime:datetime "] [" EventType:string "] [" EventSeverity "]" * "[User " DomainName:string "\\" Username:string "@" SourceIP " logged in as " UserAgent:string "]" *
        | extend DomainName = iff(isnull(DomainName), "", DomainName)
        | extend Username = iff(isnull(Username), DomainName, Username)
        | parse Message with * " " * " " * " " Hostname:string "vpxd" *  "Event [" EventId:string "] [1-1] [" EventTime:datetime "] [" EventType:string "] [" EventSeverity "]" * "[User " Username:string "@" SourceIP " logged in as " UserAgent:string "]" *
        | extend Username = iff(isnull(Username), DomainName, Username)
    };
    let vCenter_Logout =() {
        vcenter_CL
        | where Message has ("UserLogoutSessionEvent")
        | parse Message with * " " * " " * " " Hostname:string "vpxd" * "Event [" EventId:string "] [1-1] [" EventTime:datetime "] [" EventType:string "] [" EventSeverity "]" * "[User " DomainName:string "\\" Username:string "@" SourceIP " logged out (login time:" LoginTime:string ", number of API invocations: " APIInvocationCount:dynamic ", user agent:" UserAgent:string ")]" *
        | extend DomainName = iff(isnull(DomainName), "", DomainName)
        | extend Username = iff(isnull(Username), DomainName, Username)
        | parse Message with * " " * " " * " " Hostname:string "vpxd" *  "Event [" EventId:string "] [1-1] [" EventTime:datetime "] [" EventType:string "] [" EventSeverity "]" * "[User " Username:string "@" SourceIP " logged out (login time:" LoginTime:string ", number of API invocations: " APIInvocationCount:dynamic ", user agent:" UserAgent:string ")]" *
        | extend Username = iff(isnull(Username), DomainName, Username)
    };
    let vCenter_Role=() {
        vcenter_CL
        | where Message has_any("RoleAddedEvent","RoleRemovedEvent")
        | parse Message with * " " * " " * " " Hostname:string "vpxd" *  "Event [" EventId:string "] [1-1] [" EventTime:datetime "] [" EventType:string "] [" EventSeverity:string "]" * "[New role " RoleName:string " " Operation:string  "]" *
    };
    let vCenter_RoleModified=() {
        vcenter_CL
        | where Message has ("RoleUpdatedEvent")
        | parse Message with * " " * " " * " " Hostname:string "vpxd" *  "Event [" EventId:string "] [1-1] [" EventTime:datetime "] [" EventType:string "] [" EventSeverity:string "]" * "Previous name: " OldRoleName:string ", new name "NewRoleName:string " Added privileges: " AddedPriviledges:string " Removed privileges: " RemovedPriviledges:string "]" *
    };
    union vCenter_Login,vCenter_Logout,vCenter_Role,vCenter_RoleModified
    | extend ClientIP = SourceIP

Thanks!

@kevintamlsWork
Copy link
Author

@v-sudkharat Working well for most events, except for selected events in the form.

Jan 15 10:25:12 10.174.7.138 192.168.21.138 1 2025-01-15T10:25:12.099386+00:00 extserv-vc-01 vpxd 6331 - - Event [4100669] [1-1] [2025-01-15T10:25:12.097588Z] [vim.event.UserLoginSessionEvent] [info] [VSPHERE.EXTSERV.LOCAL\vpxd-extension-88bd2731-10b0-4902-8133-717424793612] [] [4100669] [User VSPHERE.EXTSERV.LOCAL\[email protected] logged in as cl/1.0.0]

Working fine log format:

Jan 15 10:29:52 CR1VAVC vpxd[7332] Event [292530013] [1-1] [2025-01-15T10:29:52.86856Z] [vim.event.UserLoginSessionEvent] [info] [XXX\s_VMC_HCXAdmin] [] [292530013] [User XXX\[email protected] logged in as ]

The parser is capturing everything after the initial timestamp as the hostname, where expected behaviour is to capture the string value before "vpxd". In this case, it's "extserv-vc-01".

Screenshot:

Image

@v-sudkharat
Copy link
Contributor

@kevintamlsWork, actually, the RAW message format you shared is different from the following formats:
Jan 15 10:25:12 10.174.7.138 192.168.21.138 1 2025-01-15T10:25:12.099386+00:00 extserv-vc-01 vpxd 6331 - - Event [4100669] [1-1] [2025-01-15T10:25:12.097588Z] [vim.event.UserLoginSessionEvent] [info] [VSPHERE.EXTSERV.LOCAL\vpxd-extension-88bd2731-10b0-4902-8133-717424793612] [] [4100669] [User VSPHERE.EXTSERV.LOCAL\[email protected] logged in as cl/1.0.0]

is in a different format compared to the following:

a. Jan 15 10:29:52 CR1VAVC vpxd[7332] Event [292530013] [1-1] [2025-01-15T10:29:52.86856Z] [vim.event.UserLoginSessionEvent] [info] [XXX\s_VMC_HCXAdmin] [] [292530013] [User XXX\[email protected] logged in as ]

b. Jan 8 11:56:13 VDIVCSA-P-01-01 vpxd[7058] Event [50736315] [1-1] [2025-01-08T11:56:13.977736Z] [vim.event.UserLogoutSessionEvent] [info] [VDIP.LOCAL\Administrator] [] [50736315] [User VDIP.LOCAL\[email protected] logged out (login time: Wednesday, 08 January, 2025 11:56:13 AM, number of API invocations: 1, user agent: Apache-CXF/3.4.10)]

We checked the RAW message format of A and B to extract the hostname, which is located after the Date & Timestamp in the third position of the RAW message (e.g., Jan 8 11:56:13 VDIVCSA-P-01-01). In the recent RAW message, the IP addresses are added before the hostname along with the timestamp values. This inconsistency is causing the parser to fail in extracting the correct hostname field.

It appears that in the recent RAW message, from the Date & Timestamp (e.g., Jan 15 10:25:12) to the Hostname (e.g., extserv-vc-01), the format is inconsistent for the parser. As a result, the parser is mistakenly identifying the IPs (10.174.7.138 192.168.21.138) and timestamp values (2025-01-15T10:25:12.099386+00:00) as part of the hostname.

So, if we proceed with making changes to extract the hostname from the RAW message :

Jan 15 10:25:12 10.174.7.138 192.168.21.138 1 2025-01-15T10:25:12.099386+00:00 extserv-vc-01 vpxd 6331 - - Event [4100669] [1-1] [2025-01-15T10:25:12.097588Z] [vim.event.UserLoginSessionEvent] [info] [VSPHERE.EXTSERV.LOCAL\vpxd-extension-88bd2731-10b0-4902-8133-717424793612] [] [4100669] [User VSPHERE.EXTSERV.LOCAL\[email protected] logged in as cl/1.0.0]

then the parser may fail to extract the hostname from the following raw message format:

Jan 15 10:29:52 CR1VAVC vpxd[7332] Event [292530013] [1-1] [2025-01-15T10:29:52.86856Z] [vim.event.UserLoginSessionEvent] [info] [XXX\s_VMC_HCXAdmin] [] [292530013] [User XXX\[email protected] logged in as ]

Hope this information helps. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Parser Parser specialty review needed
Projects
None yet
Development

No branches or pull requests

3 participants