I manage this by applying regex.
For this, the filters on the metric must use the operator =~ like:
external_sql_connection_monitor{environment=~"$environment", tenantId=~"$tenantId", internalName=~"$internalName"}
Now configure the Custom all value for the variable, with: .+
It worked like a charm