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

问题描述 投票:0回答:2

我想使用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}
json elasticsearch logstash kibana elastic-stack
2个回答
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


1
投票

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

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

© www.soinside.com 2019 - 2024. All rights reserved.