How to add Regex to a TextBox Variable and use it inside a Query to visualize data from Elasticsearch

ok let’s try this approach if you are willing, instead of elastic search datasource you can try using infinity plugin that gives you more flexibility on what you are trying to do with modifying things as you want to.

1 Like

I’ll try the infinity plugin!!
I’ll keep posted here about my progress.

Appreciate everyone’s help, thanks a ton!

check this thread out.

and others like it that deal with elastic search and infinity. You can also leverage Dynamic Text to make your es endpoint calls via fetch. etc

1 Like

And another one

Here it is with opensearch I spun up with sample data flight

Continuing this thread. So @roleyroley did you try the above approach and did it not work for you? if you do not want to use the above recommendation or it did not work for you, from your Serial Number what part of it do you want to extract and concatenate

Installing the plugin is going to take some time by admins(unfortunately I am not authorized to install anything new) -

I am trying to find a workaround until then. I saw this page Variable syntax | Grafana documentation

Which gives a brief about how to use variables with regex - any idea on how I can structure my query using this info?

1 Like

Since you are trying to do conditional formatting of the $SerialID, I am not sure you can accomplish that other than using something else. imo

Also I do not see this approach documented ${SerialID:substring(5.9)} Can you point us to where you got this?

This approach is not documented - This is something I would like to try out or hope to achieve. I’m sorry if it was misleading.

1 Like

not misleading, it was just in case I missed some new feature.

Hi @yosiasz ,

some updates - I configured the Infinity Data source plugin and tried a query on the Jsonata Excercizer to filter out the results - https://try.jsonata.org/I71uy_vY7

The problem I’m facing right now is that this query doesnt visualize the result in my dashbaord.

Query:

The Response seems to return all the objects in the test data:

Do you happen to know where I could be going wrong?

The solution to the above substring problem is:

parse-json
  scope "hits.hits"
  jsonata "*[_id=$string($substring('${BSN_Long}',5,4)&$substring('${BSN_Long}',11,4))][]"
2 Likes