2021-10-15 18:09:00 +08:00
|
|
|
// Licensed to the LF AI & Data foundation under one
|
|
|
|
// or more contributor license agreements. See the NOTICE file
|
|
|
|
// distributed with this work for additional information
|
|
|
|
// regarding copyright ownership. The ASF licenses this file
|
|
|
|
// to you under the Apache License, Version 2.0 (the
|
|
|
|
// "License"); you may not use this file except in compliance
|
2021-09-01 10:13:15 +08:00
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
2021-10-15 18:09:00 +08:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2021-09-01 10:13:15 +08:00
|
|
|
//
|
2021-10-15 18:09:00 +08:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2021-09-01 10:13:15 +08:00
|
|
|
|
|
|
|
package datanode
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/commonpb"
|
2022-08-12 13:20:39 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/internalpb"
|
2021-09-01 10:13:15 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/milvuspb"
|
|
|
|
"github.com/milvus-io/milvus/internal/util/metricsinfo"
|
|
|
|
"github.com/milvus-io/milvus/internal/util/typeutil"
|
|
|
|
)
|
|
|
|
|
2022-08-12 13:20:39 +08:00
|
|
|
//getComponentConfigurations returns the configurations of dataNode matching req.Pattern
|
|
|
|
func getComponentConfigurations(ctx context.Context, req *internalpb.ShowConfigurationsRequest) *internalpb.ShowConfigurationsResponse {
|
|
|
|
prefix := "datanode."
|
|
|
|
matchedConfig := Params.DataNodeCfg.Base.GetByPattern(prefix + req.Pattern)
|
|
|
|
configList := make([]*commonpb.KeyValuePair, 0, len(matchedConfig))
|
|
|
|
for key, value := range matchedConfig {
|
|
|
|
configList = append(configList,
|
|
|
|
&commonpb.KeyValuePair{
|
|
|
|
Key: key,
|
|
|
|
Value: value,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return &internalpb.ShowConfigurationsResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_Success,
|
|
|
|
Reason: "",
|
|
|
|
},
|
|
|
|
Configuations: configList,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-01 10:13:15 +08:00
|
|
|
func (node *DataNode) getSystemInfoMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) {
|
|
|
|
// TODO(dragondriver): add more metrics
|
|
|
|
nodeInfos := metricsinfo.DataNodeInfos{
|
|
|
|
BaseComponentInfos: metricsinfo.BaseComponentInfos{
|
2022-04-24 22:03:44 +08:00
|
|
|
Name: metricsinfo.ConstructComponentName(typeutil.DataNodeRole, Params.DataNodeCfg.GetNodeID()),
|
2021-09-03 19:35:47 +08:00
|
|
|
HardwareInfos: metricsinfo.HardwareMetrics{
|
|
|
|
IP: node.session.Address,
|
|
|
|
CPUCoreCount: metricsinfo.GetCPUCoreCount(false),
|
|
|
|
CPUCoreUsage: metricsinfo.GetCPUUsage(),
|
|
|
|
Memory: metricsinfo.GetMemoryCount(),
|
|
|
|
MemoryUsage: metricsinfo.GetUsedMemoryCount(),
|
|
|
|
Disk: metricsinfo.GetDiskCount(),
|
|
|
|
DiskUsage: metricsinfo.GetDiskUsage(),
|
|
|
|
},
|
2021-11-24 15:43:15 +08:00
|
|
|
SystemInfo: metricsinfo.DeployMetrics{},
|
2021-12-23 18:39:11 +08:00
|
|
|
CreatedTime: Params.DataNodeCfg.CreatedTime.String(),
|
|
|
|
UpdatedTime: Params.DataNodeCfg.UpdatedTime.String(),
|
2021-09-17 21:32:47 +08:00
|
|
|
Type: typeutil.DataNodeRole,
|
2021-10-14 11:12:38 +08:00
|
|
|
ID: node.session.ServerID,
|
2021-09-03 19:35:47 +08:00
|
|
|
},
|
|
|
|
SystemConfigurations: metricsinfo.DataNodeConfiguration{
|
2021-12-23 18:39:11 +08:00
|
|
|
FlushInsertBufferSize: Params.DataNodeCfg.FlushInsertBufferSize,
|
2021-09-01 10:13:15 +08:00
|
|
|
},
|
|
|
|
}
|
2021-11-24 15:43:15 +08:00
|
|
|
|
|
|
|
metricsinfo.FillDeployMetricsWithEnv(&nodeInfos.SystemInfo)
|
|
|
|
|
2021-09-01 10:13:15 +08:00
|
|
|
resp, err := metricsinfo.MarshalComponentInfos(nodeInfos)
|
|
|
|
if err != nil {
|
|
|
|
return &milvuspb.GetMetricsResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UnexpectedError,
|
|
|
|
Reason: err.Error(),
|
|
|
|
},
|
|
|
|
Response: "",
|
2022-04-24 22:03:44 +08:00
|
|
|
ComponentName: metricsinfo.ConstructComponentName(typeutil.DataNodeRole, Params.DataNodeCfg.GetNodeID()),
|
2021-09-01 10:13:15 +08:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return &milvuspb.GetMetricsResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_Success,
|
|
|
|
Reason: "",
|
|
|
|
},
|
|
|
|
Response: resp,
|
2022-04-24 22:03:44 +08:00
|
|
|
ComponentName: metricsinfo.ConstructComponentName(typeutil.DataNodeRole, Params.DataNodeCfg.GetNodeID()),
|
2021-09-01 10:13:15 +08:00
|
|
|
}, nil
|
|
|
|
}
|