-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
18 changed files
with
3,625 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Tencent is pleased to support the open source community by making | ||
// 蓝鲸智云 - 监控平台 (BlueKing - Monitor) available. | ||
// Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. | ||
// Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at http://opensource.org/licenses/MIT | ||
// 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. | ||
|
||
package monitor | ||
|
||
import ( | ||
"github.com/TencentBlueKing/bk-apigateway-sdks/core/bkapi" | ||
"github.com/TencentBlueKing/bk-apigateway-sdks/core/define" | ||
) | ||
|
||
// Client for metadata | ||
type Client struct { | ||
define.BkApiClient | ||
useBkMonitorApigw bool | ||
} | ||
|
||
// New monitor client | ||
func New(useBkMonitorApigw bool, configProvider define.ClientConfigProvider, opts ...define.BkApiClientOption) (*Client, error) { | ||
client, err := bkapi.NewBkApiClient("monitor_v3", configProvider, opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &Client{BkApiClient: client, useBkMonitorApigw: useBkMonitorApigw}, nil | ||
} | ||
|
||
// SearchAlert for monitor resource search_alert | ||
func (c *Client) SearchAlert(opts ...define.OperationOption) define.Operation { | ||
path := "search_alert" | ||
return c.BkApiClient.NewOperation(bkapi.OperationConfig{ | ||
Name: "search_alert", | ||
Method: "POST", | ||
Path: path, | ||
}, opts...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Tencent is pleased to support the open source community by making | ||
// 蓝鲸智云 - 监控平台 (BlueKing - Monitor) available. | ||
// Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. | ||
// Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at http://opensource.org/licenses/MIT | ||
// 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. | ||
|
||
package monitor | ||
|
||
import ( | ||
"github.com/TencentBlueKing/bkmonitor-datalink/pkg/bk-monitor-worker/internal/api/define" | ||
) | ||
|
||
type SearchAlertResp struct { | ||
define.ApiCommonRespMeta | ||
Data SearchAlertData `json:"data"` | ||
} | ||
|
||
type SearchAlertData struct { | ||
Total int `json:"total"` | ||
Alerts []SearchAlertDataInfo `json:"alerts"` | ||
} | ||
type SearchAlertDataInfo struct { | ||
BkBizID int32 `json:"bk_biz_id"` | ||
BkBizName string `json:"bk_biz_name"` | ||
StrategyID int32 `json:"strategy_id"` | ||
StrategyName string `json:"strategy_name"` | ||
FirstAnomalyTime int64 `json:"first_anomaly_time"` | ||
LatestTime int64 `json:"latest_time"` | ||
EventID string `json:"event_id"` | ||
Status string `json:"status"` | ||
} |
45 changes: 45 additions & 0 deletions
45
pkg/bk-monitor-worker/internal/metadata/apiservice/monitor.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Tencent is pleased to support the open source community by making | ||
// 蓝鲸智云 - 监控平台 (BlueKing - Monitor) available. | ||
// Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. | ||
// Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at http://opensource.org/licenses/MIT | ||
// 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. | ||
|
||
package apiservice | ||
|
||
import ( | ||
"github.com/TencentBlueKing/bkmonitor-datalink/pkg/bk-monitor-worker/internal/api" | ||
"github.com/TencentBlueKing/bkmonitor-datalink/pkg/bk-monitor-worker/internal/api/monitor" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
var Monitor MonitorService | ||
|
||
type MonitorService struct{} | ||
|
||
// SearchAlert 获取告警数据 | ||
func (MonitorService) SearchAlert(conditions []map[string]interface{}, startTime int64, endTime int64, page int, pageSize int, BkBizID int32) (*monitor.SearchAlertData, error) { | ||
monitorApi, err := api.GetMonitorApi() | ||
if err != nil { | ||
return nil, errors.Wrap(err, "GetMonitorApi failed") | ||
} | ||
var resp monitor.SearchAlertResp | ||
var params = map[string]interface{}{ | ||
"bk_biz_ids": []int{int(BkBizID)}, | ||
"start_time": startTime, | ||
"end_time": endTime, | ||
"page": page, | ||
"page_size": pageSize, | ||
"conditions": conditions, | ||
} | ||
_, err = monitorApi.SearchAlert().SetBody(params).SetResult(&resp).Request() | ||
if err != nil { | ||
return nil, errors.Wrap(err, "SearchAlert failed") | ||
} | ||
if err := resp.Err(); err != nil { | ||
return nil, errors.Wrap(err, "SearchAlert failed") | ||
} | ||
return &resp.Data, nil | ||
} |
29 changes: 29 additions & 0 deletions
29
pkg/bk-monitor-worker/internal/metadata/models/slo/alarm_query_config_v2.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Tencent is pleased to support the open source community by making | ||
// 蓝鲸智云 - 监控平台 (BlueKing - Monitor) available. | ||
// Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. | ||
// Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at http://opensource.org/licenses/MIT | ||
// 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. | ||
|
||
package slo | ||
|
||
const TableNameAlarmQueryConfigV2 = "alarm_query_config_v2" | ||
|
||
// AlarmQueryConfigV2 mapped from table <alarm_query_config_v2> | ||
type AlarmQueryConfigV2 struct { | ||
ID int32 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"` | ||
StrategyID int32 `gorm:"column:strategy_id;not null" json:"strategy_id"` | ||
ItemID int32 `gorm:"column:item_id;not null" json:"item_id"` | ||
Alias string `gorm:"column:alias;not null" json:"alias"` | ||
DataSourceLabel string `gorm:"column:data_source_label;not null" json:"data_source_label"` | ||
DataTypeLabel string `gorm:"column:data_type_label;not null" json:"data_type_label"` | ||
MetricID string `gorm:"column:metric_id;not null" json:"metric_id"` | ||
Config string `gorm:"column:config;not null" json:"config"` | ||
} | ||
|
||
// TableName AlarmQueryConfigV2's table name | ||
func (*AlarmQueryConfigV2) TableName() string { | ||
return TableNameAlarmQueryConfigV2 | ||
} |
23 changes: 23 additions & 0 deletions
23
pkg/bk-monitor-worker/internal/metadata/models/slo/alarm_strategy_label_2.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
pkg/bk-monitor-worker/internal/metadata/models/slo/alarm_strategy_v2.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Tencent is pleased to support the open source community by making | ||
// 蓝鲸智云 - 监控平台 (BlueKing - Monitor) available. | ||
// Copyright (C) 2022 THL A29 Limited, a Tencent company. All rights reserved. | ||
// Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at http://opensource.org/licenses/MIT | ||
// 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. | ||
|
||
package slo | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
const TableNameAlarmStrategyV2 = "alarm_strategy_v2" | ||
|
||
//go:generate goqueryset -in alarm_strategy_v2.go -out qs_alarm_strategy_v2_gen.go | ||
|
||
// AlarmStrategyV2 mapped from table <alarm_strategy_v2> | ||
type AlarmStrategyV2 struct { | ||
ID int32 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"` | ||
Name string `gorm:"column:name;not null" json:"name"` | ||
BkBizID int32 `gorm:"column:bk_biz_id;not null" json:"bk_biz_id"` | ||
Source string `gorm:"column:source;not null" json:"source"` | ||
Scenario string `gorm:"column:scenario;not null" json:"scenario"` | ||
Type string `gorm:"column:type;not null" json:"type"` | ||
IsEnabled bool `gorm:"column:is_enabled;not null" json:"is_enabled"` | ||
CreateUser string `gorm:"column:create_user;not null" json:"create_user"` | ||
CreateTime time.Time `gorm:"column:create_time;not null" json:"create_time"` | ||
UpdateUser string `gorm:"column:update_user;not null" json:"update_user"` | ||
UpdateTime time.Time `gorm:"column:update_time;not null" json:"update_time"` | ||
IsInvalid bool `gorm:"column:is_invalid;not null" json:"is_invalid"` | ||
InvalidType string `gorm:"column:invalid_type;not null" json:"invalid_type"` | ||
App string `gorm:"column:app" json:"app"` | ||
Hash string `gorm:"column:hash" json:"hash"` | ||
Path string `gorm:"column:path" json:"path"` | ||
Snippet string `gorm:"column:snippet" json:"snippet"` | ||
Priority int32 `gorm:"column:priority" json:"priority"` | ||
PriorityGroupKey string `gorm:"column:priority_group_key" json:"priority_group_key"` | ||
} | ||
|
||
// TableName AlarmStrategyV2's table name | ||
func (*AlarmStrategyV2) TableName() string { | ||
return TableNameAlarmStrategyV2 | ||
} |
Oops, something went wrong.