Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add logical cpu cores and memory into grafana #5124

Merged
2 changes: 2 additions & 0 deletions dbms/src/Common/CurrentMetrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
M(OpenFileForReadWrite) \
M(MemoryTracking) \
M(MemoryTrackingInBackgroundProcessingPool) \
M(LogicalCPUCores) \
M(MemoryCapacity) \
M(PSMVCCNumSnapshots) \
M(PSMVCCSnapshotsList) \
M(RWLockWaitingReaders) \
Expand Down
8 changes: 8 additions & 0 deletions dbms/src/Server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ namespace
}
} // namespace

namespace CurrentMetrics
{
extern const Metric LogicalCPUCores;
extern const Metric MemoryCapacity;
} // namespace CurrentMetrics

namespace DB
{
namespace ErrorCodes
Expand Down Expand Up @@ -1427,6 +1433,8 @@ int Server::main(const std::vector<std::string> & /*args*/)

{
// on ARM processors it can show only enabled at current moment cores
CurrentMetrics::set(CurrentMetrics::LogicalCPUCores, server_info.cpu_info.logical_cores);
CurrentMetrics::set(CurrentMetrics::MemoryCapacity, server_info.memory_info.capacity);
LOG_FMT_INFO(
log,
"Available RAM = {}; physical cores = {}; logical cores = {}.",
Expand Down
37 changes: 32 additions & 5 deletions metrics/grafana/tiflash_summary.json
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,14 @@
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"seriesOverrides": [
{
"alias": "/limit/",
"fill": 0,
"nullPointMode": "null",
"color": "#C4162A"
}
],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
Expand Down Expand Up @@ -633,6 +640,13 @@
"intervalFactor": 1,
"legendFormat": "{{instance}}",
"refId": "K"
},
{
"expr": "sum(tiflash_system_current_metric_MemoryCapacity{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", instance=~\"$instance\"}) by (instance)",
"legendFormat": "limit-{{instance}}",
"exemplar": true,
"refId": "L",
"hide": false
}
],
"thresholds": [],
Expand Down Expand Up @@ -701,15 +715,15 @@
"hiddenSeries": false,
"id": 51,
"legend": {
"alignAsTable": false,
"alignAsTable": true,
"avg": false,
"current": false,
"current": true,
"max": false,
"min": false,
"rightSide": false,
"rightSide": true,
"show": true,
"total": false,
"values": false
"values": true
},
"lines": true,
"linewidth": 1,
Expand All @@ -728,6 +742,12 @@
"alias": "total",
"fill": 0,
"lines": false
},
{
"alias": "/limit/",
"fill": 0,
"nullPointMode": "null",
"color": "#C4162A"
}
],
"spaceLength": 10,
Expand All @@ -742,6 +762,13 @@
"legendFormat": "{{instance}}",
"refId": "A",
"step": 40
},
{
"expr": "sum(tiflash_system_current_metric_LogicalCPUCores{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", instance=~\"$instance\"}) by (instance)",
"legendFormat": "limit-{{instance}}",
"exemplar": true,
"refId": "B",
"intervalFactor": 1
}
],
"thresholds": [],
Expand Down