参考https://cwiki.yunify.com/pages/viewpage.action?pageId=197085143 方案二实现 - [ ] `orgId`的表示 - 引入新的Org CRD。使用Org CR创建或删除`orgId`(命名上受K8S CR名称的约束) - Remote Write请求和查询请求时使用`X-Scope-OrgID` header来标记`orgId` - 指标数据存储时以`org_id`标签来标记`orgId` - 系统Org CR,名称默认为`system-org`,默认创建 - [ ] org-ingester(接收外部数据) - 相应的Ingester CR使用`org-<orgId>`前缀命名,与clusters对应的ingesters(称作cluster-ingester)进行区分 - 引入新的org-controller: (以下忽略系统Org CR) - 在新Org CR创建后为其生成Ingester CR - Org CR删除时其对应的Ingester CR需要同步删除 - [ ] cluster-ingester(接收内部数据) - `--labels`中加上`org_id="system-org"`以标记数据所属的Org - [ ] org-router(路由外部数据到org-ingester) - 相应的Router CR使用`org-`前缀命名,以与旧的Router CR(称作cluster-router)进行区分 - 更新router-controller: - 为org-router生成hashring配置,包含所有org-ingester(cluster-router则对应所有cluster-ingester) - [ ] gateway: - `/{cluster}/api/v1/receive`接收cluster的数据,属于系统Org,代理到cluster-router - `/api/v1/receive`,通过`X-Scope-OrgID` header识别Org - org `system-org`的数据代理到cluster-router - 其他org的数据代理到org-router - `/{cluster}/api/v1/query`等api查询cluster的数据,属于系统Org,在promql或matchers条件中注入`org_id=~"system-org|"`(这里包含org_id为空的情况以兼容旧数据) - `/api/v1/query`等api查询所有数据,通过`X-Scope-OrgID` header识别Org,在promql或matchers条件中注入`org_id="<orgId>"` - [ ] whizard-telemetry-apiserver: - 监控查询请求的header中添加`X-Scope-OrgID: system-org`,或promql/matchers中包含`org_id="system-org"` - [ ] whizard-alerting: - RuleGroups/ClusterRuleGroups->PrometheusRules时promql中注入`org_id="system-org"` - 支持外部Org数据的告警 - GlobalRuleGroups中支持配置orgId - kse-console支持在配置全局规则时选择orgId(需设计、前端介入): - 选择`kse-system`时,支持按模板配置规则,支持自定义规则时选择集群等 - 选择其他org时,仅支持自定义规则 - 转换到PrometheusRules时promql注入`org_id="<orgId>"` - 转换到PrometheusRules时labels中加上`org_id: <orgId>`标签 - remote write ALERTS指标时应将ALERTS中的`org_id: <orgId>`标签转换到加上header `X-Scope-OrgID: <orgId>`上 - 此时还需要考虑在orgId为系统Org时如何将cluster标签放在header上,可参考https://github.com/thanos-io/thanos/pull/7256 在cluster-router上处理
参考https://cwiki.yunify.com/pages/viewpage.action?pageId=197085143 方案二实现
orgId的表示orgId(命名上受K8S CR名称的约束)X-Scope-OrgIDheader来标记orgIdorg_id标签来标记orgIdsystem-org,默认创建org-ingester(接收外部数据)
org-<orgId>前缀命名,与clusters对应的ingesters(称作cluster-ingester)进行区分cluster-ingester(接收内部数据)
--labels中加上org_id="system-org"以标记数据所属的Orgorg-router(路由外部数据到org-ingester)
org-前缀命名,以与旧的Router CR(称作cluster-router)进行区分gateway:
/{cluster}/api/v1/receive接收cluster的数据,属于系统Org,代理到cluster-router/api/v1/receive,通过X-Scope-OrgIDheader识别Orgsystem-org的数据代理到cluster-router/{cluster}/api/v1/query等api查询cluster的数据,属于系统Org,在promql或matchers条件中注入org_id=~"system-org|"(这里包含org_id为空的情况以兼容旧数据)/api/v1/query等api查询所有数据,通过X-Scope-OrgIDheader识别Org,在promql或matchers条件中注入org_id="<orgId>"whizard-telemetry-apiserver:
X-Scope-OrgID: system-org,或promql/matchers中包含org_id="system-org"whizard-alerting:
org_id="system-org"kse-system时,支持按模板配置规则,支持自定义规则时选择集群等org_id="<orgId>"org_id: <orgId>标签org_id: <orgId>标签转换到加上headerX-Scope-OrgID: <orgId>上