chop-dbhi / prometheus-sql

Service that exposes Prometheus metrics for a SQL result set.
BSD 2-Clause "Simplified" License
202 stars 55 forks source link

Multiple addresses? #30

Closed PaulWalkerUK closed 7 years ago

PaulWalkerUK commented 7 years ago

I normally use the following connection details in my tnsnames.ora file to connect to an Oracle database. The database will only be active on one of the addresses and I guess the Oracle client just tries them in turn until it finds the right one (I don't know how it actually works in the background 😄).

I've got Prometheus-SQL working by specifying a single address, but if the database is switched over to one of the other servers, I have to manually update the config. Is there any way to specify multiple addresses in the Prometheus-SQL config in a similar way?

An example of my TNS connection would be:

CONNECTION_NAME=
    (DESCRIPTION=
        (ADDRESS_LIST=
            (ADDRESS=(PROTOCOL=TCP)(HOST=server1)(PORT=1523))
            (ADDRESS=(PROTOCOL=TCP)(HOST=server2)(PORT=1521))
            (ADDRESS=(PROTOCOL=TCP)(HOST=server3)(PORT=1521))
        )
        (CONNECT_DATA=(SERVICE_NAME=DB_SERVICE_NAME))
    )
bruth commented 7 years ago

There is a pending feature noted in #23 which will supports hot-reloading configuration and queries. So one approach could be to dynamically update the config (depending on how often these connections change).

Another option would be to list a set of connections to try in the configuration, basically enumerating until one works.

Another option that would be done on your end is to put some kind of load balancer/DNS/service discovery thing in front that handles the changing server and the configuration simply points to that persistent address.

PaulWalkerUK commented 7 years ago

OK, thanks, I'll look into those options