Elastic Search 整合Zipkin进行跟踪数据的持久化报错
ZipKin\UI版本:2.12.3
Elastic Search:7.14.0
报错信息:`Caused by: java.lang.IllegalStateException: response for update-template failed: {“error”:{“root_cause”:[{“type”:“invalid_index_template_exception”,“reason”:“index_template [zipkin:span_template] invalid, cause [Validation Failed: 1: index_pattern [zipkin:span-] must not contain a ‘:’;]"}],“type”:“invalid_index_template_exception”,“reason”:"index_template [zipkin:span_template] invalid, cause [Validation Failed: 1: index_pattern [zipkin:span-] must not contain a ‘:’;]”},“status”:400}
at zipkin2.elasticsearch.internal.client.HttpCall.parseResponse(HttpCall.java:151) ~[zipkin-storage-elasticsearch-2.8.4.jar:?]
at zipkin2.elasticsearch.internal.client.HttpCall.execute(HttpCall.java:79) ~[zipkin-storage-elasticsearch-2.8.4.jar:?]
at zipkin2.elasticsearch.EnsureIndexTemplate.apply(EnsureIndexTemplate.java:40) ~[zipkin-storage-elasticsearch-2.8.4.jar:?]
at zipkin2.elasticsearch.ElasticsearchStorage.ensureIndexTemplates(ElasticsearchStorage.java:301) ~[zipkin-storage-elasticsearch-2.8.4.jar:?]
at zipkin2.elasticsearch.AutoValue_ElasticsearchStorage.ensureIndexTemplates(AutoValue_ElasticsearchStorage.java:28) ~[zipkin-storage-elasticsearch-2.8.4.jar:?]
at zipkin2.elasticsearch.ElasticsearchStorage.spanStore(ElasticsearchStorage.java:217) ~[zipkin-storage-elasticsearch-2.8.4.jar:?]
at zipkin.storage.elasticsearch.http.ElasticsearchHttpStorage.spanStore(ElasticsearchHttpStorage.java:147) ~[zipkin-storage-elasticsearch-http-2.8.4.jar:?]
at zipkin2.server.internal.ZipkinQueryApiV2.getSpanNames(ZipkinQueryApiV2.java:97) ~[zipkin-server-2.12.3.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_144]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_144]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_144]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:893) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:798) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
... 86 more`
ZipKin版本注意:
release 版本是 Zipkin 2.12.9,从 2.12.6 版本开始有个较大的更新,迁移使用 Armeria HTTP 引擎。从此版本开始,若直接添加依赖的 Spring Boot 应用启动会存在冲突,降到2.12.3版本就可以正常启动
解决方案:
Elastic Search 版本过高,下载Elastic Search6.0.0可解决错误
Elastic Search6.0.0下载地址
下面是持久化步骤
我这里是下载的windows的
1.下载6.0.0版本
解压–》到bin目录–》运行elasticsearch.bat完了访问–》localhost:9200如果显示json则没问题
2.在zipkin加入依赖:
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-storage-elasticsearch-http</artifactId>
<version>2.8.4</version>
</dependency>
3.加配置
zipkin.storage.type=elasticsearch
zipkin.storage.elasticsearch.cluster=elasticsearch
zipkin.storage.elasticsearch.hosts=http://localhost:9200
zipkin.storage.elasticsearch.index=zipkin