xaecbd / KCenter

KCenter(KafkaCenter) is a unified platform for kafka cluster management and maintenance, producer / consumer monitoring, and use of ecological components(ksql/kafka connect).it's kafkacenter(kafka center).
https://xaecbd.github.io/KCenter
Apache License 2.0
1.16k stars 196 forks source link

ES问题 #71

Closed bfc-maple closed 4 years ago

bfc-maple commented 4 years ago

配置完ES之后出现type is missing `public boolean batchInsertES(List datas, String index) throws IOException { if(client==null){ return false; } BulkRequest request = new BulkRequest(); if (datas == null || datas.isEmpty()) { return true; } datas.forEach(data -> { // TODO new IndexRequest(index)时,client.bulk一直报type is missing,这个方法过时了,但保证了不报错暂时还能用 request.add(new IndexRequest(index).source(data)); });

    LOG.info("batchInsertES : index : " + index + ",data : " + datas + "");

    BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT);

    LOG.info("client.bulk result :" + JSON.toJSONString(bulkResponse));

    return !bulkResponse.hasFailures();

}`

打印日志如下: ElasticsearchUtil: batchInsertES : index : kafka_center_monitor,type : kafka_center_monitor-2020-07-07,data : [{"date":"2020-07-07T09:26:00.000+0800","jmxPort":"21006","metricName":"BytesOutPerSec","fiveMinuteRate":84428.0895,"count":198054151932,"clusterID":"1","broker":"10.102.0.19","oneMinuteRate":63170.8368,"fifteenMinuteRate":53117.433,"meanRate":465406.0547,"port":"21005","clusterName":"cluster","location":"dev","timestamp":1594085160000}, {"date":"2020-07-07T09:26:00.000+0800","jmxPort":"21006","metricName":"BytesInPerSec","fiveMinuteRate":96238.9229,"count":118288142172,"clusterID":"1","broker":"10.102.0.19","oneMinuteRate":73428.1492,"fifteenMinuteRate":65046.5471,"meanRate":277964.4716,"port":"21005","clusterName":"cluster","location":"dev","timestamp":1594085160000}, {"date":"2020-07-07T09:26:00.000+0800","jmxPort":"21006","metricName":"BytesOutPerSec","fiveMinuteRate":54553.1159,"count":109035702157,"clusterID":"1","broker":"10.102.0.18","oneMinuteRate":37763.0596,"fifteenMinuteRate":37694.6493,"meanRate":256222.4317,"port":"21005","clusterName":"cluster","location":"dev","timestamp":1594085160000}, {"date":"2020-07-07T09:26:00.000+0800","jmxPort":"21006","metricName":"BytesInPerSec","fiveMinuteRate":55574.1832,"count":89660100777,"clusterID":"1","broker":"10.102.0.18","oneMinuteRate":43037.1803,"fifteenMinuteRate":37120.41,"meanRate":210691.8068,"port":"21005","clusterName":"cluster","location":"dev","timestamp":1594085160000}, {"date":"2020-07-07T09:26:00.000+0800","jmxPort":"21006","metricName":"BytesOutPerSec","fiveMinuteRate":52880.7928,"count":138662488364,"clusterID":"1","broker":"10.102.0.17","oneMinuteRate":40038.6967,"fifteenMinuteRate":33190.2336,"meanRate":325841.291,"port":"21005","clusterName":"cluster","location":"dev","timestamp":1594085160000}, {"date":"2020-07-07T09:26:00.000+0800","jmxPort":"21006","metricName":"MessagesInPerSec","fiveMinuteRate":33.2382,"count":47663123,"clusterID":"1","broker":"10.102.0.19","oneMinuteRate":27.5254,"fifteenMinuteRate":24.8562,"meanRate":112.0032,"port":"21005","clusterName":"cluster","location":"dev","timestamp":1594085160000}, {"date":"2020-07-07T09:26:00.000+0800","jmxPort":"21006","metricName":"BytesInPerSec","fiveMinuteRate":17254.7238,"count":2988950547,"clusterID":"1","broker":"10.102.0.16","oneMinuteRate":13566.8426,"fifteenMinuteRate":11686.4836,"meanRate":56040.6149,"port":"21005","clusterName":"cluster","location":"dev","timestamp":1594085160000}, {"date":"2020-07-07T09:26:00.000+0800","jmxPort":"21006","metricName":"BytesInPerSec","fiveMinuteRate":65539.8609,"count":91101226682,"clusterID":"1","broker":"10.102.0.17","oneMinuteRate":52961.1351,"fifteenMinuteRate":43281.3703,"meanRate":214077.6627,"port":"21005","clusterName":"cluster","location":"dev","timestamp":1594085160000}, {"date":"2020-07-07T09:26:00.000+0800","jmxPort":"21006","metricName":"BytesOutPerSec","fiveMinuteRate":15024.0503,"count":2917432782,"clusterID":"1","broker":"10.102.0.16","oneMinuteRate":11390.5053,"fifteenMinuteRate":9521.2635,"meanRate":54699.7085,"port":"21005","clusterName":"cluster","location":"dev","timestamp":1594085160000}, {"date":"2020-07-07T09:26:00.000+0800","jmxPort":"21006","metricName":"MessagesInPerSec","fiveMinuteRate":93.5886,"count":29947462,"clusterID":"1","broker":"10.102.0.17","oneMinuteRate":80.7972,"fifteenMinuteRate":57.5723,"meanRate":70.3732,"port":"21005","clusterName":"cluster","location":"dev","timestamp":1594085160000}, {"date":"2020-07-07T09:26:00.000+0800","jmxPort":"21006","metricName":"MessagesInPerSec","fiveMinuteRate":16.0738,"count":22906131,"clusterID":"1","broker":"10.102.0.18","oneMinuteRate":12.142,"fifteenMinuteRate":10.1072,"meanRate":53.827,"port":"21005","clusterName":"cluster","location":"dev","timestamp":1594085160000}, {"date":"2020-07-07T09:26:00.000+0800","jmxPort":"21006","metricName":"MessagesInPerSec","fiveMinuteRate":13.3404,"count":887933,"clusterID":"1","broker":"10.102.0.16","oneMinuteRate":10.9706,"fifteenMinuteRate":9.8997,"meanRate":16.6481,"port":"21005","clusterName":"cluster","location":"dev","timestamp":1594085160000}] 2020-07-07 09:26:10,326 ERROR [pool-2-thread-5] CollectMetricsJob: monitor metric error. org.elasticsearch.ElasticsearchStatusException: Elasticsearch exception [type=action_request_validation_exception, reason=Validation Failed: 1: type is missing;2: type is missing;3: type is missing;4: type is missing;5: type is missing;6: type is missing;7: type is missing;8: type is missing;9: type is missing;10: type is missing;11: type is missing;12: type is missing;] at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:177) at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:1727) at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:1704) at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1467) at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1424) at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1394) at org.elasticsearch.client.RestHighLevelClient.bulk(RestHighLevelClient.java:492) at org.nesc.ec.bigdata.common.util.ElasticsearchUtil.batchInsertES(ElasticsearchUtil.java:64) at org.nesc.ec.bigdata.job.CollectMetricsJob.collectMetric(CollectMetricsJob.java:67) at org.nesc.ec.bigdata.job.CollectorAndAlertJob.lambda$runCollectMetricsJob$1(CollectorAndAlertJob.java:91) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:835) 求帮助看下是哪里出现了问题

TrumanDu commented 4 years ago

@bfc-maple es版本7.0+,检查一下你的es版本

bfc-maple commented 4 years ago

如果用到ES就必须要7.0+,不用到ES就对版本没要求,晓得了,谢谢