SchedulerX针对专业版应用提供了概览时序数据信息查看功能,同时支持通过接口获取相应的数据信息,并且支持集成至自建的Grafana中。本文介绍如何在Grafana中接入概览数据。
前提条件
应用已升级至专业版。具体操作,请参见如何升级为专业版。
自建Grafana集成
在自建Grafana中创建数据源。
安装JSON API数据源插件,创建数据源配置。
- 登录分布式任务调度平台。
在概览页面,单击概览数据读取,复制相应Endpoint地址作为数据源地址并粘贴在对应位置。
导入Dashboard。
在Grafana中通过Import复制下方的JSON文件执行导入,然后单击Load。
{ "__inputs": [ { "name": "DS_SCHEDULERX-OVERVIEW", "label": "SchedulerX-Overview", "description": "", "type": "datasource", "pluginId": "marcusolsson-json-datasource", "pluginName": "JSON API" } ], "__requires": [ { "type": "grafana", "id": "grafana", "name": "Grafana", "version": "8.2.3" }, { "type": "datasource", "id": "marcusolsson-json-datasource", "name": "JSON API", "version": "1.3.4" }, { "type": "panel", "id": "stat", "name": "Stat", "version": "" }, { "type": "panel", "id": "timeseries", "name": "Time series", "version": "" } ], "annotations": { "list": [ { "builtIn": 1, "datasource": "-- Grafana --", "enable": true, "hide": true, "iconColor": "rgba(0, 211, 255, 1)", "name": "Annotations & Alerts", "target": { "limit": 100, "matchAny": false, "tags": [], "type": "dashboard" }, "type": "dashboard" } ] }, "editable": true, "fiscalYearStartMonth": 0, "gnetId": null, "graphTooltip": 0, "id": null, "iteration": 1685010894165, "links": [], "liveNow": false, "panels": [ { "datasource": "${DS_SCHEDULERX-OVERVIEW}", "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null } ] } }, "overrides": [] }, "gridPos": { "h": 8, "w": 24, "x": 0, "y": 0 }, "id": 4, "options": { "colorMode": "value", "graphMode": "area", "justifyMode": "center", "orientation": "auto", "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "/.*/", "values": false }, "text": {}, "textMode": "auto" }, "pluginVersion": "8.2.3", "targets": [ { "cacheDurationSeconds": 60, "fields": [ { "jsonPath": "$.data.schedulerx_job_counter_all", "name": "总任务数" }, { "jsonPath": "$.data.schedulerx_job_counter_enable", "language": "jsonpath", "name": "启用任务数" }, { "jsonPath": "$.data.schedulerx_job_counter_disable", "language": "jsonpath", "name": "禁用任务数" }, { "jsonPath": "$.data.schedulerx_worker_counter", "language": "jsonpath", "name": "在线Worker数" }, { "jsonPath": "$.data.schedulerx_job_trigger_counter_running", "language": "jsonpath", "name": "运行实例数" } ], "method": "GET", "params": [ [ "startTime", "${__from:date:seconds}" ], [ "endTime", "${__to:date:seconds}" ], [ "operate", "query" ], [ "metricType", "0" ], [ "namespace", "${namespace}" ], [ "groupId", "${groupId}" ] ], "queryParams": "", "refId": "A", "urlPath": "" } ], "title": "执行记录汇总", "type": "stat" }, { "datasource": "${DS_SCHEDULERX-OVERVIEW}", "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null } ] } }, "overrides": [] }, "gridPos": { "h": 8, "w": 24, "x": 0, "y": 8 }, "id": 7, "options": { "colorMode": "value", "graphMode": "area", "justifyMode": "center", "orientation": "auto", "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "/.*/", "values": false }, "text": {}, "textMode": "auto" }, "pluginVersion": "8.2.3", "targets": [ { "cacheDurationSeconds": 60, "fields": [ { "jsonPath": "$.data.schedulerx_job_trigger_counter_all", "name": "总触发量" }, { "jsonPath": "$.data.schedulerx_job_trigger_counter_success", "language": "jsonpath", "name": "执行成功" }, { "jsonPath": "$.data.schedulerx_job_trigger_counter_failed", "language": "jsonpath", "name": "执行失败" } ], "method": "GET", "params": [ [ "startTime", "${__from:date:seconds}" ], [ "endTime", "${__to:date:seconds}" ], [ "operate", "query" ], [ "metricType", "1" ], [ "namespace", "${namespace}" ], [ "groupId", "${groupId}" ] ], "queryParams": "", "refId": "A", "urlPath": "" } ], "title": "执行记录汇总", "type": "stat" }, { "datasource": "${DS_SCHEDULERX-OVERVIEW}", "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, "drawStyle": "line", "fillOpacity": 0, "gradientMode": "none", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5, "scaleDistribution": { "type": "linear" }, "showPoints": "auto", "spanNulls": false, "stacking": { "group": "A", "mode": "none" }, "thresholdsStyle": { "mode": "off" } }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] } }, "overrides": [] }, "gridPos": { "h": 10, "w": 24, "x": 0, "y": 16 }, "id": 6, "options": { "legend": { "calcs": [], "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "cacheDurationSeconds": 60, "fields": [ { "jsonPath": "$.data[0].data[*].0", "language": "jsonpath", "name": "", "type": "time" }, { "jsonPath": "$.data[0].data[*].1", "language": "jsonpath", "name": "触发" }, { "jsonPath": "$.data[1].data[*].1", "language": "jsonpath", "name": "失败" }, { "jsonPath": "$.data[2].data[*].1", "language": "jsonpath", "name": "成功" } ], "hide": false, "method": "GET", "params": [ [ "startTime", "${__from:date:seconds}" ], [ "endTime", "${__to:date:seconds}" ], [ "operate", "query_range" ], [ "metricType", "1" ], [ "namespace", "${namespace}" ], [ "groupId", "${groupId}" ] ], "queryParams": "", "refId": "调度触发", "urlPath": "" } ], "title": "触发运行记录", "type": "timeseries" } ], "refresh": "", "schemaVersion": 31, "style": "dark", "tags": [], "templating": { "list": [ { "allValue": "_All_", "current": {}, "datasource": "${DS_SCHEDULERX-OVERVIEW}", "definition": "$.data[*]", "description": "命名空间", "error": null, "hide": 0, "includeAll": true, "label": "命名空间", "multi": false, "name": "namespace", "options": [], "query": { "cacheDurationSeconds": 0, "fields": [ { "jsonPath": "$.data[*]" } ], "method": "GET", "params": [ [ "operate", "query_namespace" ], [ "startTime", "1684132981" ], [ "endTime", "1684132991" ] ], "queryParams": "", "urlPath": "" }, "refresh": 1, "regex": "/\"name\":\"(?<text>[^\"]+)|\"uId\":\"(?<value>[^\"]+)/g", "skipUrlSync": false, "sort": 0, "type": "query" }, { "allValue": "_All_", "current": {}, "datasource": "${DS_SCHEDULERX-OVERVIEW}", "definition": "$.data[*].groupId", "description": "应用分组", "error": null, "hide": 0, "includeAll": true, "label": "应用分组", "multi": false, "name": "groupId", "options": [], "query": { "cacheDurationSeconds": 0, "fields": [ { "jsonPath": "$.data[*].groupId" } ], "method": "GET", "params": [ [ "operate", "query_appgroup" ], [ "startTime", "1684132981" ], [ "endTime", "1684132991" ], [ "namespace", "$namespace" ] ], "queryParams": "", "urlPath": "" }, "refresh": 2, "regex": "", "skipUrlSync": false, "sort": 0, "type": "query" } ] }, "time": { "from": "now-6h", "to": "now" }, "timepicker": {}, "timezone": "", "title": "SCHEDULERX-OVERVIEW", "uid": "bDLXhLyVk", "version": 2 }
进行切换选择,选择第一步中配置的数据源,然后单击Import。
查看导入的Dashboard。
选择对应的命名空间和应用分组即可概览数据信息。
文档内容是否对您有帮助?