mirror of
https://github.com/ptarmiganlabs/butler-sos.git
synced 2025-12-26 21:01:20 -05:00
feat(InfluxDB): Configurable timeouts when writing to and querying InfluxDB v3
This commit is contained in:
@@ -522,6 +522,8 @@ Butler-SOS:
|
||||
description: Butler SOS metrics
|
||||
token: mytoken
|
||||
retentionDuration: 10d
|
||||
timeout: 10000 # Optional: Socket timeout in milliseconds (default: 10000)
|
||||
queryTimeout: 60000 # Optional: Query timeout in milliseconds (default: 60000)
|
||||
v2Config: # Settings for InfluxDB v2.x only, i.e. Butler-SOS.influxdbConfig.version=2
|
||||
org: myorg
|
||||
bucket: mybucket
|
||||
|
||||
@@ -900,8 +900,25 @@ Configuration File:
|
||||
const token = this.config.get('Butler-SOS.influxdbConfig.v3Config.token');
|
||||
const database = this.config.get('Butler-SOS.influxdbConfig.v3Config.database');
|
||||
|
||||
// Get timeout settings with defaults
|
||||
const timeout = this.config.has('Butler-SOS.influxdbConfig.v3Config.timeout')
|
||||
? this.config.get('Butler-SOS.influxdbConfig.v3Config.timeout')
|
||||
: 10000; // Default 10 seconds for socket timeout
|
||||
|
||||
const queryTimeout = this.config.has(
|
||||
'Butler-SOS.influxdbConfig.v3Config.queryTimeout'
|
||||
)
|
||||
? this.config.get('Butler-SOS.influxdbConfig.v3Config.queryTimeout')
|
||||
: 60000; // Default 60 seconds for gRPC query timeout
|
||||
|
||||
try {
|
||||
this.influx = new InfluxDBClient3({ host, token, database });
|
||||
this.influx = new InfluxDBClient3({
|
||||
host,
|
||||
token,
|
||||
database,
|
||||
timeout,
|
||||
queryTimeout,
|
||||
});
|
||||
|
||||
// Test connection by executing a simple query
|
||||
this.logger.info(`INFLUXDB3 INIT: Testing connection to InfluxDB v3...`);
|
||||
@@ -921,6 +938,8 @@ Configuration File:
|
||||
this.logger.info(`INFLUXDB3 INIT: Port: ${port}`);
|
||||
this.logger.info(`INFLUXDB3 INIT: Database: ${database}`);
|
||||
this.logger.info(`INFLUXDB3 INIT: Token: ${tokenPreview}`);
|
||||
this.logger.info(`INFLUXDB3 INIT: Socket timeout: ${timeout}ms`);
|
||||
this.logger.info(`INFLUXDB3 INIT: Query timeout: ${queryTimeout}ms`);
|
||||
} catch (testErr) {
|
||||
this.logger.warn(
|
||||
`INFLUXDB3 INIT: Could not test connection (this may be normal): ${this.getErrorMessage(testErr)}`
|
||||
@@ -932,6 +951,8 @@ Configuration File:
|
||||
this.logger.info(`INFLUXDB3 INIT: Port: ${port}`);
|
||||
this.logger.info(`INFLUXDB3 INIT: Database: ${database}`);
|
||||
this.logger.info(`INFLUXDB3 INIT: Token: ${tokenPreview}`);
|
||||
this.logger.info(`INFLUXDB3 INIT: Socket timeout: ${timeout}ms`);
|
||||
this.logger.info(`INFLUXDB3 INIT: Query timeout: ${queryTimeout}ms`);
|
||||
}
|
||||
} catch (err) {
|
||||
this.logger.error(
|
||||
|
||||
Reference in New Issue
Block a user