How to extract the uri path and the param from the uri

I want to extract the uri path and the param from the uri. There are two forms of the uri, one with params and one without.

Here is the examples of the uri

/sentence_func?key=23872323232
/bot_recognize

I use this pattern to match the uri
%{URIPATH:uri_path}(?:%{URIPARAM:param})|%{URIPATH:uri_path}

But there are two results in the uri_path with the GROK DEBUGGER. I don't want the null be in the output.

{
  "uri_path": [
    "/sentence_func",
    null
  ],
  "param": [
    "?key=23872323232"
  ]
}

Or like this output

{
  "uri_path": [
    null,
    "/bot_recognize"
  ],
  "param": [
    null
  ]
}

How can I remove the redundant result?

I used %{URIPATH:uri}(%{URIPARAM})? to get the desired result.

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