在配置类中实例化
@Bean
public BatchPoints batchPoints() {
return BatchPoints.database(database)
.retentionPolicy(retentionPolicy)
.build();
}
实现保存
private void saveLogs(List<LogModel> models, String uesrName) {
if (null == models || models.size() == 0) {
return;
}
try {
for (LogModel model : models) {
Point point = Point.measurement("log_record")
.tag("event_level", model.getEventLevel())
.tag("operator", uesrName)
.addField("url", model.getUrl())
.time(model.getTime(), TimeUnit.MILLISECONDS)
.build();
logBakDBBatchPoints.point(point);
}
influxLogBakDB.write(logBakDBBatchPoints);
} catch (Exception e) {
}
}