Elasticsearch API dashboard issues

Grafana version: 7.2

I am trying to build a dashboard for a bunch of apis giving response time , success rate , no of hits …
The datasource for this dashboard would be elasticsearch.

The only way to differentiate apis would be through a field called as “request” in the logs which gives me the request endpoint.

I am going to have the same set of 7 panels for each api endpoint , so i wanted to have a variable which gives me the endpoints and then i can repeat the panels.

I faced some issues while setting up these variables because they vary a lot .
For eg : some apis are in this format

/name1/name2/id?query params

For this i just used a regex filter to get just /name1/name2/ and then in the query i used $api*

But there are some apis which has a variable id in the middle , for eg

/name1/id/name2?queryparams

I am not sure how i could use a regex to get a generic endpoint and then how i could use that in a query?

One option that would be easy is to a variable which is a regex

For eg : the variable should store values like
/name1/ /name2
/name1/name2/

And then i use this variable which substitutes to a regex in the query , i tried this with custom variables but it didnt work out , is this even possible?? Let me know if you guys can think of any other way of achieving this

Are these api paths dynamic or static

yes the id field in the api endpoint can vary and the endpoint can be either of the two formats

  1. /name1/name2/{id} (for this i used regex to remove the id part so the variable will just store /name1/name2 and in the es query i use request: $variable*)
  2. /name1/{id}/name2 (this is a bit tricky for variables , if it was possible for variables to store a custom regex then it would have been pretty staight forward, but was not able to make this work)