Documentation ¶
Index ¶
- Constants
- func BodyMd5(jsonstring string) string
- func GetRequestPath(entity string, project string, id string) string
- func InitBaseHeader(v *http.Request)
- type ActionGroup
- type ActionsModel
- type AlarmHistoryItem
- type AlarmItem
- type AlertActionsModel
- type AlertRequest
- type CMSClient
- func NewCMSClient(accessKeyId, accessKeySecret string) *CMSClient
- func NewCMSRegionClient(accessKeyId, accessKeySecret string, regionID common.Region) *CMSClient
- func NewClientWithEndpoint(endpoint string, accessKeyId, accessKeySecret string) *CMSClient
- func NewClientWithRegion(endpoint string, accessKeyId, accessKeySecret string, regionID common.Region) *CMSClient
- func (client *CMSClient) CreateAlarm(args *CreateAlarmArgs) (*CreateAlarmResponse, error)
- func (client *CMSClient) DeleteAlarm(id string) error
- func (client *CMSClient) DisableAlarm(id string) error
- func (client *CMSClient) EnableAlarm(id string) error
- func (client *CMSClient) ListAlarm(args *ListAlarmArgs) (*ListAlarmResponse, error)
- func (client *CMSClient) ListAlarmHistory(args *ListAlarmHistoryArgs) (*ListAlarmHistoryResponse, error)
- func (client *CMSClient) ListContactGroup(args *ListContactGroupArgs) (*ListContactGroupResponse, error)
- func (client *CMSClient) UpdateAlarm(args *UpdateAlarmArgs) error
- type Client
- func (c *Client) CreateAlert(projectName string, alertRequest AlertRequest) (result ResultModel, err error)
- func (c *Client) CreateAlert4Json(projectName string, request string) (result ResultModel, err error)
- func (c *Client) CreateAlertDimension(projectName string, request DimensionRequest) (result ResultModel, err error)
- func (c *Client) CreateProject(projectName string, projectDesc string, projectOwner string) (result ResultModel, err error)
- func (c *Client) DeleteAlert(projectName string, alertName string) (result ResultModel, err error)
- func (c *Client) DeleteAlertDimension(projectName string, alertName string, dimensionId string) (result ResultModel, err error)
- func (c *Client) DeleteProject(projectName string) (result ResultModel, err error)
- func (client *Client) GetAccessKey() string
- func (client *Client) GetAccessSecret() string
- func (c *Client) GetAlert(projectName string, alertName string) (result GetProjectResult, err error)
- func (c *Client) GetAlertList(page string, pageSize string, projectName string, alertName string) (result GetProjectResult, err error)
- func (client *Client) GetApiUri() string
- func (c *Client) GetDimensions(projectName string, alertName string) (result GetDimenstionResult, err error)
- func (c *Client) GetProject(projectName string) (result GetProjectResult, err error)
- func (c *Client) GetProjectList(page string, pageSize string, projectOwner string) (result ProjectListResultModel, err error)
- func (c *Client) GetResponseJson(method string, requestUrl string, requestPath string, body string) (responseBody string, err error)
- func (client *Client) GetUrl(entity string, project string, id string) string
- func (c *Client) PutMetrics(projectName string, request string) (result ResultModel, err error)
- func (client *Client) SetDebug(debug bool)
- func (client *Client) SetSecurityToken(securityToken string)
- func (client *Client) SetTransport(transport http.RoundTripper)
- func (client *Client) Sign(method string, url string, req *http.Request, querys string)
- func (c *Client) UpdateAlert(projectName string, alertName string, alertRequest AlertRequest) (result ResultModel, err error)
- func (c *Client) UpdateProject(projectName string, project *ProjectModel) (result ResultModel, err error)
- type CommonAlarmItem
- type CommonAlarmResponse
- type ConditionModel
- type CreateAlarmArgs
- type CreateAlarmResponse
- type DeleteAlarmArgs
- type DeleteAlarmResponse
- type DimensionDataPoint
- type DimensionRequest
- type DisableAlarmArgs
- type DisableAlarmResponse
- type EnableAlarmArgss
- type EnableAlarmResponse
- type EscalationsModel
- type Failure
- type GetDimenstionResult
- type GetProjectResult
- type ListAlarmArgs
- type ListAlarmHistoryArgs
- type ListAlarmHistoryResponse
- type ListAlarmResponse
- type ListContactGroupArgs
- type ListContactGroupResponse
- type ListProjectRequestModel
- type ProjectListResultModel
- type ProjectModel
- type ProjectResultModel
- type ResultModel
- type UpdateAlarmArgs
- type UpdateAlarmResponse
Constants ¶
const ( HEADER_SEPERATER = "\n" ACS_PREFIX = "x-acs" )
const ( //TODO 旧的API,暂时保留 DefaultEndpoint = "http://alert.aliyuncs.com" APIVersion = "2015-08-15" METHOD_GET = "GET" METHOD_POST = "POST" METHOD_PUT = "PUT" METHOD_DELETE = "DELETE" CMSDefaultEndpoint = "http://metrics.cn-hangzhou.aliyuncs.com" CMSAPIVersion = "2017-03-01" CMSServiceCode = "cms" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ActionGroup ¶
type ActionsModel ¶
type ActionsModel struct { AlertActions []AlertActionsModel `json:"alertActions"` Effective string `json:"effective"` Failure ActionGroup `json:"failure"` }
type AlarmHistoryItem ¶
type AlarmHistoryItem struct { Id string //报警规则id Name string //报警规则名称 Namespace string //产品名称,参考各产品对应的project,例如acs_ecs_dashboard, acs_rds_dashboard等 MetricName string //相应产品对应的监控项名称,参考各产品metric定义 Dimension string //报警规则对应实例列表,为json array对应的string,例如[{“instanceId”:”name1”},{“iinstance”:”name2”}] EvaluationCount int //连续探测几次都满足阈值条件时报警,默认3次 Value string //报警的当前值 AlarmTime int64 //发生报警的时间 LastTime int64 //报警持续时间,单位为毫秒 State string //报警规则状态,有OK,ALARM,INSUFFICIENT_DATA三种状态 Status int //通知发送状态,0为已通知用户,1为不在生效期未通知,2为处于报警沉默期未通知 ContactGroups string //发出的报警通知的通知对象,json array对应的字符串,例如[“联系组1”:”联系组2”],只有通知状态为0才有该字段 }
type AlarmItem ¶
type AlarmItem struct { Id string //报警规则id Enable bool //该规则是否启用,true为启动 State string //报警规则的状态,有一个实例报警就是ALARM,所有都没数据是INSUFFICIENT_DATA,其它情况为OK CommonAlarmItem }
type AlertActionsModel ¶
type AlertRequest ¶
type AlertRequest struct { Name string `json:"name"` Status int `json:"status"` Actions ActionsModel `json:"actions"` Condition ConditionModel `json:"condition"` Enable bool `json:"enable"` Escalations []EscalationsModel `json:"escalations"` }
alert请求结构
type CMSClient ¶
func NewCMSClient ¶
NewClient creates a new instance of CMS client
func NewCMSRegionClient ¶
func NewClientWithEndpoint ¶
func NewClientWithRegion ¶
func (*CMSClient) CreateAlarm ¶
func (client *CMSClient) CreateAlarm(args *CreateAlarmArgs) (*CreateAlarmResponse, error)
see doc at https://help.aliyun.com/document_detail/51910.html?spm=5176.doc51912.6.627.61vKOf
func (*CMSClient) DeleteAlarm ¶
see doc at https://help.aliyun.com/document_detail/51912.html?spm=5176.doc51915.6.628.ozEQet
func (*CMSClient) DisableAlarm ¶
see doc at https://help.aliyun.com/document_detail/51914.html?spm=5176.doc51915.6.630.YUybwN
func (*CMSClient) EnableAlarm ¶
see doc at https://help.aliyun.com/document_detail/51913.html?spm=5176.doc51910.6.631.3zgHyK
func (*CMSClient) ListAlarm ¶
func (client *CMSClient) ListAlarm(args *ListAlarmArgs) (*ListAlarmResponse, error)
see doc at https://help.aliyun.com/document_detail/51915.html?spm=5176.doc51914.6.629.Yz4ZjF
func (*CMSClient) ListAlarmHistory ¶
func (client *CMSClient) ListAlarmHistory(args *ListAlarmHistoryArgs) (*ListAlarmHistoryResponse, error)
see doc at https://help.aliyun.com/document_detail/51916.html?spm=5176.doc51911.6.633.KPOcwc
func (*CMSClient) ListContactGroup ¶
func (client *CMSClient) ListContactGroup(args *ListContactGroupArgs) (*ListContactGroupResponse, error)
see doc at https://help.aliyun.com/document_detail/52315.html?spm=5176.doc51916.6.634.TDR72G
func (*CMSClient) UpdateAlarm ¶
func (client *CMSClient) UpdateAlarm(args *UpdateAlarmArgs) error
see doc at https://help.aliyun.com/document_detail/51911.html?spm=5176.doc51913.6.632.IgBO9g
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) CreateAlert ¶
func (c *Client) CreateAlert(projectName string, alertRequest AlertRequest) (result ResultModel, err error)
*
- 创建一个Alert
- @params
- projectName
- AlertRequest 创建模块的模型
- @return
- result 创建返回的模型
- error 错误,如果一切Ok,error为 nil
func (*Client) CreateAlert4Json ¶
func (c *Client) CreateAlert4Json(projectName string, request string) (result ResultModel, err error)
func (*Client) CreateAlertDimension ¶
func (c *Client) CreateAlertDimension(projectName string, request DimensionRequest) (result ResultModel, err error)
func (*Client) CreateProject ¶
func (c *Client) CreateProject(projectName string, projectDesc string, projectOwner string) (result ResultModel, err error)
*
- 创建一个Project
- @params
- ProjectModel 创建模块的模型
- @return
- result 创建返回的模型
- error 错误,如果一切Ok,error为 nil
func (*Client) DeleteAlert ¶
func (c *Client) DeleteAlert(projectName string, alertName string) (result ResultModel, err error)
*
*
func (*Client) DeleteAlertDimension ¶
func (*Client) DeleteProject ¶
func (c *Client) DeleteProject(projectName string) (result ResultModel, err error)
*
- 删除一个Project
- @params
- projectName 创建模块的模型
- @return
- result 返回的模型
- error 错误,如果一切Ok,error为 nil
func (*Client) GetAccessKey ¶
func (*Client) GetAccessSecret ¶
func (*Client) GetAlert ¶
func (c *Client) GetAlert(projectName string, alertName string) (result GetProjectResult, err error)
* 取得一个alert
func (*Client) GetAlertList ¶
func (c *Client) GetAlertList(page string, pageSize string, projectName string, alertName string) (result GetProjectResult, err error)
*
- 取得alertl列表
func (*Client) GetDimensions ¶
func (c *Client) GetDimensions(projectName string, alertName string) (result GetDimenstionResult, err error)
func (*Client) GetProject ¶
func (c *Client) GetProject(projectName string) (result GetProjectResult, err error)
*
- 取得一个Project
- @params
- projectName projectName不能为空
- @return
- result 返回的模型
- error 错误,如果一切Ok,error为 nil
func (*Client) GetProjectList ¶
func (c *Client) GetProjectList(page string, pageSize string, projectOwner string) (result ProjectListResultModel, err error)
*
- 取得一个多个Project
- @params
- page: 页码
- pageSize: 每夜记录条数
- projectOwner 所属用户
- @return
- result 返回的模型
- error 错误,如果一切Ok,error为 nil
func (*Client) GetResponseJson ¶
func (c *Client) GetResponseJson(method string, requestUrl string, requestPath string, body string) (responseBody string, err error)
*
- 发送http请求,去的响应字符串
func (*Client) PutMetrics ¶
func (c *Client) PutMetrics(projectName string, request string) (result ResultModel, err error)
func (*Client) SetSecurityToken ¶
func (*Client) SetTransport ¶
func (client *Client) SetTransport(transport http.RoundTripper)
SetTransport sets transport to the http client
func (*Client) Sign ¶
*
- 这个方法是先POP签名,并写入到协议头中
- @params
- method http方法,GET POST DELETE PUT 等
- url 请求的url
- header http请求头
- querys GET请求参数,则需要设置querys参数
- POP签名
func (*Client) UpdateAlert ¶
func (c *Client) UpdateAlert(projectName string, alertName string, alertRequest AlertRequest) (result ResultModel, err error)
*
- 更新Alert
func (*Client) UpdateProject ¶
func (c *Client) UpdateProject(projectName string, project *ProjectModel) (result ResultModel, err error)
*
- 更新一个Project
- @params
- projectName 创建模块的模型
- project 修改的模型,这个只能修改projectDesc和ProjectOwer
- @return
- result 返回的模型
- error 错误,如果一切Ok,error为 nil
type CommonAlarmItem ¶
type CommonAlarmItem struct { Name string //报警规则名称 Namespace string //产品名称,参考各产品对应的project,例如acs_ecs_dashboard, acs_rds_dashboard等 MetricName string //相应产品对应的监控项名称,参考各产品metric定义 Dimensions string //报警规则对应实例列表,为json array对应的string,例如[{“instanceId”:”name1”},{“iinstance”:”name2”}] Period int //查询指标的周期,必须与定义的metric一致,默认300,单位为秒 Statistics string //统计方法,必须与定义的metric一致,例如Average ComparisonOperator string //报警比较符,只能为以下几种<=,<,>,>=,==,!= Threshold string //报警阈值,目前只开放数值类型功能 EvaluationCount int //连续探测几次都满足阈值条件时报警,默认3次 ContactGroups string //报警规则通知的联系组,必须在控制台上已创建,为json array对应的string,例如 [“联系组1”,”联系组2”] StartTime int //报警生效时间的开始时间,默认0,代表0点 EndTime int //报警生效时间的结束时间,默认24,代表24点 SilenceTime int //一直处于报警状态的通知沉默周期,默认86400,单位s,最小1小时 NotifyType int //通知类型,为0是旺旺+邮件,为1是旺旺+邮件+短信 }
type CommonAlarmResponse ¶
type ConditionModel ¶
type CreateAlarmArgs ¶
type CreateAlarmArgs struct {
CommonAlarmItem
}
type CreateAlarmResponse ¶
type CreateAlarmResponse struct { CommonAlarmResponse Data string }
type DeleteAlarmArgs ¶
type DeleteAlarmArgs struct {
Id string
}
type DeleteAlarmResponse ¶
type DeleteAlarmResponse struct { CommonAlarmResponse Data string }
type DimensionDataPoint ¶
type DimensionRequest ¶
type DisableAlarmArgs ¶
type DisableAlarmArgs struct {
Id string
}
type DisableAlarmResponse ¶
type DisableAlarmResponse struct {
CommonAlarmResponse
}
type EnableAlarmArgss ¶
type EnableAlarmArgss struct {
Id string
}
type EnableAlarmResponse ¶
type EnableAlarmResponse struct {
CommonAlarmResponse
}
type EscalationsModel ¶
type GetDimenstionResult ¶
type GetDimenstionResult struct { Code string `json:"code"` Success bool `json:"success"` Message string `json:"comessagede,omitempty"` TraceId string `json:"traceId"` DataPoints []*DimensionDataPoint `json:"datapoints,omitempty"` }
type GetProjectResult ¶
type GetProjectResult struct { Result ProjectResultModel `json:"result"` Code string `json:"code"` Success bool `json:"success"` }
返回的实体类型
type ListAlarmArgs ¶
type ListAlarmArgs struct { Id string //报警规则的id Name string //报警规则名称,支持模糊查询 Namespace string //产品名称,参考各产品对应的project,例如 acs_ecs_dashboard, acs_rds_dashboard等 Dimensions string //规则关联的实例信息,为json object对应的字符串,例如{“instacnce”:”name1”}。可以查询用于查询关联该实例的所有规则,应用该字段时必须指定Namespace State string //报警规则状态, ALARM, INSUFFICIENT_DATA,OK IsEnable bool //true为启用,false为禁用 common.Pagination }
type ListAlarmHistoryArgs ¶
type ListAlarmHistoryResponse ¶
type ListAlarmHistoryResponse struct { CommonAlarmResponse Cursor string //查询数据的起始位置,为空则按时间查询前100条 AlarmHistoryList struct { AlarmHistory []AlarmHistoryItem //报警历史详情列表 } }
type ListAlarmResponse ¶
type ListAlarmResponse struct { CommonAlarmResponse NextToken int //下一页,为空代表没有下一页 Total int //符合条件数据总数 AlarmList struct { Alarm []AlarmItem //报警规则详情列表 } }
type ListContactGroupArgs ¶
type ListContactGroupArgs struct {
common.Pagination
}
type ListContactGroupResponse ¶
type ListContactGroupResponse struct { CommonAlarmResponse NextToken string //下一页,为空代表没有下一页 Datapoints []string //联系组名称列表 Total int //符合条件数据总数 }
type ListProjectRequestModel ¶
列表批量取得Project的请求参数
type ProjectListResultModel ¶
type ProjectListResultModel struct { Total int `json:"total"` Datapoints []ProjectResultModel `json:"datapoints"` }
取得多个project的结构
type ProjectModel ¶
type ProjectModel struct { ProjectName string `json:"projectName"` ProjectDesc string `json:"projectDesc"` ProjectOwner string `json:"projectOwner"` }
project的实体类,主要用于发送请求,更新或者添加Project
type ProjectResultModel ¶
type ProjectResultModel struct { ProjectModel Id int64 `json:"id"` GmtModified int64 `json:"gmtModified"` GmtCreate int64 `json:"gmtCreate"` Status int `json:"status"` Creator string `json:"creator"` }
project返回实体,继承于ProjectModel
type ResultModel ¶
type ResultModel struct { Code string `json:"code"` Message string `json:"message"` Success bool `json:"success"` }
调用接口返回的实体 新增加的结构首字母一定要大写,否则json编码或者解析编码会出现问题
type UpdateAlarmArgs ¶
type UpdateAlarmArgs struct { Id string //报警规则的id Name string //报警规则名称 Period int //查询指标的周期,必须与定义的metric一致,默认300,单位为秒 Statistics string //统计方法,必须与定义的metric一致,例如Average ComparisonOperator string //报警比较符,只能为以下几种<=,<,>,>=,==,!= Threshold string //报警阈值,目前只开放数值类型功能 EvaluationCount int //连续探测几次都满足阈值条件时报警,默认3次 ContactGroups string //报警规则通知的联系组,必须在控制台上已创建,为json array对应的string,例如 [“联系组1”,”联系组2”] StartTime int //报警生效时间的开始时间,默认0,代表0点 EndTime int //报警生效时间的结束时间,默认24,代表24点 SilenceTime int //一直处于报警状态的通知沉默周期,默认86400,单位s,最小1小时 NotifyType int //通知类型,为0是旺旺+邮件,为1是旺旺+邮件+短信 }
type UpdateAlarmResponse ¶
type UpdateAlarmResponse struct {
CommonAlarmResponse
}