使用Zipkin+ElasticSearch+Sleuth+RabbitMQ无法找到services问题求助
Hey there, let's break down why your Zipkin instance isn't showing any services after switching storage to Elasticsearch. First, let's recap your environment and setup:
Environment Details
- Spring Cloud: Dalston.SR1
- RabbitMQ: 3.6.10
- ElasticSearch: 6.2.4
Problem Overview
Previously, your Zipkin setup worked perfectly with MySQL storage. But after switching to Elasticsearch, you can't see any services in the Zipkin UI. Here's the screenshot of the issue:
Looking through your configuration and dependencies, I've spotted several potential issues that could be causing this:
1. Wrong Elasticsearch Port Configuration
This is likely the biggest culprit! You've configured:
zipkin.storage.elasticsearch.hosts=127.0.0.1:9300
But the zipkin-autoconfigure-storage-elasticsearch-http dependency you're using is an HTTP-based client for Elasticsearch. The default HTTP port for Elasticsearch is 9200 (port 9300 is used for node-to-node TCP communication).
Fix this by updating the configuration to:
zipkin.storage.elasticsearch.hosts=http://127.0.0.1:9200
You can verify Elasticsearch's HTTP service is running by visiting http://127.0.0.1:9200 in your browser or using curl—you should see a JSON response with Elasticsearch details.
2. Invalid Configuration Entry
Your application.properties has an unnecessary and incorrect line:
zipkin.storage.StorageComponent = elasticsearch
This isn't a valid Zipkin configuration property. The correct way to set the storage type is already present with zipkin.storage.type=elasticsearch. Delete this invalid line to avoid conflicts with storage component initialization.
3. Optional Dependency Flag Blocking Component Load
In your pom.xml, the Elasticsearch storage dependency has <optional>true</optional>:
<dependency> <groupId>io.zipkin.java</groupId> <artifactId>zipkin-autoconfigure-storage-elasticsearch-http</artifactId> <version>2.4.1</version> <optional>true</optional> <!-- This is problematic --> </dependency>
This flag tells Maven not to include this dependency by default, which means Zipkin might not load the Elasticsearch storage component at all. Remove the <optional>true</optional> line to ensure the dependency is properly included in your build.
4. Version Compatibility Issue
You're using Elasticsearch 6.2.4 with Zipkin Java 2.4.1. Elasticsearch 6.x introduced breaking changes (like deprecating document types) that aren't fully supported in older Zipkin versions like 2.4.1. This could prevent Zipkin from writing trace data to Elasticsearch entirely.
You have two options here:
- Downgrade Elasticsearch to a 5.x version (which is fully compatible with Zipkin 2.4.1)
- Upgrade Zipkin dependencies to a version that supports Elasticsearch 6.x (like 2.8.0 or later). Just make sure to check compatibility with Spring Cloud Dalston.SR1 before upgrading.
Step-by-Step Fix Recap
- Fix the Elasticsearch host/port configuration to use the HTTP port
- Remove the invalid
zipkin.storage.StorageComponentline - Remove the
<optional>true</optional>flag from your Elasticsearch storage dependency - Adjust Elasticsearch/Zipkin versions if needed for compatibility
- Restart your Zipkin service, send some trace data, and check the UI again
内容的提问来源于stack exchange,提问作者发给官兵

