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!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

Data Management Digest – May 2026

Welcome to the May 2026 edition of Data Management Digest!   As your trusted partner in data innovation, the ...