Skip to content

支持按org划分数据以及外部数据接入 #546

@junotx

Description

@junotx

参考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>

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions