MCPcopy Index your code
hub / github.com/APIParkLab/APIPark / GetMonitorConfig

Method GetMonitorConfig

module/monitor/iml.go:1275–1301  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

1273}
1274
1275func (m *imlMonitorConfig) GetMonitorConfig(ctx context.Context) (*monitor_dto.MonitorConfig, error) {
1276 clusterId := cluster.DefaultClusterID
1277 _, err := m.clusterService.Get(ctx, clusterId)
1278 if err != nil {
1279 return nil, err
1280
1281 }
1282 info, err := m.monitorService.GetByCluster(ctx, clusterId)
1283 if err != nil {
1284 if !errors.Is(err, gorm.ErrRecordNotFound) {
1285 return nil, err
1286 }
1287 return &monitor_dto.MonitorConfig{
1288 Driver: "influxdb-v2",
1289 Config: map[string]interface{}{},
1290 }, nil
1291 }
1292 cfg := make(map[string]interface{})
1293 err = json.Unmarshal([]byte(info.Config), &cfg)
1294 if err != nil {
1295 return nil, err
1296 }
1297 return &monitor_dto.MonitorConfig{
1298 Driver: info.Driver,
1299 Config: cfg,
1300 }, nil
1301}
1302
1303func (m *imlMonitorConfig) GetMonitorCluster(ctx context.Context) ([]*monitor_dto.MonitorCluster, error) {
1304 clusters, err := m.clusterService.ListByClusters(ctx)

Callers 1

SaveMonitorConfigMethod · 0.95

Calls 2

GetMethod · 0.65
GetByClusterMethod · 0.65

Tested by

no test coverage detected