代码之家  ›  专栏  ›  技术社区  ›  C.med

Curl添加索引模式和json文件以创建仪表板

  •  0
  • C.med  · 技术社区  · 7 年前

    我想使用curl命令将索引模式添加到我的kibana索引中。我使用logstash为我的数据编制索引,索引如下所示: logstash-{the current date}

    curl -XPOST "http://localhost:9200/.kibana1/_mappings/_doc/
    {
     "properties": {
             "index-pattern":{
                     "properties":{
                             "title": "logstash*",
                             "timeFieldName": "time"
                     }
               }
     }
    }"
    

    我得到这个错误: curl: (3) [globbing] nested brace in column 67

    我还有一个json文件,我想使用curl将其发送到kibana。

    curl -XPOST "http://localhost:9200/.kibana1/_mappings/_doc/" -H 'Content-Type: application/json' -d'
    {
     "properties": {
             "index-pattern":{
                     "properties":{
                             "title": "logstash*",
                             "timeFieldName": "time"}}}}'
    

    错误:

    {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Expected map for property [fields] on field [title] but got a class java.lang.String"}],"type":"mapper_parsing_exception","reason":"Expected map for property [fields] on field [title] but got a class java.lang.String"},"status":400}
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   C.med    7 年前

    curl -X POST "http://localhost:5601/api/saved_objects/index-pattern/logstash" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d'
     {
    "attributes": {
     "title": "logstash-*","timeFieldName": "time"
     }
    }'
    

    更多信息请点击此处: REST API

    在这里: elastic forum

        2
  •  1
  •   Jitendra Pawar 陈启东    7 年前

    知道答案了,如果你有一个安全的kibana实例

    curl -XPOST -u USERNAME:PASSWORD http://localhost:5601/api/saved_objects/index-pattern/index-pattern -H "Content-Type: application/json" -H "kbn-xsrf: true" -d '{"attributes": {"title": "index-pattern-*"}}'
    

    应该至少有一个索引与我们的索引模式匹配&索引下至少应有一个条目。