Authored by qinchao

恶意ip

@@ -18,6 +18,8 @@ public class MaliciousIpMapperImpl extends InfluxDBQuery implements MaliciousIpM @@ -18,6 +18,8 @@ public class MaliciousIpMapperImpl extends InfluxDBQuery implements MaliciousIpM
18 @Autowired 18 @Autowired
19 private InluxDBSingle inluxDBSingle; 19 private InluxDBSingle inluxDBSingle;
20 20
  21 + private final String mip_rpname="rp_thirtyweek";///恶意ip默认保留30个星期,半年左右
  22 +
21 23
22 /** 24 /**
23 *插入恶意ip 25 *插入恶意ip
@@ -27,7 +29,7 @@ public class MaliciousIpMapperImpl extends InfluxDBQuery implements MaliciousIpM @@ -27,7 +29,7 @@ public class MaliciousIpMapperImpl extends InfluxDBQuery implements MaliciousIpM
27 @Override 29 @Override
28 public void insertMip(String influxDBName, String ip){ 30 public void insertMip(String influxDBName, String ip){
29 BatchPoints batchPoints = BatchPoints 31 BatchPoints batchPoints = BatchPoints
30 - .database(InfluxDBContants.YOMO_MONITOR).retentionPolicy("default") 32 + .database(InfluxDBContants.YOMO_MONITOR).retentionPolicy(mip_rpname)
31 .build(); 33 .build();
32 Point point = Point.measurement("monitor_malicousips") 34 Point point = Point.measurement("monitor_malicousips")
33 .tag("ip",ip) 35 .tag("ip",ip)
@@ -37,13 +39,15 @@ public class MaliciousIpMapperImpl extends InfluxDBQuery implements MaliciousIpM @@ -37,13 +39,15 @@ public class MaliciousIpMapperImpl extends InfluxDBQuery implements MaliciousIpM
37 .write(batchPoints); 39 .write(batchPoints);
38 } 40 }
39 41
  42 + //duration 是influxdb关键字,因此字段名称取为dur,保留策略: rp_thirtyweek
  43 + //由于不是默认的保留策略,因此执行查询时,select * from rp_thirtyweek.monitor_malicousips where value= '127.0.0.1';
40 public void insertMipObj(String influxDBName, String ip,String reason,String duration){ 44 public void insertMipObj(String influxDBName, String ip,String reason,String duration){
41 BatchPoints batchPoints = BatchPoints 45 BatchPoints batchPoints = BatchPoints
42 - .database(InfluxDBContants.YOMO_MONITOR).retentionPolicy("default") 46 + .database(InfluxDBContants.YOMO_MONITOR).retentionPolicy(mip_rpname)
43 .build(); 47 .build();
44 Point point = Point.measurement("monitor_malicousips") 48 Point point = Point.measurement("monitor_malicousips")
45 .tag("ip",ip) 49 .tag("ip",ip)
46 - .addField("value", ip).addField("duration",duration).addField("reason",reason).build(); 50 + .addField("value", ip).addField("dur",duration).addField("reason",reason).build();
47 batchPoints.point(point); 51 batchPoints.point(point);
48 inluxDBSingle.getInfluxDBByName(influxDBName).getInfluxDB() 52 inluxDBSingle.getInfluxDBByName(influxDBName).getInfluxDB()
49 .write(batchPoints); 53 .write(batchPoints);