|
@@ -78,4 +78,36 @@ public class LoggingService {
|
|
|
results.add(yList.toArray());
|
|
results.add(yList.toArray());
|
|
|
return results;
|
|
return results;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public void logTest() {
|
|
|
|
|
+ TextFile textFile = new TextFile();
|
|
|
|
|
+ String filePath = "nginx.log";
|
|
|
|
|
+ List<String> list = textFile.read(filePath);
|
|
|
|
|
+ List<NginxLog> nginxLogs = new ArrayList<>();
|
|
|
|
|
+ for (String line : list) {
|
|
|
|
|
+ if (!line.startsWith("{")) {
|
|
|
|
|
+ System.out.println("not json data");
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ NginxLog nginxLog = JsonConverter.jsonToObject(line, NginxLog.class);
|
|
|
|
|
+ nginxLogs.add(nginxLog);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ nginxLogs.stream()
|
|
|
|
|
+ .filter(nginxLog -> nginxLog.getStatus() >= 400)
|
|
|
|
|
+ .forEach(nginxLog -> {
|
|
|
|
|
+ System.out.printf("%s %s -> %s\n", nginxLog.getRequestMethod(), nginxLog.getStatus(), nginxLog.getUpstreamAddr());
|
|
|
|
|
+ });
|
|
|
|
|
+ System.out.println();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static void main(String[] args) throws ParseException {
|
|
|
|
|
+ LoggingService loggingService = new LoggingService();
|
|
|
|
|
+ loggingService.getChartData();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|