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 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>..."
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. For tracking down connection issues, I'd like to be able to log which drillbit is being used from the application, rather than have to grep logfiles.
Don’t forget that you can ask these questions directly to the Apache Drill community on the drill mailing lists or slack channels. See https://drill.apache.org/community-resources/ for more details.
Specific to your question, check out the system tables (https://drill.apache.org/docs/querying-system-tables/). The sys.profiles_json table, in particular, seems to be the one that is likely to give you the information you need.
It is a generally pretty safe bet that if you can see the information that you need in the web interface for Drill that you will also be able to find that information in the system tables. Commonly, a quick scan of the docs and some trial queries will give you the info you need. Since the web interface is open source, you can also grovel the source code to figure out how the web interface gives you the pertinent info.
In particular, this query gives roughly what you are asking for:
with t1 as (
select convert_from(x.json, 'JSON') js from sys.profiles_json x
)
select t1.js.queryId id, t1.js.foreman.address foreman, t1.js.query query
from t1
limit 3