From 907e06ad4deaa54d41d40b96be339a2f147465bb Mon Sep 17 00:00:00 2001 From: dmchen Date: Thu, 1 Feb 2024 04:52:54 +0000 Subject: [PATCH] clusterid by taosd --- source/dnode/mnode/impl/src/mndDnode.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index bd0c29f4c8..50bc95f546 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -14,6 +14,7 @@ */ #define _DEFAULT_SOURCE +#include #include "tjson.h" #include "mndDnode.h" #include "audit.h" @@ -500,6 +501,9 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) { SStatisReq statisReq = {0}; int32_t code = -1; + char strClusterId[TSDB_CLUSTER_ID_LEN] = {0}; + sprintf(strClusterId, "%"PRId64, pMnode->clusterId); + if (tDeserializeSStatisReq(pReq->pCont, pReq->contLen, &statisReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; goto _OVER; @@ -546,8 +550,21 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) { *(sample_labels + j) = taosMemoryMalloc(MONITOR_TAG_VALUE_LEN); tjsonGetStringValue(item, "value", *(sample_labels + j)); + if(strncmp(*(labels + j), "cluster_id", MONITOR_TAG_NAME_LEN) == 0) { + strncpy(*(sample_labels + j), strClusterId, MONITOR_TAG_VALUE_LEN); + } } + /* + *(labels + tagSize) = taosMemoryMalloc(MONITOR_TAG_NAME_LEN); + strncpy(*(labels + tagSize), "cluster_id", MONITOR_TAG_NAME_LEN); + + *(sample_labels + tagSize) = taosMemoryMalloc(MONITOR_TAG_VALUE_LEN); + strncpy(*(sample_labels + tagSize), strClusterId, MONITOR_TAG_VALUE_LEN); + + tagSize++; + */ + SJson* metrics = tjsonGetObjectItem(item, "metrics"); int32_t metricLen = tjsonGetArraySize(metrics);