Split FQDN

I'm trying to split an FQDN to get the base server name. Currently, the FQDN is stored in "server", so I'd like to split "server" on "." and get the name.
Additionally, sometimes the server may not be the FQDN, so it'd be useful if this would work regardless of whether the server field was an FQDN or not.

Has anyone had any experience doing this?

There are plenty of solutions in the community posts.

With Split

With Grok

Another Grok sample

That first one worked for me, and while I haven't tested it yet I've wrapped it in an if else to check if there is a . in the "server" field before it bothers splitting it.