...
|
...
|
@@ -18,6 +18,8 @@ public class MaliciousIpMapperImpl extends InfluxDBQuery implements MaliciousIpM |
|
|
@Autowired
|
|
|
private InluxDBSingle inluxDBSingle;
|
|
|
|
|
|
private final String mip_rpname="rp_thirtyweek";///恶意ip默认保留30个星期,半年左右
|
|
|
|
|
|
|
|
|
/**
|
|
|
*插入恶意ip
|
...
|
...
|
@@ -27,7 +29,7 @@ public class MaliciousIpMapperImpl extends InfluxDBQuery implements MaliciousIpM |
|
|
@Override
|
|
|
public void insertMip(String influxDBName, String ip){
|
|
|
BatchPoints batchPoints = BatchPoints
|
|
|
.database(InfluxDBContants.YOMO_MONITOR).retentionPolicy("default")
|
|
|
.database(InfluxDBContants.YOMO_MONITOR).retentionPolicy(mip_rpname)
|
|
|
.build();
|
|
|
Point point = Point.measurement("monitor_malicousips")
|
|
|
.tag("ip",ip)
|
...
|
...
|
@@ -37,13 +39,15 @@ public class MaliciousIpMapperImpl extends InfluxDBQuery implements MaliciousIpM |
|
|
.write(batchPoints);
|
|
|
}
|
|
|
|
|
|
//duration 是influxdb关键字,因此字段名称取为dur,保留策略: rp_thirtyweek
|
|
|
//由于不是默认的保留策略,因此执行查询时,select * from rp_thirtyweek.monitor_malicousips where value= '127.0.0.1';
|
|
|
public void insertMipObj(String influxDBName, String ip,String reason,String duration){
|
|
|
BatchPoints batchPoints = BatchPoints
|
|
|
.database(InfluxDBContants.YOMO_MONITOR).retentionPolicy("default")
|
|
|
.database(InfluxDBContants.YOMO_MONITOR).retentionPolicy(mip_rpname)
|
|
|
.build();
|
|
|
Point point = Point.measurement("monitor_malicousips")
|
|
|
.tag("ip",ip)
|
|
|
.addField("value", ip).addField("duration",duration).addField("reason",reason).build();
|
|
|
.addField("value", ip).addField("dur",duration).addField("reason",reason).build();
|
|
|
batchPoints.point(point);
|
|
|
inluxDBSingle.getInfluxDBByName(influxDBName).getInfluxDB()
|
|
|
.write(batchPoints);
|
...
|
...
|
|