Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions docs/en/operations/system-tables/asynchronous_metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Columns:

- `metric` ([String](../../sql-reference/data-types/string.md)) — Metric name.
- `value` ([Float64](../../sql-reference/data-types/float.md)) — Metric value.
- `description` ([String](../../sql-reference/data-types/string.md) - Metric description)

**Example**

Expand All @@ -17,18 +18,18 @@ SELECT * FROM system.asynchronous_metrics LIMIT 10
```

``` text
┌─metric──────────────────────────────────┬──────value─┐
jemalloc.background_thread.run_interval 0
jemalloc.background_thread.num_runs │ 0 │
jemalloc.background_thread.num_threads │ 0 │
jemalloc.retained │ 422551552
jemalloc.mapped │ 1682989056
jemalloc.resident │ 1656446976
jemalloc.metadata_thp0
jemalloc.metadata │ 10226856
UncompressedCacheCells │ 0
MarkCacheFiles 0
└─────────────────────────────────────────┴────────────┘
┌─metric──────────────────────────────────┬──────value─┬─description────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
AsynchronousMetricsCalculationTimeSpent │ 0.00179053Time in seconds spent for calculation of asynchronous metrics (this is the overhead of asynchronous metrics).
NumberOfDetachedByUserParts │ 0 │ The total number of parts detached from MergeTree tables by users with the `ALTER TABLE DETACH` query (as opposed to unexpected, broken or ignored parts). The server does not care about detached parts and they can be removed.
NumberOfDetachedParts │ 0 │ The total number of parts detached from MergeTree tables. A part can be detached by a user with the `ALTER TABLE DETACH` query or by the server itself it the part is broken, unexpected or unneeded. The server does not care about detached parts and they can be removed.
TotalRowsOfMergeTreeTables │ 2781309 │ Total amount of rows (records) stored in all tables of MergeTree family.
TotalBytesOfMergeTreeTables │ 7741926 │ Total amount of bytes (compressed, including data and indices) stored in all tables of MergeTree family.
NumberOfTables │ 93 │ Total number of tables summed across the databases on the server, excluding the databases that cannot contain MergeTree tables. The excluded database engines are those who generate the set of tables on the fly, like `Lazy`, `MySQL`, `PostgreSQL`, `SQlite`.
NumberOfDatabases 6 │ Total number of databases on the server.
MaxPartCountForPartition 6 │ Maximum number of parts per partition across all partitions of all tables of MergeTree family. Values larger than 300 indicates misconfiguration, overload, or massive data loading.
ReplicasSumMergesInQueue │ 0 │ Sum of merge operations in the queue (still to be applied) across Replicated tables.
ReplicasSumInsertsInQueue 0Sum of INSERT operations in the queue (still to be replicated) across Replicated tables.
└─────────────────────────────────────────┴────────────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
```

**See Also**
Expand Down
32 changes: 32 additions & 0 deletions src/Common/AsynchronousMetrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ AsynchronousMetrics::AsynchronousMetrics(
openFileIfExists("/proc/uptime", uptime);
openFileIfExists("/proc/net/dev", net_dev);

openFileIfExists("/sys/fs/cgroup/memory/memory.limit_in_bytes", cgroupmem_limit_in_bytes);
openFileIfExists("/sys/fs/cgroup/memory/memory.usage_in_bytes", cgroupmem_usage_in_bytes);

openSensors();
openBlockDevices();
openEDAC();
Expand Down Expand Up @@ -879,6 +882,35 @@ void AsynchronousMetrics::update(TimePoint update_time)
}
}

if (cgroupmem_limit_in_bytes && cgroupmem_usage_in_bytes)
{
try {
cgroupmem_limit_in_bytes->rewind();
cgroupmem_usage_in_bytes->rewind();

uint64_t cgroup_mem_limit_in_bytes = 0;
uint64_t cgroup_mem_usage_in_bytes = 0;

readText(cgroup_mem_limit_in_bytes, *cgroupmem_limit_in_bytes);
readText(cgroup_mem_usage_in_bytes, *cgroupmem_usage_in_bytes);

if (cgroup_mem_limit_in_bytes && cgroup_mem_usage_in_bytes)
{
new_values["CgroupMemoryTotal"] = { cgroup_mem_limit_in_bytes, "The total amount of memory in cgroup, in bytes." };
new_values["CgroupMemoryUsed"] = { cgroup_mem_usage_in_bytes, "The amount of memory used in cgroup, in bytes." };
}
else
{
LOG_DEBUG(log, "Cannot read statistics about the cgroup memory total and used. Total got '{}', Used got '{}'.",
cgroup_mem_limit_in_bytes, cgroup_mem_usage_in_bytes);
}
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
}

if (meminfo)
{
try
Expand Down
3 changes: 3 additions & 0 deletions src/Common/AsynchronousMetrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class AsynchronousMetrics
std::optional<ReadBufferFromFilePRead> uptime;
std::optional<ReadBufferFromFilePRead> net_dev;

std::optional<ReadBufferFromFilePRead> cgroupmem_limit_in_bytes;
std::optional<ReadBufferFromFilePRead> cgroupmem_usage_in_bytes;

std::vector<std::unique_ptr<ReadBufferFromFilePRead>> thermal;

std::unordered_map<String /* device name */,
Expand Down