es集成,去掉loki

This commit is contained in:
ludj
2023-02-07 17:42:33 +08:00
parent 8fb452f27f
commit dd7ef7f9ba
20 changed files with 395 additions and 207 deletions

View File

@@ -0,0 +1,31 @@
package org.nl.modules.logging.rest;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.nl.modules.logging.service.EsLogService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author ldjun
* @version 1.0
* @date 2023年01月29日 18:55
* @desc desc
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/esLog")
public class EsLogController {
private final EsLogService esLogService;
@GetMapping("/labels")
@ApiOperation("获取标签")
public ResponseEntity<Object> labelsValues() {
return new ResponseEntity<>(esLogService.getLabelsValues(), HttpStatus.OK);
}
}

View File

@@ -0,0 +1,17 @@
package org.nl.modules.logging.service;
import com.alibaba.fastjson.JSONArray;
/**
* @author ldjun
* @version 1.0
* @date 2023年02月07日 14:34
* @desc desc
*/
public interface EsLogService {
/**
* 获取labels和values树
* @return
*/
JSONArray getLabelsValues();
}

View File

@@ -0,0 +1,76 @@
package org.nl.modules.logging.service.impl;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import org.nl.modules.logging.service.EsLogService;
import org.nl.wms.ext.acs.service.impl.AcsToWmsServiceImpl;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* @author ldjun
* @version 1.0
* @date 2023年02月07日 14:35
* @desc desc
*/
@Service
@RequiredArgsConstructor
public class EsLogServiceImpl implements EsLogService {
@Override
public JSONArray getLabelsValues() {
/**
* [{
* label:
* value:
* children:[{
* label
* value
* }]
* }]
*/
//获取所有索引
// String url = "http://47.111.78.178:27017/_cat/indices";
String url = "http://47.111.78.178:27017/_aliases";
String resultMsg = HttpRequest.get(url)
.execute().body();
JSONObject jsonObject = JSON.parseObject(resultMsg);
JSONArray arr = new JSONArray();
for (Map.Entry entry : jsonObject.entrySet()) {
System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
JSONObject json = new JSONObject();
json.put("label", entry.getKey());
json.put("Value", entry.getValue());
arr.add(json);
}
return arr;
}
public static void main(String[] args) {
// String url = "http://47.111.78.178:27017/_cat/indices";
String url = "http://47.111.78.178:27017/_aliases";
String resultMsg = HttpRequest.get(url)
.execute().body();
JSONObject jsonObject = JSON.parseObject(resultMsg);
JSONArray arr = new JSONArray();
for (Map.Entry entry : jsonObject.entrySet()) {
System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
JSONObject json = new JSONObject();
json.put("label", entry.getKey());
json.put("Value", entry.getValue());
arr.add(json);
}
}
}