albertodonato / query-exporter

Export Prometheus metrics from SQL queries
GNU General Public License v3.0
435 stars 101 forks source link

Query exporter not able to connect with IBM DB2 #147

Open manvitha9347 opened 1 year ago

manvitha9347 commented 1 year ago

I am trying to connect the query exporter to ibm db2, and facing the following error in logs

2023-05-02 13:02:01,876 - ERROR - query-exporter - error from database "db1": (ibm_db_dbi.OperationalError) ibm_db_dbi::OperationalError: [IBM][CLI Driver] SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location where the error was detected: "". Communication function detecting the error: "recv". Protocol specific error code(s): "104", "*", "0". SQLSTATE=08001 SQLCODE=-30081

config.yaml: databases: db1: dsn: db2+ibm_db://uname:pass@ip:50000/DSODB keep-connected: true autocommit: false labels: app: app1

metrics:
  all_entries_last_hr:
    type: gauge
    description: all_entries_last_hr

queries: query1: interval: 100 databases: [db1] metrics: [all_entries_last_hr] sql: > select count(*) from
DSODB.JOBRUN JR,DSODB.JOBEXEC JE,DSODB.HOST H
where
JR.JOBID=JE.JOBID
AND H.HOSTID=JE.HOSTID
AND RUNSTARTTIMESTAMP BETWEEN current timestamp - 60 minutes and current timestamp

I am using python 3.10 dev and venv for this, and I also tried the troubleshoot options specified in https://github.com/albertodonato/query-exporter/issues/96 https://github.com/albertodonato/query-exporter/issues/14

  1. adding libxml2
  2. adding venv related environment variable
  3. kept sql alchemy version at 1.3.24
  4. kept aiohttp version at 3.7.4.post0 but nothing worked

I also tried having dsn as dsn: db2+ibm_db://uname:pass@ip:50000/DSODB dsn: db2+ibm_db_sa://uname:pass@ip:50000/DSODB dsn: db2://uname:pass@ip:50000/DSODB but nothing worked

tried varying query params for ibm db2 added DB2COMM=tcpip DB2TCP_CLIENT_CONTIMEOUT=0 DB2TCP_CLIENT_RCVTIMEOUT=0 but nothing worked

Connection Details: Query exporter deployed in Kubernetes pod built with ubuntu image Firewall has been enabled between source and destination

And do we need DB2Client to connect with IBM DB2?

Could you please help me understand what's going wrong here? Thanks

albertodonato commented 10 months ago

Does this still happen with newer releases? If so, can you provide what version (including whether it's virtualenv, snap or docker) and the exact configuration being used?