Using RegEx in a Panel Query

I have a query variable that returns a list of Fargate instances that are running. The user is allowed to select any number of them or select ALL. This works great.

However, I have another ElasticSearch index that uses a different format for instances. I have created a regex that changes strips off the AWS domain info and returns only the IP address prefixed with “ip-”.

Here is the regex for that which I am using in another query variable: /(ip-\d{1,3}-\d{1,3}-\d{1,3}-\d{1,3})/

In my panels, I’d like to use the Instances variable. The value of the Instances format needs to be “scrubbed” using the Regex above. I can seem to find out how to do this in panel query.

I am using the Instance variable in a query like this:

fields.Application:${Collection}.${Application} AND
fields.Environment:$Environment AND
host.hostname:$Instances

Now, because I am using another ElasticSearch index, which needs to have the Instance variable “scrubbed” I am wondering how I can call the regex inline in the query. For example:

fields.Application:${Collection}.${Application} AND
fields.Environment:$Environment AND
fields.MachineName:Regex($Instances,"/(ip-\d{1,3}-\d{1,3}-\d{1,3}-\d{1,3})/")

Is this possible?

This topic was automatically closed after 365 days. New replies are no longer allowed.