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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...