卷曲以添加索引模式和 json 文件以创建仪表板
Curl to add an index pattern and a json file to create dashboard
我想使用 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}
已解决:
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
得到答案,如果您有安全的 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-*"}}'
应该至少有一个索引符合我们的索引模式并且在索引下应该至少有一个条目。
我想使用 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}
已解决:
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
得到答案,如果您有安全的 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-*"}}'
应该至少有一个索引符合我们的索引模式并且在索引下应该至少有一个条目。