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 @@ -47,6 +47,8 @@
M(StorageBufferBytes) \
M(DictCacheRequests) \
M(Revision) \
M(LogicalCPUCores) \
M(MemoryCapacity) \
M(PSMVCCNumSnapshots) \
M(PSMVCCSnapshotsList) \
M(RWLockWaitingReaders) \
Expand Down
6 changes: 5 additions & 1 deletion dbms/src/Server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ namespace
namespace CurrentMetrics
{
extern const Metric Revision;
}
extern const Metric LogicalCPUCores;
extern const Metric MemoryCapacity;
} // namespace CurrentMetrics

namespace DB
{
Expand Down Expand Up @@ -1424,6 +1426,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
138 changes: 137 additions & 1 deletion metrics/grafana/tiflash_summary.json
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,142 @@
"align": false,
"alignLevel": null
}
},
{
"datasource": "${DS_TEST-CLUSTER}",
"description": "The logical cpu cores per TiFlash instance.",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 12,
"x": 0,
"y": 32
},
"id": 101,
"links": [],
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"text": {},
"textMode": "auto",
"alignmentMode": "center"
},
"pluginVersion": "7.5.7",
"targets": [
{
"exemplar": true,
"expr": "sum(tiflash_system_current_metric_LogicalCPUCores{tidb_cluster=\"$tidb_cluster\", instance=~\"$instance\"}) by (instance)",
JaySon-Huang marked this conversation as resolved.
Show resolved Hide resolved
"format": "time_series",
"interval": "",
"intervalFactor": 2,
"legendFormat": "{{instance}}",
"refId": "A",
"step": 10
}
],
"title": "Logical Cpu Cores",
"type": "stat"
},
{
"datasource": "${DS_TEST-CLUSTER}",
"description": "The memory capacity per TiFlash instance.\n",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 12,
"x": 12,
"y": 32
},
"id": 102,
"links": [],
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"text": {},
"textMode": "auto",
"alignmentMode": "center"
},
"pluginVersion": "7.5.7",
"targets": [
{
"exemplar": true,
"expr": "sum(tiflash_system_current_metric_MemoryCapacity{tidb_cluster=\"$tidb_cluster\", instance=~\"$instance\"}) by (instance) / (1024 * 1024 * 1024)",
"format": "time_series",
"interval": "",
"intervalFactor": 2,
"legendFormat": "{{instance}}",
"refId": "A",
"step": 10
},
{
"hide": false,
"refId": "B"
}
],
"timeFrom": null,
"timeShift": null,
"title": "Memory Capacity (GB)",
"type": "stat"
}
],
"repeat": null,
Expand Down Expand Up @@ -8184,4 +8320,4 @@
"title": "Test-Cluster-TiFlash-Summary",
"uid": "SVbh2xUWk",
"version": 2
}
}