Mark,

That's a great trick to grep for a unique string in the query!

You don't have to grep logs, however, when you can grep the profiles or 
profiles_json system table for the same information. That grepping is simple 
enough to do in SQL, so you should be good to go.

On 2021/06/26 20:28:26, Mark Rajcok <mraj...@gmail.com> wrote: 
> I'm using a zookeeper connection string to get a connection to a drill
> cluster. I would like to log which drillbit (hostname or IP address) I
> successfully connected to, but I can't find any property or method on
> the java.sql.Connection
> class <https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html>
> to get this information.
> 
> I tried connection.getMetaData.getURL, but that just returns the zookeeper
> connection string I used to get the connection (scala code below):
> import java.sql._
> Class.forName("com.mapr.drill.jdbc41.Driver")
> val con =
> DriverManager.getConnection("jdbc:drill:zk=<server1>:5181,<server2>:5181/drill/<cluster_name>...")
> con.getMetaData().getURL()  // returns "jdbc:drill:zk=<server1>...", so not
> what I'm looking for
> val st  = con.createStatement()
> val res = st.executeQuery("select *,'findme' from sys.drillbits")
> while(res.next()) { println(res.getString(1)) }
> 
> If I "grep" the drillbit_queries.json logs on all of the drillbit servers
> for "findme", I can find which drillbit was used to execute the query, and
> hence which drillbit I'm currently connected to. For tracking down
> connection issues, however, I'd like to be able to log which drillbit is
> being used from the application, rather than have to grep logfiles.
> 
> This question is also posted on StackOverflow:
> https://stackoverflow.com/questions/68042577/how-to-determine-which-apache-drill-drillbit-was-selected-when-connecting-via-zo
> 

Reply via email to