Skip to content

Commit

Permalink
feat: add logical cpu cores and memory into grafana (#5124)
Browse files Browse the repository at this point in the history
close #3821
  • Loading branch information
Lloyd-Pottiger authored Jul 7, 2022
1 parent 57d001c commit fe2b539
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
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

0 comments on commit fe2b539

Please sign in to comment.