Issue with Filtering Paths Using Regex in Grafana and Elasticsearch

Hi!

Im trying to split some Elasticsearch values (jenkins jobs dir paths) into variables, so I can filter by job the dashboard.

The structure of the field is: DSI/enviroment/folder_1/folder_2/job.

So, I have different combinations

For example (not real paths):

DSI/dev/monitoring/alerts/teams_webhook
DSI/pre/monitoring/alerts/teams_webhook
DSI/pro/monitoring/triggers/cpu_load_fix
DSI/dev/programming/....
.
.

So, I want to get the following variables

-Enviroment
-Folder_1
-Folder_2
-Job

To get these variables, I’m combining term queries to filter each path as I select variables (this works incorrectly) and regex (to get the exact word between the /).

(data.buildVariables.JOB_NAME =~ data.fullProjectName.keyword)

To get the Enviroment I use:

To get the other variables I use:

I just change the query (adding the previous value) and the {1} vallue, by {2} and {3} to get the other positions.

As I mentioned earlier, the issue is that sometimes, when I select the variables and reach Job, instead of filtering properly, it returns all the available Job Names. I think this is because of how Grafana escapes the / characters to query Elasticsearch.
No matter what I change, I can’t seem to resolve it.

Thanks in advance for any help or suggestions!

Hi, anyone knows how to do this? Im not getting it…

UP. Still with this problem…

The variables you posted do not match the sample data you provided,can you show examples based on the mock paths you provided

Hello ,

The variables are an example and it doesn’t have much to do with the real problem…

As far as I have been able to see the problem is in picking up the field as keyword.
In the index, the rootFullProjectName and fullProjectName fields (they have the same values) are both keyword and text type. However, in the Grafana variables only let me get the values if I put .keyword, if I put nothing or put .text I get nothing.

I need the Text type to make a query without the field name being identical, that is to say flexible queries.

so from your not real path example

DSI/dev/monitoring/alerts/teams_webhook
DSI/pre/monitoring/alerts/teams_webhook
DSI/pro/monitoring/triggers/cpu_load_fix
DSI/dev/programming/....

what would be the expected result

Hi,

I have realized that the real problem is that I can’t get the partial filtering or regex filtering that I use later on other variables to work for fields that are of type keyword. Therefore, I have to get my fullProjectName variable of type text. But I get nothing.

Elastic field type:

:white_check_mark: Grafana → OK getting the keyword field:

:cross_mark: Grafana → No OK getting the text field: