简体   繁体   中英

Using Splunk rex to extract String from logs

From splunk logs,how can I get a count of all those methods whose Time taken is > 10ms?
Splunk logs which look some thing like this :

csmcadvice.ExecutionTimeAdvice : <> relationId = aa12 | Method Name = methodA() Time taken is = 0ms

csmcadvice.ExecutionTimeAdvice : <> relationId = ab12 | Method Name = methodA(). Time taken is = 15ms

csmcadvice.ExecutionTimeAdvice : <> relationId = ab12 | Method Name = methodB(). Time taken is = 1ms

This would be the general idea:

| rex field=_raw "Method Name = (?<methodName>\w*)\(\)"
| rex field=_raw "Time taken is = (?<duration>\d*)ms"
| where duration > 10
| stats count by methodName

Within your search, you will need to

  1. Create a rex field to grab the method name
  2. Create a rex field to grab the duration in milliseconds
  3. Use the where command to filter the results to where your new "duration" field > 10ms
  4. Use the stats command with count by to count the current results, binning by your new "methodName" field

If this is not exactly correct for your logs, it should at least get you very close.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM