Use default influx batch options.
This commit is contained in:
parent
e3717529b5
commit
c198c370ff
|
@ -12,6 +12,13 @@ Small utility to fetch metrics from one or more HMC's and push those to an Influ
|
|||
- Run the *bin/hmci* program in a shell, as a @reboot cron task or setup a proper service :)
|
||||
|
||||
|
||||
### Notes
|
||||
|
||||
Examples on how to change the default retention policy:
|
||||
|
||||
ALTER RETENTION POLICY "autogen" ON "hmci" DURATION 156w
|
||||
ALTER RETENTION POLICY "autogen" ON "hmci" DURATION 90d
|
||||
|
||||
|
||||
## Development Information
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ class InfluxClient {
|
|||
InfluxDB influxDB
|
||||
BatchPoints batchPoints
|
||||
|
||||
|
||||
InfluxClient(String url, String username, String password, String database) {
|
||||
this.url = url
|
||||
this.username = username
|
||||
|
@ -44,6 +45,7 @@ class InfluxClient {
|
|||
this.database = database
|
||||
}
|
||||
|
||||
|
||||
void login() {
|
||||
if(!influxDB) {
|
||||
try {
|
||||
|
@ -51,9 +53,8 @@ class InfluxClient {
|
|||
createDatabase()
|
||||
|
||||
// Enable batch writes to get better performance.
|
||||
BatchOptions options = BatchOptions.DEFAULTS.actions(300).flushDuration(500);
|
||||
influxDB.enableBatch(options);
|
||||
|
||||
//BatchOptions options = BatchOptions.DEFAULTS.actions(300).flushDuration(500);
|
||||
influxDB.enableBatch(BatchOptions.DEFAULTS);
|
||||
//influxDB.setLogLevel(InfluxDB.LogLevel.BASIC);
|
||||
|
||||
batchPoints = BatchPoints.database(database).precision(TimeUnit.SECONDS).build();
|
||||
|
@ -65,6 +66,7 @@ class InfluxClient {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void logoff() {
|
||||
influxDB?.close();
|
||||
influxDB = null
|
||||
|
@ -72,18 +74,9 @@ class InfluxClient {
|
|||
|
||||
|
||||
void createDatabase() {
|
||||
// Create a database...
|
||||
influxDB.query(new Query("CREATE DATABASE " + database));
|
||||
// Create our database... with a default retention of 156w == 3 years
|
||||
influxDB.query(new Query("CREATE DATABASE " + database + " WITH DURATION 156w"));
|
||||
influxDB.setDatabase(database);
|
||||
|
||||
/*
|
||||
// ... and a retention policy, if necessary.
|
||||
String retentionPolicyName = "HMCI_ONE_YEAR";
|
||||
influxDB.query(new Query("CREATE RETENTION POLICY " + retentionPolicyName
|
||||
+ " ON " + database + " DURATION 365d REPLICATION 1 DEFAULT"));
|
||||
influxDB.setRetentionPolicy(retentionPolicyName);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -96,7 +89,6 @@ class InfluxClient {
|
|||
logoff()
|
||||
login()
|
||||
}
|
||||
//influxDB.flush()
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue