Adding new index-pattern in Kibana through REST API

Hi

I'm upgrading from 5.6.13 to 7.0.0. I came to know there are few breaking changes.
Earlier I use to have a script to create index-pattern, visualizations, dashboards through REST API

Can you direct me a sample to do the same in 7

Regards
Ram

As an example , I have tried to create new visualization using below

curl -XPOST "http://localhost:9200/.kibana/_doc" -H 'Content-Type: application/json' -d'
{
"visualization" :{

"title": "Test",
"visState": "{....}",
"uiStateJSON": "{.....}",
"description": "",
"version": 1,
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{"index":"testindex","query":{"match_all":{}},"filter":}"
},
"type": "visualization"
}
}'

I'm getting below error

"reason": "mapping set to strict, dynamic introduction of [type] within [visualization] is not allowed"

If I dont give "type", my visualizations are not getting listed in UI, though it got added successfully

Ironically "type" is working fine when I give for index-pattern as below

POST .kibana/_doc
{
"index-pattern" :{"title" : "test",
"timeFieldName" :"createdat",
"type": "index-pattern"
}

}

Moving to Kibana forum - this is essentially an issue with how Kibana visualizations are stored internally and their changing document format.

Can some one reply please??

The problem you have is that the documents you present do not adhere to a schema (mapping). The schema is not formally documented and published because it is subject to change. However if you use the _mapping api in elasticsearch you can probably reverse engineer what fields are defined in your version.

I thought mapping doesn't matter, as elasticsearch is flexible. I can give only fields I want.

But , is that the reason blocking me to create new visualization through POST/PUT API??

So is it possible to create visualization through API (which I was doing in 5.6.13 ) in 7.0.0? If yes, please share an example. I will adhere to that mapping schema

Mappings can be made strict which is what is happening here. What would be the point of your application sending the wrong fields and not being made aware of that failure?

Yes

See my previous comment about using the _mapping api to discover the schema in effect. Or - create a visualization manually in Kibana, save it, then find the saved JSON and copy as appropriate.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.