【问题标题】:Curl to add an index pattern and a json file to create dashboard卷曲以添加索引模式和 json 文件以创建仪表板
【发布时间】:2019-04-18 08:23:03
【问题描述】:

我想使用 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}

【问题讨论】:

  • 为什么你的最后一个大括号后面有"?
  • 因为在 XPOST 之后有一个 "
  • @rbcvl 我编辑了我的帖子
  • 当您尝试 GET <your_index> 时,您在 Kibana 开发工具中有什么?

标签: json elasticsearch logstash kibana elastic-stack


【解决方案1】:

已解决:

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

【讨论】:

  • 我在上面尝试并得到如下错误{"statusCode":401,"error":"Unauthorized","message":"Unauthorized"} 这是因为我在经过身份验证的 kibana 实例上尝试它。如何登录 kibana 并尝试此 API
【解决方案2】:

得到答案,如果您有一个安全的 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-*"}}'

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

【讨论】:

  • 谢谢,这可以帮助别人。但即使 kibana 中没有索引,它也必须工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-25
  • 1970-01-01
  • 2018-05-24
  • 2020-04-22
相关资源
最近更新 更多