You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过API为Elasticsearch Kibana指定租户创建index-pattern?

可以实现,你可以通过Kibana Saved Objects API指定租户完成index pattern创建,具体操作如下:

核心逻辑

Kibana的index pattern属于平台存储的saved object,Open Distro安全插件支持通过请求头指定操作的租户,只要在创建请求中携带对应租户标识即可完成指定租户下的index pattern创建。

请求构造说明

  • 请求方法:POST
  • 接口路径:/api/saved_objects/index-pattern/<自定义index pattern唯一ID>
  • 必带请求头:
    • kbn-xsrf: true:Kibana跨域校验必填参数
    • Content-Type: application/json:指定请求体格式
    • securitytenant: <目标租户名称>:值与你创建租户时设置的名称完全一致即可
    • 若开启了Kibana身份认证,还需额外携带基础认证的Authorization头
  • 请求体参数:
    • attributes.title:填写你要关联的索引匹配规则,比如business-log-*
    • attributes.timeFieldName:可选参数,填写该index pattern默认使用的时间字段,比如@timestamp

示例请求(curl格式)

curl -X POST "你的Kibana服务访问地址/api/saved_objects/index-pattern/biz_log_pattern" \
-H "kbn-xsrf: true" \
-H "Content-Type: application/json" \
-H "securitytenant: 目标租户名称" \
-u 你的账号:你的密码 \
-d '{
  "attributes": {
    "title": "business-log-*",
    "timeFieldName": "@timestamp"
  }
}'

注意事项

  • 创建前可调用GET接口/api/saved_objects/_find?type=index-pattern&search_fields=title&search=<你的索引匹配规则>,同样携带securitytenant头,校验目标租户下是否存在重名的index pattern,避免覆盖原有配置
  • 操作账号需要同时具备目标租户的管理权限、对应关联索引的读权限,否则会触发权限报错
  • 如果你使用的是Open Distro后续迭代的OpenSearch套件,对应OpenSearch Dashboards的接口参数完全兼容,无需调整

内容的提问来源于stack exchange,提问作者triptesh_1212

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.25 09:06:05