We want an alarm_enrichment rule to lookup the device details in our CMDB based on the short name / hostname and not the FQDN.
The trouble is the source alarm contains the FQDN and the CMDB contains the short name / hostname.
In the "nas" Raw Configure, there is a parameter: "lookup_by_regexp".
Using a regex like "(^.*(?=(\.)))" to pull the hostname did not work.
UIM any Version
MS SQL Server DBMS
The "lookup_by_regexp" is a filter and not a substitution parameter for the CMDB database query.
Another option would be to create a function on the cmdb database to manipulate the search parameter.
For example:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
USE [cmdb]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].getHostName(@string varchar(8000))
RETURNS varchar(8000) AS
BEGIN
RETURN SUBSTRING(@string, 1, CHARINDEX('.', @string) - 1)
END
GO
So, a query like this:
select name,sla_level,description,ip,os_type,origin from cm_computer_system where name = dbo.getHostName('servername.company.com')
would return rows where name = 'servername'.
The next step would be to modify the cmdb query in the "nas" Raw Configure.
For example:
select name,sla_level,description,ip,os_type,origin from cm_computer_system where name = dbo.getHostName(?)
So, the '?' gets replaced by the search parameter.