ES 账号权限
给网关一个专用的 Elasticsearch 账号:读你的日志索引,读写它自己的 .rst_copilot_* 索引,可选读告警和 osquery 结果。附 Kibana 建角色的步骤和 API 写法。
网关对你的日志索引只读,自己的状态全部写在 .rst_copilot_* 前缀下(12 个隐藏索引,用通配一次覆盖)。建一个专用账号,别用 elastic 超级用户。
角色定义
| 索引模式 | 权限 | 用途 | 必需 |
|---|---|---|---|
你的日志索引,如 logs-*, filebeat-*, winlogbeat-* | read, view_index_metadata | 智能查询、字段字典、调查取证 | ✅ |
.rst_copilot_* | create_index, read, write, manage | 审计、会话、知识库、学习库、报告、分析记录、告警、游标、通知配置与队列、资产、用户状态 | ✅ |
.alerts-security.alerts-*, .internal.alerts-security.alerts-* | read, view_index_metadata | 实时告警轮询拉取、批量分诊 | 用告警时 |
logs-osquery_manager.result-* | read, view_index_metadata | 基线巡检 | 用基线时 |
baseline-* | create_index, read, write, manage | 基线的规则 / 结果 / 轮次 | 用基线时 |
集群权限:monitor(平台健康的集群级检查和「列出索引」需要它;没有的话那些检查显示「查不了」,其余功能不受影响)。
.alerts-security.alerts-* 这类是隐藏索引,Kibana 角色页的索引下拉不会自动补全,把模式手敲进去按回车即可,不需要「包含受限索引」开关。
用 Kibana 建
Stack Management → Security → Roles → Create role,名字 rst_copilot_gateway。
Cluster privileges 勾 monitor。
Index privileges 按上表逐行加:一行一组索引模式 + 权限。
Users → Create user,用户名 rst_copilot_gateway,分配这个角色。
把账号密码填进 .env 的 ES_USER / ES_PASSWORD,或在系统设置里「测试连接」后保存。
用 API 建
PUT _security/role/rst_copilot_gateway
{
"cluster": ["monitor"],
"indices": [
{ "names": ["logs-*", "filebeat-*", "winlogbeat-*"], "privileges": ["read", "view_index_metadata"] },
{ "names": [".rst_copilot_*", "baseline-*"], "privileges": ["create_index", "read", "write", "manage"] },
{ "names": [".alerts-security.alerts-*", ".internal.alerts-security.alerts-*", "logs-osquery_manager.result-*"], "privileges": ["read", "view_index_metadata"] }
]
}
PUT _security/user/rst_copilot_gateway
{ "password": "<强密码>", "roles": ["rst_copilot_gateway"] }验证
curl -k https://<域名>/readyzes_write 必须是 ok。denied = 缺 .rst_copilot_* 的建 / 写权限,网关日志里会有 es_write_denied。系统设置的「测试连接」如果提示「这个账号列不出索引」,是缺 monitor 或目标索引的 read。
索引白名单
权限决定网关能读什么;RST_INDEX_WHITELIST(或系统设置里的索引白名单)决定它会读什么。两层都设:账号只给必要的索引,白名单再收一层。模型试图查白名单外的索引会被拒绝,告警调查的检索过程里能看到这类拒绝。