logstash使用中遇到的问题
文章目錄
- 1. 在logstash中配置es的域名無法使用
- 2. logstash.yml配置不生效
1. 在logstash中配置es的域名無法使用
output {elasticsearch {hosts => ["http://estest_hostmy.com:10200"]index => "%{[@metadata][index_0]}-%{+YYYY.MM.dd}"} }報錯如下
17378 [2018-11-22T15:46:00,659][WARN ][logstash.outputs.elasticsearch] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>"http://:9200/", :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError, :error=>"Elasticsearch Unreachable: [http://:9200/][Manticore::ClientProtocolException] URI does not specify a valid host name: http:/"}17379 [2018-11-22T15:46:05,660][INFO ][logstash.outputs.elasticsearch] Running health check to see if an Elasticsearch connection is working {:healthcheck_url=>http://:9200/, :path=>"/"}17380 [2018-11-22T15:46:05,660][INFO ][logstash.outputs.elasticsearch] Running health check to see if an Elasticsearch connection is working {:healthcheck_url=>http://:9200/, :path=>"/"}17381 [2018-11-22T15:46:05,660][INFO ][logstash.outputs.elasticsearch] Running health check to see if an Elasticsearch connection is working {:healthcheck_url=>http://:9200/, :path=>"/"}17382 [2018-11-22T15:46:05,660][INFO ][logstash.outputs.elasticsearch] Running health check to see if an Elasticsearch connection is working {:healthcheck_url=>http://:9200/, :path=>"/"}17383 [2018-11-22T15:46:05,660][INFO ][logstash.outputs.elasticsearch] Running health check to see if an Elasticsearch connection is working {:healthcheck_url=>http://:9200/, :path=>"/"}17384 [2018-11-22T15:46:05,660][WARN ][logstash.outputs.elasticsearch] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>"http://:9200/", :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError, :error=>"Elasticsearch Unreachable: [http://:9200/][Manticore::ClientProtocolException] URI does not specify a valid host name: http:/"}一度以為就是logstash不支持域名配置。
但是logstash的官網介紹的是 type 為uri 鏈接
hosts
Value type is uri
Default value is [//127.0.0.1]
Sets the host(s) of the remote instance. If given an array it will load balance requests across the hosts specified in the hosts parameter. Remember the http protocol uses the http address (eg. 9200, not 9300). “127.0.0.1” [“127.0.0.1:9200”,“127.0.0.2:9200”] [“http://127.0.0.1”] [“https://127.0.0.1:9200”] [“https://127.0.0.1:9200/mypath”] (If using a proxy on a subpath) It is important to exclude dedicated master nodes from the hosts list to prevent LS from sending bulk requests to the master nodes. So this parameter should only reference either data or client nodes in Elasticsearch.
Any special characters present in the URLs here MUST be URL escaped! This means # should be put in as %23 for instance.
??左思右想覺得不太對勁,后來想到查到logstash的 output-elasticsearch-plugin的官方github,通過一個issue 才發現原來是我對域名配置不夠熟悉(在這個issue看到一半的時候以為是logstash的 logstash-output-elasticsearch 插件版本問題,打臉,以后要看完),域名里面的規范是不能有下劃線(_)的。
??看來最基本的知識有時候不牢固會造成很多問題,一定要有質疑能力,還好看了es的官網是可以配置url的,所以堅持查了查,要不然估計就認知錯誤了。坑。要多學習,孩砸。
修改為下面的方式就ok了
output {elasticsearch {hosts => ["http://estes-thostmy.com:10200"]index => "%{[@metadata][index_0]}-%{+YYYY.MM.dd}"} }github issue 鏈接
2. logstash.yml配置不生效
在logstash.yml中配置監控數據收集到es當中,但是一直不生效,數據無法進入到es當中,根據實際經驗,類似下面配置沒有問題。
path.data: /home/dev/logstash/logstash_dataconfig.reload.interval: 3sdead_letter_queue.enable: falsehttp.port: 9600-9700xpack.monitoring.enabled: truexpack.monitoring.elasticsearch.username: "logstash_system"xpack.monitoring.elasticsearch.password: "d1Acosm6Eo"xpack.monitoring.elasticsearch.hosts: "http://uc-k8s3:9200"xpack.monitoring.collection.pipeline.details.enabled: true??后來猛然想起來是yml的格式有問題,因為配置項提交多,注釋項也很多(最開始上面的配置中夾雜了很多其他注釋),發現是因為前面的一些配置和后面的配置沒有按照yml格式對齊,刪掉所有的注釋性文字,整理成上面就可以了
總結
以上是生活随笔為你收集整理的logstash使用中遇到的问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: spark on yarn 使用自定义j
- 下一篇: mac golang grpc prot