elasticsearch - 使用logstash的动态elasticsearch index_type

标签 elasticsearch logstash grok

我正在使用Rabbitmq服务器上的logstash在elasticsearch上存储数据。

我的logstash命令看起来像

logstash -e 'input{
rabbitmq {
    exchange => "redwine_log"
    key => "info.redwine"
    host => "localhost"
    durable => true
    user => "guest"
    password => "guest"
}
}

output {
  elasticsearch {
    host => "localhost"
    index => "redwine"
  }
}
filter {
  json {
    source => "message"
    remove_field => [ "message" ]
  }
}'

但是我需要使用logstash将数据放入Elasticsearch集群中的不同类型。我所说的类型是:
"hits": {
      "total": 3,
      "max_score": 1,
      "hits": [
         {
            "_index": "logstash-2014.11.19",
            "_type": "logs",
            "_id": "ZEea8HBOSs-QwH67q1Kcaw",
            "_score": 1,
            "_source": {
               "context": [],
               "level": 200,
               "level_name": "INFO",

这是搜索结果的一部分,您可以在其中看到通过defualt创建的logstash,该类型称为“logs”(_ type:“logs”)。在我的项目中,我需要类型是动态的,并且应该基于输入数据创建。
例如:我的输入数据看起来像
{
    "data":"some data",
    "type": "type_1"
}

我需要logstash在elasticsearch中创建一个名称为“type_1”的新类型。

我尝试使用grok ..但是无法获得此特定要求。

最佳答案

它以这种方式为我工作

elasticsearch {
    host => "localhost"
    index_type => "%{type}"
  }

关于elasticsearch - 使用logstash的动态elasticsearch index_type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27017503/

相关文章:

Elasticsearch - 启用字段的全文搜索

elasticsearch - 使用 http 输入插件设置与 SSL 的通信 logstash

elasticsearch - Logstash索引编制错误-聚合插件:对于task_id模式 '%{id}',有多个过滤器

python - Grok DistributionNotFound : grokcore. 启动

python - 比 grok 更喜欢 zope 3 的原因

elasticsearch - 在Elastic的_all字段中搜索并返回突出显示的结果

elasticsearch - 按类别查找文档

elasticsearch - 有人可以解释如何在 Elasticsearch 5.1中将过滤器与percolate查询一起使用吗?

elasticsearch - 可以将作为 Web 服务公开的日志数据输入到 Elasticsearch 吗?

portlet - 是否可以在 Plone 4.1 中使用 Five.grok 来注册 portlet?