mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 11:05:39 -04:00
Developer guide - index patterns key concepts (#96017)
* add index patterns key concepts
This commit is contained in:
parent
2ee11db1fa
commit
2e68ce1a05
4 changed files with 122 additions and 461 deletions
86
dev_docs/tutorials/data_views.mdx
Normal file
86
dev_docs/tutorials/data_views.mdx
Normal file
|
@ -0,0 +1,86 @@
|
|||
---
|
||||
id: kibDevTutorialDataViews
|
||||
slug: /kibana-dev-docs/tutorials/data-views
|
||||
title: Data views API
|
||||
summary: Data views API
|
||||
date: 2021-08-11
|
||||
tags: ['kibana', 'onboarding', 'dev', 'architecture']
|
||||
---
|
||||
|
||||
*Note: Kibana index patterns are currently being renamed to data views. There will be some naming inconsistencies until the transition is complete.*
|
||||
|
||||
### Data views API
|
||||
|
||||
- Get list of data views
|
||||
- Get default data view and examine fields
|
||||
- Get data view by id
|
||||
- Find data view by title
|
||||
- Create data view
|
||||
- Create data view and save it
|
||||
- Modify data view and save it
|
||||
- Delete data view
|
||||
|
||||
#### Get list of data view titles and ids
|
||||
|
||||
```
|
||||
const idsAndTitles = await data.indexPatterns.getIdsWithTitle();
|
||||
idsAndTitles.forEach(({id, title}) => console.log(`Data view id: ${id} title: ${title}`));
|
||||
```
|
||||
|
||||
#### Get default data view and examine fields
|
||||
|
||||
```
|
||||
const defaultDataView = await data.indexPatterns.getDefault();
|
||||
defaultDataView.fields.forEach(({name}) => { console.log(name); })
|
||||
```
|
||||
|
||||
#### Get data view by id
|
||||
|
||||
```
|
||||
const id = 'xxxxxx-xxx-xxxxxx';
|
||||
const dataView = await data.indexPatterns.get(id);
|
||||
```
|
||||
|
||||
#### Find data view by title
|
||||
|
||||
```
|
||||
const title = 'kibana-*';
|
||||
const [dataView] = await data.indexPatterns.find(title);
|
||||
```
|
||||
|
||||
#### Create data view
|
||||
|
||||
```
|
||||
const dataView = await data.indexPatterns.create({ title: 'kibana-*' });
|
||||
```
|
||||
|
||||
#### Create data view and save it immediately
|
||||
|
||||
```
|
||||
const dataView = await data.indexPatterns.createAndSave({ title: 'kibana-*' });
|
||||
```
|
||||
|
||||
#### Create data view, modify, and save
|
||||
|
||||
```
|
||||
const dataView = await data.indexPatterns.create({ title: 'kibana-*' });
|
||||
dataView.setFieldCustomLabel('customer_name', 'Customer Name');
|
||||
data.indexPatterns.createSavedObject(dataView);
|
||||
```
|
||||
|
||||
#### Modify data view and save it
|
||||
|
||||
```
|
||||
dataView.setFieldCustomLabel('customer_name', 'Customer Name');
|
||||
await data.indexPatterns.updateSavedObject(dataView);
|
||||
```
|
||||
|
||||
#### Delete index pattern
|
||||
|
||||
```
|
||||
await data.indexPatterns.delete(dataViewId);
|
||||
```
|
||||
|
||||
### Data view HTTP API
|
||||
|
||||
Rest-like HTTP CRUD+ API - [docs](https://www.elastic.co/guide/en/kibana/master/index-patterns-api.html)
|
Loading…
Add table
Add a link
Reference in a new issue