# При добавлении в конфиг Logstash elasticsearch filter plugun появилась ошибка filebeat: Failed to connect to backoff(async(tcp://xxx.xxx.xxx.xxx:5044)): dial tcp xxx.xxx.xxx.xxx:5044: connect: connection refused

**URL:** <https://discuss.elastic.co/t/logstash-elasticsearch-filter-plugun-filebeat-failed-to-connect-to-backoff-async-tcp-xxx-xxx-xxx-xxx-5044-dial-tcp-xxx-xxx-xxx-xxx-connect-connection-refused/215132>\
**Category:** Вопросы на русском языке\
**Created:** [January 15, 2020, 12:30pm UTC](https://discuss.elastic.co/t/logstash-elasticsearch-filter-plugun-filebeat-failed-to-connect-to-backoff-async-tcp-xxx-xxx-xxx-xxx-5044-dial-tcp-xxx-xxx-xxx-xxx-connect-connection-refused/215132 "2020-01-15T12:30:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![111249](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/111249/32/58382_2.png) [@111249](https://discuss.elastic.co/u/111249)\
**Post date:** [January 15, 2020, 12:30pm UTC](https://discuss.elastic.co/t/logstash-elasticsearch-filter-plugun-filebeat-failed-to-connect-to-backoff-async-tcp-xxx-xxx-xxx-xxx-5044-dial-tcp-xxx-xxx-xxx-xxx-connect-connection-refused/215132/1 "2020-01-15T12:30:19Z")

</div>

В фильтре logstash я пытаюсь обратиться к elasticsearch, чтобы получить необходимые данные. Без elasticsearch plugin все работает хорошо (если код закоментирован).

**/etc/logstash/conf.d/mysql-beats.conf**

```
input {
  beats {
    port => 5044
    client_inactivity_timeout => 3000
# ssl => false
  }
}

filter {
  mutate {gsub => ["message", "\t", " "]}
  grok {
    match => {"message" => "%{WORD:method}\s%{WORD:product_name}\s%{WORD:product_price}"}
  }
  if [method] == "UPDATE" {
    mutate {
      convert => {"product_price" => "float"}
    }
# elasticsearch {
# hosts => ["http://0.0.0.0:9200"]
# query_template => "/usr/share/logstash/product-names.json"
# fields => { "product_name" => "title", "ourProductId" => "ourProductId" }
# index => "product-names"
# user => "elastic"
# password => "elasticpassword"
# }
  }
}

output {
  if "_grokparsefailure" not in [tags] {
    elasticsearch {
      hosts => ["http://0.0.0.0:9200"]
      index => "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
      user => "elastic"
      password => "elasticpassword"
    }
  }
}

```

**/usr/share/logstash/product-names.json**

```
{
    "size": 1,
    "query": {
      "term": {
       "ourProductId": {"value": "%{product_name}"}
      }
    },
   "_source": ["title", "ourProductId"]
 }

```

**curl -XGET "xxx.xxx.xxx.xxx:9200/product-names/\_mapping?pretty"**

```
{
  "product-names" : {
    "mappings" : {
      "properties" : {
        "ourProductId" : {
          "type" : "keyword"
        },
        "product_name" : {
          "type" : "keyword"
        }
      }
    }
  }
}

```

из-за чего может возникать ошибка?

Elasticsearch plugin должен обращаться именно к индексам логов? Или можно взять данные из любого индекса?

Изменил `query_template` на `query => "ourProductId:%{product_name}"`  
данные записываются с filebeat в elasticsearch через logstash, но появился тег `_elasticsearch_lookup_failure`

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [January 15, 2020, 11:13pm UTC](https://discuss.elastic.co/t/logstash-elasticsearch-filter-plugun-filebeat-failed-to-connect-to-backoff-async-tcp-xxx-xxx-xxx-xxx-5044-dial-tcp-xxx-xxx-xxx-xxx-connect-connection-refused/215132/2 "2020-01-15T23:13:29Z")

</div>

А elasticsearch обрабатывать запросы успевает?

---

<div class="post-metadata">

**Author:** ![111249](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/111249/32/58382_2.png) [@111249](https://discuss.elastic.co/u/111249)\
**Post date:** [January 16, 2020, 8:17am UTC](https://discuss.elastic.co/t/logstash-elasticsearch-filter-plugun-filebeat-failed-to-connect-to-backoff-async-tcp-xxx-xxx-xxx-xxx-5044-dial-tcp-xxx-xxx-xxx-xxx-connect-connection-refused/215132/3 "2020-01-16T08:17:47Z")

</div>

А как это можно проверить? У меня в индексе всего две тестовые записи с двумя полями, я думаю, что должен успевать. А logstash output не ждет, когда отработают все плагины в фильтре? Я думал, что когда завершены все процессе в фильтре, то тогда только происходит запись в эластик

---

<div class="post-metadata">

**Author:** ![111249](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/111249/32/58382_2.png) [@111249](https://discuss.elastic.co/u/111249)\
**Post date:** [January 16, 2020, 9:33am UTC](https://discuss.elastic.co/t/logstash-elasticsearch-filter-plugun-filebeat-failed-to-connect-to-backoff-async-tcp-xxx-xxx-xxx-xxx-5044-dial-tcp-xxx-xxx-xxx-xxx-connect-connection-refused/215132/4 "2020-01-16T09:33:11Z")

</div>

Мне кажется, проблема в том, что я не могу подключиться к произвольному индексу эластика, а нужно использовать индекс для filebeat. Я попробовал подключиться именно к нему и получилось найти данные, а тег \_elasticsearch\_lookup\_failure пропал.

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [January 16, 2020, 1:53pm UTC](https://discuss.elastic.co/t/logstash-elasticsearch-filter-plugun-filebeat-failed-to-connect-to-backoff-async-tcp-xxx-xxx-xxx-xxx-5044-dial-tcp-xxx-xxx-xxx-xxx-connect-connection-refused/215132/5 "2020-01-16T13:53:22Z")

</div>

А если заменить filebeat input на stdin input, то что появляется в логах logstash?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 13, 2020, 1:53pm UTC](https://discuss.elastic.co/t/logstash-elasticsearch-filter-plugun-filebeat-failed-to-connect-to-backoff-async-tcp-xxx-xxx-xxx-xxx-5044-dial-tcp-xxx-xxx-xxx-xxx-connect-connection-refused/215132/6 "2020-02-13T13:53:24Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
