Spaces method and path for this operation:
post /s/{space_id}/api/data_views/data_view
Refer to Spaces for more information.
Create a data view. Data views identify the Elasticsearch data you want to explore and visualize. They can point to one or more data streams, indices, or index aliases, and use optional runtime fields to compute values at query time. Note that data views are not required for ES|QL-based visualizations. To learn more, refer to the data views documentation.
POST
/api/data_views/data_view
curl
curl \
-X POST "${KIBANA_URL}/api/data_views/data_view" \
-H "Authorization: ApiKey ${API_KEY}" \
-H "kbn-xsrf: true" \
-H "Content-Type: application/json" \
-d '{"data_view":{"title":"logstash-*","name":"My Logstash data view"}}'
POST kbn://api/data_views/data_view
{"data_view":{"title":"logstash-*","name":"My Logstash data view"}}
Request example
Create a data view for logstash indices that includes a runtime field which extracts the shape name from a source field.
{
"data_view": {
"name": "My Logstash data view",
"runtimeFieldMap": {
"runtime_shape_name": {
"script": {
"source": "emit(doc['shape_name'].value)"
},
"type": "keyword"
}
},
"title": "logstash-*"
}
}
Response examples (200)
The response includes the full data view specification, including auto-generated fields such as the unique identifier and version.
{
"data_view": {
"allowNoIndex": false,
"fieldAttrs": {},
"fieldFormats": {},
"fields": {
"runtime_shape_name": {
"aggregatable": true,
"count": 0,
"esTypes": [
"keyword"
],
"format": {
"id": "string"
},
"name": "runtime_shape_name",
"readFromDocValues": false,
"runtimeField": {
"script": {
"source": "emit(doc['shape_name'].value)"
},
"type": "keyword"
},
"scripted": false,
"searchable": true,
"shortDotsEnable": false,
"type": "string"
}
},
"id": "b561acfb-0181-455e-84a3-ce8980b2272f",
"name": "My Logstash data view",
"namespaces": [
"default"
],
"runtimeFieldMap": {
"runtime_shape_name": {
"script": {
"source": "emit(doc['shape_name'].value)"
},
"type": "keyword"
}
},
"sourceFilters": [],
"title": "logstash-*",
"typeMeta": {},
"version": "WzQ5LDJd"
}
}
Response examples (400)
The request was rejected because the payload or query parameters are missing required fields or contain invalid values.
{
"error": "Bad Request",
"message": "[request body.data_view.title]: expected value of type [string] but got [undefined]",
"statusCode": 400
}