ELK API common interface
One: Elasticsearch API interface:
1. Cluster API: The cluster API is used to obtain, modify and manage the information of the entire cluster, such as nodes, indexes, mappings and settings.
_cluster/health:获取集群健康状况。
_cluster/stats:获取集群统计信息。
_cluster/settings:获取或修改集群设置。
_cluster/pending_tasks:获取正在等待执行的集群任务。
Index API:索引API,用于管理索引的创建、删除、映射、搜索和更新。
_cat/indices:列出所有索引。
_cat/indices?v:列出所有索引,并显示一些详细信息。
_cat/indices/{index}:获取特定索引的详细信息。
_cat/indices/{index}/docs:获取特定索引的文档数量信息。
_cat/indices/{index}/shards:获取特定索引的分片信息。
_bulk:批量操作索引。
2. Document API: Document API for creating, updating, deleting and searching documents.
index:创建或更新文档。
get:获取文档。
delete:删除文档。
search:搜索文档。
Search API:搜索API,用于搜索和聚合文档。
_search:基本搜索。
_search/scroll:滚动搜索。
_count:计算匹配文档的数量。
_msearch:批量搜索。
_search/template:使用搜索模板搜索。
2. Logstash API interface:
1. Node API: Node API, used to manage Logstash nodes.
_node/stats:获取节点统计信息。
_node/pipelines:获取节点上的管道列表。
_node/{node_id}/stats:获取指定节点的统计信息。
_node/{node_id}/hot_threads:获取指定节点上的热线程信息。
2. Pipeline API: Pipeline API for creating, modifying and deleting Logstash pipelines.
_pipeline/pipeline_id:获取指定管道的配置。
_pipeline/pipeline_id/_simulate:模拟管道运行。
_pipeline/pipeline_id/_clear:清除指定管道的持久队列。
_pipeline/pipeline_id/_reorder:重新排序指定管道中的插件。
3. Kibana API interface:
1. Index API: Index API, used to manage the index in Kibana.
GET /api/saved_objects/index-pattern:获取所有索引模式。
POST /api/saved_objects/index-pattern:创建一个索引模式。
PUT /api/saved_objects/index-pattern/{id}:更新一个索引模式。
DELETE /api/saved_objects/index-pattern/{id}:删除一个索引模式。
2. Visualization API: Visualization API for managing visualization objects in Kibana.
GET /api/saved_objects/visualization:获取所有可视化对象。
POST /api/saved_objects/visualization:创建一个可视化对象。
PUT /api/saved_objects/visualization/{id}:更新一个可视化对象。
DELETE /api/saved_objects/visualization/{id}:删除一个可视化对象
Four, ELK additions, deletions, modifications and inquiries
Elasticsearch's curl command can index, query, and delete through HTTP requests:
1. Index operation:
PUT /index_name/document_type/document_id: Create a new document in the specified index, document_id is optional.
Parameter Description:
index_name:索引名称,必选项。
document_type:文档类型,可选项,建议使用_mapping中定义的类型。
document_id:文档ID,可选项,若不指定系统会自动生成一个唯一ID。
Example:
curl -XPUT 'http://localhost:9200/my_index/my_type/1' -d '{ "title": "Elasticsearch is Awesome", "tags": ["elasticsearch", "bigdata"] }'
2. Search operation:
GET /index_name/_search:搜索所有文档。
GET /index_name/document_type/_search:搜索指定类型的文档。
POST /index_name/document_type/_search:搜索指定类型的文档。
Parameter Description:
index_name:索引名称,必选项。
document_type:文档类型,可选项,建议使用_mapping中定义的类型。
q:查询语句,可选项,支持通配符、逻辑操作符等。
Example:
curl -XGET 'http://localhost:9200/my_index/_search?q=title:elasticsearch'
3. Delete operation:
DELETE /index_name/document_type/document_id:删除指定文档。
DELETE /index_name/document_type:删除指定类型的所有文档。
DELETE /index_name:删除指定索引及其中的所有文档。
Parameter Description:
index_name:索引名称,必选项。
document_type:文档类型,可选项,建议使用_mapping中定义的类型。
document_id:文档ID,可选项,若不指定系统会自动生成一个唯一ID。
Example:
curl -XDELETE 'http://localhost:9200/my_index/my_type/1'
4. Update operation:
POST /index_name/document_type/document_id/_update:更新指定文档。
Parameter Description:
index_name:索引名称,必选项。
document_type:文档类型,可选项,建议使用_mapping中定义的类型。
document_id:文档ID,必选项。
script:脚本,必选项,用于更新文档。
params:脚本中的参数,可选项。
Example:
curl -XPOST 'http://localhost:9200/my_index/my_type/1/_update' -d '{ "script": "ctx._source.title = 'Elasticsearch is Awesome'", "params": {"tag": "bigdata"} }'