Getting Data In

To create a field from the csv data

Paul_tcs
Explorer

Hi Xperts,

I Need to create a field which displays hostnames with the following data,

1

1568    *NAIT US ICC Tibco Hawk Alerts  24/03/13 08:47  STOPPED :: BW Engine AFSDailyAndInitialLoad-A-550BwProcess-1911-14743 on ncdap-prd1911  Loanpath    Alert   High    00:15

11569   *NAIT US ICC Tibco Hawk Alerts  24/03/13 08:47  STOPPED :: BW Engine NAIT_AFS_BookingInterface-C-LP_AFS_BookingInterface_RequestMessage-1911-14743 on ncdap-prd1911 Loanpath    Alert   High    00:15

11570   *NAIT US ICC Tibco Hawk Alerts  24/03/13 08:47  STOPPED :: BW Engine IMPACS-C-IMPACS_LoanBooking_ReqRep-1911-14743 on ncdap-prd1911 Loanpath    Alert   High    00:15

11571   *NAIT US ICC Tibco Hawk Alerts  24/03/13 08:47  STOPPED :: BW Engine ICV_Customer_Interface-B-ICV_Get_Customer_Request-1911-14743 on ncdap-prd1914  Loanpath    Alert   High    00:15

11572   *NAIT US ICC Tibco Hawk Alerts  24/03/13 08:47  STOPPED :: BW Engine NAIT_AFS_BookingInterface-C-AFS_LP_BookingInterface_ResponseMessage-1911-14743 on ncdap-prd1921    Loanpath    Alert   High    00:15

in the above code, term staes with "ncdap-prd1911" "ncdap-prd1914" are nodes, i want to create a field "hostname" under which i want these nodes to filtered. How to proceed this.

Regards,
Paul

Tags (2)
0 Karma

lguinn2
Legend

Here is the discussion in the manual of how to add fields at search time. In Splunk, this is called field extraction.
You may want to create a "permanent" field extraction using the Interactive Field Extractor.
If you want to create a field on the fly, during a search, you could do this:

yoursearchhere
| rex "\son\s*(?<hostname>ncdap\S+)"
| stats count by hostname

I just gave the stats command as one example of what you can do. But, if you just want to filter the data, you don't need fields at all

yoursearchhere NOT "ncdap-prd1911" NOT "ncdap-prd1914"

assuming that "ncdap-prd1911" "ncdap-prd1914" does not appear anywhere else in the event text.

lguinn2
Legend

yoursearchhere
| rex "\son\s*(?<hostname>ncdap\S+)"
| stats count by hostname

should work. This will extract all of the hostnames in the log, if you replace the first line with a general query like sourcetype=ZZZZ where ZZZZ is the sourcetype of the data.

If you want to see the events, but only certain fields, you can do this

yoursearchhere
| rex "\son\s*(?<hostname>ncdap\S+)"
| table hostname

You could also filter like this

yoursearchhere
| rex "\son\s*(?<hostname>ncdap\S+)"
| where hostname="ncdap-prd1911" OR hostname="ncdap-prd1914"
| stats count by hostname

0 Karma

Paul_tcs
Explorer

any help on this?

0 Karma

Paul_tcs
Explorer

thanks a lot for your reply,

here when am giving this rex, this display four host which am mentioned in the sample query. consider that am having many hostname in the log, how to extract the same.

Also, i see one field hostname has been created when i view he contents, i see complete line of the log

ncdap-prd1911 Loanpath Alert High 00:15

instead i need only

ncdap-prd1911

how to achieve this.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...

SplunkTrust Application Period is Officially OPEN!

It's that time, folks! The application/nomination period for the 2026-2027 SplunkTrust is officially open. If ...