filebeat-index-template.json для ElasticSearch 6.2.4 - PullRequest
0 голосов
/ 30 апреля 2018

Я использую ElasticSearch 6.2.4. Я попытался создать шаблон индекса Filebeat, но получил следующую ошибку

{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "No handler for type [string] declared on field [message]"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "Failed to parse mapping [_default_]: No handler for type [string] declared on field [message]",
    "caused_by" : {
      "type" : "mapper_parsing_exception",
      "reason" : "No handler for type [string] declared on field [message]"
    }
  },
  "status" : 400
}

filebeat-index.template.json

{
  "mappings": {
    "_default_": {
      "_all": {
        "enabled": true,
        "norms": {
          "enabled": false
        }
      },
      "dynamic_templates": [
        {
          "template1": {
            "mapping": {
              "doc_values": true,
              "ignore_above": 1024,
              "index": "not_analyzed",
              "type": "{dynamic_type}"
            },
            "match": "*"
          }
        }
      ],
      "properties": {
        "@timestamp": {
          "type": "date"
        },
        "message": {
          "type": "string",
          "index": "analyzed"
        },
        "offset": {
          "type": "long",
          "doc_values": "true"
        },
        "geoip"  : {
          "type" : "object",
          "dynamic": true,
          "properties" : {
            "location" : { "type" : "geo_point" }
          }
        }
      }
    }
  },
  "settings": {
    "index.refresh_interval": "5s"
  },
  "template": "filebeat-*"
}

Интересно, есть ли официальный filebeat-index-template.json , который работает для ElasticSearch 6.2.4

Другое, что я пробовал

  • Попробуйте filebeat -c "/etc/filebeat/filebeat.yml" export template > filebeat.template.json, но файловый ритм будет работать вечно, ничего не создавая.
  • Я пытался изменить "type": "string" на "type": "text",, но получил еще одну ошибку, где _all устарело.
  • Я также пытался удалить _all, но ElasticSearch продолжает иметь ошибку синтаксического анализа, когда Logstash отправляет данные в ElasticSearch.

Filebeat Version [Старая версия]

Я также пытаюсь выяснить версию моего Filebeat. Я пытался

> filebeat -v
Loading config file error: Failed to read /root/filebeat.yml: open /root/filebeat.yml: no such file or directory. Exiting.

> filebeat -v -c "/etc/filebeat/filebeat.yml"
(it struck forever) 

Я следую этому https://www.digitalocean.com/community/tutorials/how-to-install-elasticsearch-logstash-and-kibana-elk-stack-on-ubuntu-14-04,, но вместо использования ElasticSearch 2.0 и Kibana 4.5 я устанавливаю ElasticSearch 6.2.4, Kibana 6.2.4, Logstash 6.2.4 и Ubuntu 16.04.4 LTS

Обновление до Filebeat 6.2.4

Сейчас я обновляю Filebeat до 6.2.4. Теперь я получаю эту ошибку

Exiting: Could not start registrar: Error loading state: Error decoding states: json: cannot unmarshal object into Go value of type []file.State

Я удалил эту ошибку на rm /var/lib/filebeat/registry. Теперь я могу сделать filebeat export template > template.json, и теперь он работает нормально. Я скоро закрою вопрос.

Ответы [ 2 ]

0 голосов
/ 13 марта 2019

Вы должны иметь возможность использовать --es.version 6.2.4 при создании шаблона, чтобы он выводил соответствующие сопоставления для вашей версииasticsearch.

Ознакомьтесь с инструкциями для Загрузите шаблон вручную (альтернативный метод) . Они показывают следующий пример для Windows, но он может работать и в Linux.

PS > .\filebeat.exe export template --es.version 6.6.2 | Out-File -Encoding UTF8 filebeat.template.json
0 голосов
/ 08 августа 2018

Попробуйте использовать этот эластичный 6.0 модифицированный json для filebeat-index.template.json

{
  "mappings": {
    "_default_": {
      "dynamic_templates": [
        {
          "template1": {
            "mapping": {
              "doc_values": true,
              "ignore_above": 1024,
              "index": "false",
              "type": "{dynamic_type}"
            },
            "match": "*"
          }
        }
      ],
      "properties": {
        "@timestamp": {
          "type": "date"
        },
        "message": {
          "type": "text",
          "index": "true"
        },
        "offset": {
          "type": "long",
          "doc_values": "true"
        },
        "geoip": {
          "type": "object",
          "dynamic": true,
          "properties": {
            "location": {
              "type": "geo_point"
            }
          }
        }
      }
    }
  },
  "settings": {
    "index.refresh_interval": "5s"
  },
  "template": "filebeat-*"
}

В основном я изменил тип сообщения с строка на текст . Также начиная с эластичного 6.0 и далее в индексном поле используется true или false вместо проанализировано .

После выполнения этой команды (как указано в блоге , о котором вы говорите выше):

curl -XPUT 'http://localhost:9200/_template/filebeat?pretty' -d@filebeat-index-template.json -H 'Content-Type: application/json'

Мне удалось получить правильное подтверждение от эластика:

{ 
  "acknowledged" : true
}

Я еще не проверял его, но, пожалуйста, дайте мне знать, работает ли он для вас.

Вы, вероятно, заметите, что шаблон _all также удален из исходного json. Зачем? Очевидно, это было амортизировано в эластичном 6.0 , и есть способы использовать вместо него copy_to , как предложено в здесь , но я еще не понял это.

...