clusterid by taosd

This commit is contained in:
dmchen 2024-02-01 04:52:54 +00:00
parent 80d5f35bc5
commit 907e06ad4d
1 changed files with 17 additions and 0 deletions

View File

@ -14,6 +14,7 @@
*/ */
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include <stdio.h>
#include "tjson.h" #include "tjson.h"
#include "mndDnode.h" #include "mndDnode.h"
#include "audit.h" #include "audit.h"
@ -500,6 +501,9 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
SStatisReq statisReq = {0}; SStatisReq statisReq = {0};
int32_t code = -1; int32_t code = -1;
char strClusterId[TSDB_CLUSTER_ID_LEN] = {0};
sprintf(strClusterId, "%"PRId64, pMnode->clusterId);
if (tDeserializeSStatisReq(pReq->pCont, pReq->contLen, &statisReq) != 0) { if (tDeserializeSStatisReq(pReq->pCont, pReq->contLen, &statisReq) != 0) {
terrno = TSDB_CODE_INVALID_MSG; terrno = TSDB_CODE_INVALID_MSG;
goto _OVER; goto _OVER;
@ -546,8 +550,21 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
*(sample_labels + j) = taosMemoryMalloc(MONITOR_TAG_VALUE_LEN); *(sample_labels + j) = taosMemoryMalloc(MONITOR_TAG_VALUE_LEN);
tjsonGetStringValue(item, "value", *(sample_labels + j)); 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"); SJson* metrics = tjsonGetObjectItem(item, "metrics");
int32_t metricLen = tjsonGetArraySize(metrics); int32_t metricLen = tjsonGetArraySize(metrics);