summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshizhendong <[email protected]>2024-09-06 18:36:20 +0800
committershizhendong <[email protected]>2024-09-06 18:36:20 +0800
commitb037e46f8e99a68d80c2dbd73915626bd7e556ed (patch)
tree2a360a52dbc25beb965817a8a2f952830c51d791
parentdf01d6a61892264b89e4f76b38cd24aac97f6570 (diff)
fix: 调整 opensearch-dashboard 展示字段 ts(float),time(keyword,format="yyyy-MM-dd'T'HH:mm:ss.SSSZ")
-rw-r--r--src/main/java/net/geedge/asw/module/runner/util/PcapParserThread.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/main/java/net/geedge/asw/module/runner/util/PcapParserThread.java b/src/main/java/net/geedge/asw/module/runner/util/PcapParserThread.java
index 4f04b95..9e223c8 100644
--- a/src/main/java/net/geedge/asw/module/runner/util/PcapParserThread.java
+++ b/src/main/java/net/geedge/asw/module/runner/util/PcapParserThread.java
@@ -345,22 +345,23 @@ public class PcapParserThread implements Runnable {
.properties("version", Property.of(p2 -> p2.keyword(k -> k))))
)
)
- .properties("ts", Property.of(p -> p.keyword(f -> f)))
+ .properties("ts", Property.of(p -> p.float_(f -> f)))
+ .properties("time", Property.of(p -> p.keyword(f -> f)))
.properties("tunnel_parents", Property.of(p -> p.text(t -> t)))
.properties("uid", Property.of(p -> p.keyword(k -> k)))
);
openSearchClient.indices().create(createIndexRequestBuilder.build());
// upload data in bulk
- DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
+ DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
BulkRequest.Builder br = new BulkRequest.Builder();
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = (JSONObject) jsonArray.get(i);
// 时间戳格式转换
- String ts = jsonObject.getString("ts");
- jsonObject.put("ts", this.convertTsToFormatDate(timeFormatter, ts));
+ String formatDate = this.convertTsToFormatDate(timeFormatter, jsonObject.getString("ts"));
+ jsonObject.put("time", formatDate);
String id = String.valueOf(i);
br.operations(op -> op.index(