Trimming the URI Path from end

(Satish Kumar) #1

Hi All,

I am new to logstash, I am working on creating visualization of top API based on AWS ELB logs, and i am stucked at this point where i need to trim URIPath.

example request:

Actual URIPATH: "/test/v1/api/006b2511-b009-11e8-b30f-0165a332b61d"

I am looking for parsing logic so that after parsing URI path should come like this.

URIPATH: "/test/v1/api"

I have given example for one scenairo, but we have multiple api's and last section of URIPATH is different in length.

For example:

Please guide me how to trim URIPATH from end upto '/'


(Magnus B├Ąck) #2

You can e.g. use a mutate filter's gsub option to replace the protocol and hostname (and optionally port) with an empty string. A regexp like ^https?://[^/]+ would do.

(Satish Kumar) #3

thanks magnus, i will try this out and check if it works for my scenario

(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.