我对弹性搜索非常陌生,我正在使用 OOB DotNet7 WeatherApi。这是一个日志记录示例,我正在使用 Serilog 和 Elasticsearch 接收器。我尝试使用的弹性搜索版本是8.7.1和8.10.2,两者的结果是相同的。 我在 docker 日志中收到以下内容:
Caught exception while performing bulk operation to Elasticsearch: Elasticsearch.Net.ElasticsearchClientException: The client is unable to verify that the server is Elasticsearch due to an unsuccessful product check call.Some functionality may not be compatible if the server is running an unsupported product. Call: Status code unknown from: GET
我在执行此操作时正在关注 YouTube 教程,显然它对这个人有用,但据我所知,一切都是一样的,我根本无法让 Kibana 仪表板 显示日志。
我正在托管在公共 GitHub 存储库上使用的示例 API 代码,该代码位于此处
对此的任何帮助表示赞赏。这看起来像这样简单的事情应该可行,但我不知道我在哪里搞砸了。
当我使用 power shell 在 Windows 计算机上运行命令 curl http://localhost:9200/ 时,您会得到以下信息:
StatusCode : 200
StatusDescription : OK
Content : {
"name" : "a8e6b14cff9e",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "7LvJ1XZNx813aV6g",
"version" : {
"number" : "8.7.1",
"build_flavor" : "default",
"build_type" ...
RawContent : HTTP/1.1 200 OK
X-elastic-product: Elasticsearch
Content-Length: 539
Content-Type: application/json
{
"name" : "a8e6b14cff9e",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "7LvJ1...
Forms : {}
Headers : {[X-elastic-product, Elasticsearch], [Content-Length, 539], [Content-Type, application/json]}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : System.__ComObject
RawContentLength : 539
我认为您的应用程序中的elasticsearch Uri配置不正确。尝试更换
"ELKConfiguration": {
"Uri": "default_url"
},
与
"ELKConfiguration": {
"Uri": "http://elasticsearch:9200/"
},
如果您在 docker-compose 中运行应用程序或
"ELKConfiguration": {
"Uri": "http://localhost:9200/"
},
如果您直接在操作系统中运行应用程序。
我认为 docker compose 文件也存在问题。看来elasticsearch和kibana正在共享相同的非默认网络,而您的应用程序没有使用相同的网络:
sampleapi:
image: ${DOCKER_REGISTRY-}sampleapi
build:
context: .
dockerfile: src/SampleApi/Dockerfile
networks:
- elasticnw
因此,修复网址和网络,看看它是否有效。