apiVersion: observability.openshift.io/v1alpha1
kind: UIPlugin
metadata:
name: dashboards
spec:
type: Dashboards
集群可观测性运算符只是一个技术预览功能。技术预览功能不受 Red Hat 生产服务级别协议 (SLA) 支持,并且可能功能不完整。Red Hat 不建议在生产环境中使用它们。这些功能可以提前访问即将推出的产品功能,使客户能够在开发过程中测试功能并提供反馈。 有关 Red Hat 技术预览功能的支持范围的更多信息,请参阅 技术预览功能支持范围。 |
仪表板 UI 插件在 OpenShift Web 控制台中支持增强的仪表板,位于 **观察** → **仪表板**。除了集群内数据源外,您还可以将集群中的其他 Prometheus 数据源添加到默认仪表板。这将带来跨不同数据源的统一可观测性体验。
该插件从 `openshift-config-managed` 命名空间中具有标签 `console.openshift.io/dashboard-datasource: 'true'` 的 `ConfigMap` 资源中搜索数据源。
您可以作为具有 `cluster-admin` 集群角色的用户访问集群。
您已登录到 OpenShift Container Platform Web 控制台。
您已安装集群可观测性运算符。
在 OpenShift Container Platform Web 控制台中,单击 **运算符** → **已安装运算符** 并选择集群可观测性运算符。
选择 **UI 插件** 选项卡(位于选项卡列表的最右侧)并按 **创建 UIPlugin**。
选择 **YAML 视图**,输入以下内容,然后按 **创建**
apiVersion: observability.openshift.io/v1alpha1
kind: UIPlugin
metadata:
name: dashboards
spec:
type: Dashboards
仪表板 UI 插件从 `openshift-config-managed` 命名空间中具有标签 `console.openshift.io/dashboard-datasource: 'true'` 的 `ConfigMap` 资源中搜索数据源。`ConfigMap` 资源必须定义数据源类型和可以从中获取数据的集群内服务。
您可以作为具有 `cluster-admin` 集群角色的用户访问集群。
您已登录到 OpenShift Container Platform Web 控制台。
您已安装集群可观测性运算符。
您已安装仪表板 UI 插件。
在 `openshift-config-managed` 命名空间中创建一个 `ConfigMap` 资源,并带有标签 `console.openshift.io/dashboard-datasource: 'true'`。以下示例来自 prometheus-datasource-example.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: cluster-prometheus-proxy
namespace: openshift-config-managed
labels:
console.openshift.io/dashboard-datasource: "true"
data:
"dashboard-datasource.yaml": |-
kind: "Datasource"
metadata:
name: "cluster-prometheus-proxy"
project: "openshift-config-managed"
spec:
plugin:
kind: "prometheus"
spec:
direct_url: "https://prometheus-k8s.openshift-monitoring.svc.cluster.local:9091"
配置连接到数据源的自定义仪表板。示例仪表板的 YAML 可在 prometheus-dashboard-example.yaml 中找到。出于演示目的,下面显示了该文件的一个摘录
apiVersion: v1
kind: ConfigMap
metadata:
name: dashboard-example
namespace: openshift-config-managed
labels:
console.openshift.io/dashboard: "true"
data:
k8s-resources-workloads-namespace.json: |-
{
"annotations": {
"list": [
]
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"hideControls": false,
"links": [
],
"refresh": "10s",
"rows": [
{
"collapse": false,
"height": "250px",
"panels": [
{
"aliasColors": {
},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": {
"name": "cluster-prometheus-proxy",
"type": "prometheus"
},
"fill": 10,
"id": 1,
"interval": "1m",
"legend": {
"alignAsTable": true,
"avg": false,
"current": false,
"max": false,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 0,
"links": [
],
"nullPointMode": "null as zero",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [
{
"alias": "quota - requests",
"color": "#F2495C",
"dashes": true,
"fill": 0,
"hiddenSeries": true,
"hideTooltip": true,
"legend": true,
"linewidth": 2,
"stack": false
},
{
"alias": "quota - limits",
"color": "#FF9830",
"dashes": true,
"fill": 0,
"hiddenSeries": true,
"hideTooltip": true,
"legend": true,
"linewidth": 2,
"stack": false
}
],
"spaceLength": 10,
"span": 12,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "sum( node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate{cluster=\"$cluster\", namespace=\"$namespace\"}* on(namespace,pod) group_left(workload, workload_type) namespace_workload_pod:kube_pod_owner:relabel{cluster=\"$cluster\", namespace=\"$namespace\", workload_type=\"$type\"}) by (workload, workload_type)",
"format": "time_series",
"intervalFactor": 2,
"legendFormat": "{{workload}} - {{workload_type}}",
"legendLink": null,
"step": 10
},
{
"expr": "scalar(kube_resourcequota{cluster=\"$cluster\", namespace=\"$namespace\", type=\"hard\",resource=\"requests.cpu\"})",
"format": "time_series",
"intervalFactor": 2,
"legendFormat": "quota - requests",
"legendLink": null,
"step": 10
},
{
"expr": "scalar(kube_resourcequota{cluster=\"$cluster\", namespace=\"$namespace\", type=\"hard\",resource=\"limits.cpu\"})",
"format": "time_series",
"intervalFactor": 2,
"legendFormat": "quota - limits",
"legendLink": null,
"step": 10
}
],
"thresholds": [
],
"timeFrom": null,
"timeShift": null,
"title": "CPU Usage",
"tooltip": {
"shared": false,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": [
]
},
...
点击观察 → 仪表盘,即可看到标题为** DASHBOARD EXAMPLE **的自定义仪表盘,该仪表盘基于prometheus-dashboard-example.yaml
中的配置。
您可以在UI中设置仪表盘的命名空间、时间范围和刷新间隔。
请查看如何在添加新的数据源,详情请参考console-dashboards-plugin GitHub 仓库。