OpenSearch CLI
OpenSearch CLI 命令行界面 (opensearch-cli) 允许您从命令行管理 OpenSearch 集群并自动化任务。
当前,opensearch-cli 支持异常检测和 k-NN 插件,以及任意 REST API 路径。除其他功能外,您可以使用 opensearch-cli 创建和删除检测器、启动和停止它们,以及检查 k-NN 统计信息。
配置文件让您可以轻松访问不同的集群或使用不同的凭证签署请求。opensearch-cli 支持未经身份验证的请求、HTTP 基本签名和 Amazon Web Services 的 IAM 签名。
此示例将检测器 (ecommerce-count-quantity
) 从预演集群移动到生产集群
opensearch-cli ad get ecommerce-count-quantity --profile staging > ecommerce-count-quantity.json
opensearch-cli ad create ecommerce-count-quantity.json --profile production
opensearch-cli ad start ecommerce-count-quantity.json --profile production
opensearch-cli ad stop ecommerce-count-quantity --profile staging
opensearch-cli ad delete ecommerce-count-quantity --profile staging
安装
-
下载并为您的计算机提取相应的安装包。
-
使
opensearch-cli
文件可执行chmod +x ./opensearch-cli
-
将命令添加到您的路径
export PATH=$PATH:$(pwd)
-
确认 CLI 正常工作
opensearch-cli --version
配置文件
配置文件让您可以在不同集群和用户凭证之间轻松切换。要开始使用,请运行 opensearch-cli profile create
并使用 --auth-type
、--endpoint
和 --name
选项
opensearch-cli profile create --auth-type basic --endpoint https://:9200 --name docker-local
或者,将配置文件保存到 ~/.opensearch-cli/config.yaml
profiles:
- name: docker-local
endpoint: https://:9200
user: admin
password: foobar
- name: aws
endpoint: https://some-cluster.us-east-1.es.amazonaws.com
aws_iam:
profile: ""
service: es
用法
opensearch-cli 命令使用以下语法
opensearch-cli <command> <subcommand> <flags>
例如,以下命令检索有关检测器的信息
opensearch-cli ad get my-detector --profile docker-local
对于 OpenSearch CAT API 请求,请尝试以下命令
opensearch-cli curl get --path _cat/plugins --profile aws
使用 -h
或 --help
标志查看所有支持的命令、子命令或特定命令的用法
opensearch-cli -h
opensearch-cli ad -h
opensearch-cli ad get -h