User Tools

Site Tools


nms:splunk

This is an old revision of the document!


SPLUNK

Regular expresions perl
Create searches. Ad hoc: http://docs.splunk.com/Documentation/Splunk/5.0/Search/Aboutcustomsearchcommands http://docs.splunk.com/Documentation/Splunk/6.0.1/Search/Whatsinthismanual

Commands:

regex:
convert
eval
extract (kv)
fields
lookup (if not local=t)
mvexpand
multikv
rename
regex : Removes or keeps results that match the specified regular expression(streamingly). …

| regex _raw="(?=!\d)10\.\d{1,3}\.\d{1,3}\.\d{1,3}(?!\d)" (this is from the field _raw)


replace rex : string replacement and character substitution. search strcat tagstyper.

Examples: Creates a new field called 'test' taking as key “Error adding limit institutionId:”. Then it deduplicates all the members of the field and sorts them up

source="ParFX-PRD-Env" host="l52prdsrv-mds1.pure.local" error | rex field=_raw "Error adding limit institutionId: (?<test>.*)" | dedup test | sort test

EXTRACT, ORDER & TABULATE FIELDS

To extract fields that are not automatically detected:

  1. Search. Select Source of interest, for example:
     source="network" 
  2. Make a sample search contained log entries with the fields we want to extract
  3. Click on the small square box with an arrow which are in each the log entries and select extract fields
  4. Fill up the text box “Example values for a field:” with some examples of the field you want to extract and click “Generate”
  5. We can click in test, this will generate a simple table with the count and percentage of that field.
index=main host="l52eatfwl-edge1" PROD-DMS created | rex field=_raw "session created (?P<test>\\d+\\.\\d+\\.\\d+\\.\\d+)(?=/)" | dedup test | sort test | table test 
nms/splunk.1434660211.txt.gz · Last modified: (external edit)