Is it InfluxDB datasource or custom datasource? Alerts support

We have InfluxDB datasource, but with custom data endpoint (because of our database structure - we have more databases so the query from grafana is translated by the endpoint and then the proper database is queried again). Alerts are not working for us (401 - unauthorized).

But when we setup InfluxDB datasource directly to one of the databases, alerts are working as expected. We use Oauth forwarding in our custom endpoint setup.

I investigated queries and HTTP request/reponses and found differences in cookies in response and there is one of tokens (from gravitee API which makes endpoint) missing in non working setup. Do you think is it possible to setup our custom endpoint to work with alerts? (because it is InfluxDB where alerts should be supported). Are there any documented requirements for query endpoint to support alerts? (note that the datasource works for normal data queries but not for alerts). Or do we need to write our own backend plugin to support alerts, because our custom endpoint for influxDB makes this datasource a custom datasource? I have noticed there is now possibility to write custom datasource backend plugin for alerts support.