api調(diào)試地址
https://api.aliyun.com/?spm=a2c4g.11186623.2.16.2f352ef74mLr9A#product=Cms&api=DescribeSiteMonitorData
api監(jiān)控指標(biāo)項(xiàng):
https://help.aliyun.com/document_detail/28619.html?spm=a2c4g.11186623.2.15.67e05679fpgajb#h2-url-31
對接api腳本
安裝基礎(chǔ)依賴
pip?install?aliyun-python-sdk-core
安裝監(jiān)控SDK
pip?install?aliyun-python-sdk-cms
本文主要展示? kafka應(yīng)用和阿里云SLB 應(yīng)用灾锯,其他應(yīng)用雷同
kafka腳本內(nèi)容:
#!/usr/bin/env?python
#coding=utf-8
import?json
import?sys
from?aliyunsdkcore.client?import?AcsClient
from?aliyunsdkcore.acs_exception.exceptions?import?ClientException
from?aliyunsdkcore.acs_exception.exceptions?import?ServerException
from?aliyunsdkcms.request.v20190101.DescribeMetricListRequest?import?DescribeMetricListRequest
def?query_request(Namespace,MetricName):
client?=?AcsClient('xxxx',?'xxxx',?'cn-hangzhou')
request?=?DescribeMetricListRequest()
request.set_accept_format('json')
request.set_MetricName(MetricName)
request.set_Namespace(Namespace)
request.set_Length("1")
response?=?client.do_action_with_exception(request)
Arr?=?json.loads(response)
i?=?eval(Arr['Datapoints'])
for?i?in?eval(Arr['Datapoints']):
if?i.has_key('Maximum'):
print?i['Maximum']
elif?i.has_key('Value'):
print?i['Value']
else:
print?"None"
query_request(sys.argv[1],sys.argv[2])
腳本使用方法:
python? aliapi.py
消息隊(duì)列 Kafka
Project為acs_kafka蹋半,采樣周期為60s,Period賦值為60或60的整數(shù)倍數(shù)澡匪。
Metric監(jiān)控項(xiàng)含義單位Dimensions
instance_disk_capacity實(shí)例磁盤使用率%instanceId
instance_message_input實(shí)例消息生產(chǎn)量byte/sinstanceId
instance_message_output實(shí)例消息消費(fèi)量byte/sinstanceId
topic_message_inputtopic每分鐘消息生產(chǎn)量byte/sinstanceId,topic
topic_message_outputtopic每分鐘消息消費(fèi)量byte/sinstanceId褒链,topic
SLB腳本內(nèi)容:
#!/usr/bin/env?python
#coding=utf-8
import?sys
import?json
from?aliyunsdkcore.client?import?AcsClient
from?aliyunsdkcore.acs_exception.exceptions?import?ClientException
from?aliyunsdkcore.acs_exception.exceptions?import?ServerException
from?aliyunsdkcms.request.v20190101.DescribeMetricListRequest?import?DescribeMetricListRequest
def?query_req(MetricName):
client?=?AcsClient('xxxx',?'xxxxx',?'cn-hangzhou')
request?=?DescribeMetricListRequest()
request.set_accept_format('json')
#request.set_StartTime("2019-05-30?12:00:00")
request.set_Dimensions("{\"instanceId\":\"lb-bp12611tm9yubz6r8duwy\"}")
request.set_Period("60")
request.set_Namespace("acs_slb_dashboard")
request.set_MetricName(MetricName)
request.set_Length("1")
response?=?client.do_action_with_exception(request)
#python2:?print(response)
Arr?=?json.loads(response)
#?print?Arr?#print?dict
i?=?eval(Arr['Datapoints'])
for?i?in?eval(Arr['Datapoints']):
if?i.has_key('Average'):
#????????????????print?i?#print?list
print?i['Average']
elif?i.has_key('Value'):
print?i['Value']
else:
print?"None"
query_req(sys.argv[1])
腳本使用方法:
python? aliapislb.py
負(fù)載均衡 SLB
Project為acs_slb_dashboard唁情,采樣周期為60s,Period賦值為60或60的整數(shù)倍甫匹。
Dimensions中的instanceId賦值SLB實(shí)例的instanceId甸鸟。
Dimensions中的port賦值SLB實(shí)例的端口。
Dimensions中的vip賦值SLB實(shí)例的服務(wù)地址兵迅。
4層協(xié)議監(jiān)控指標(biāo)
Metric描述單位DimensionsStatistics
HeathyServerCount后端健康ECS實(shí)例個數(shù)CountinstanceIdAverage抢韭、Minimum、Maximum
UnhealthyServerCount后端異常ECS實(shí)例個數(shù)CountinstanceIdAverage恍箭、Minimum刻恭、Maximum
PacketTX端口每秒流出數(shù)據(jù)包數(shù)Count/SecondinstanceId, port, vipAverage、Minimum扯夭、Maximum
PacketRX端口每秒流入數(shù)據(jù)包數(shù)Count/SecondinstanceId, port, vipAverage鳍贾、Minimum、Maximum
TrafficRXNew端口每秒流入數(shù)據(jù)量bit/sinstanceId, port, vipAverage交洗、Minimum骑科、Maximum
TrafficTXNew端口每秒流出數(shù)據(jù)量bit/sinstanceId, port, vipAverage、Minimum构拳、Maximum
ActiveConnection端口當(dāng)前活躍連接數(shù)咆爽,既客戶端正在訪問SLB產(chǎn)生的連接CountinstanceId, port, vipAverage梁棠、Minimum、Maximum
InactiveConnection端口當(dāng)前非活躍連接數(shù)伍掀,既訪問SLB后未斷開的空閑的連接CountinstanceId, port, vipAverage掰茶、Minimum、Maximum
NewConnection端口當(dāng)前新建連接數(shù)CountinstanceId, port, vipAverage蜜笤、Minimum濒蒋、Maximum
MaxConnection端口當(dāng)前并發(fā)連接數(shù)CountinstanceId, port, vipAverage、Minimum把兔、Maximum
DropConnection監(jiān)聽每秒丟失連接數(shù)Count/SecondinstanceId, port, vipAverage沪伙、Minimum、Maximum
DropPacketRX監(jiān)聽每秒丟失入包數(shù)Count/SecondinstanceId, port, vipAverage县好、Minimum围橡、Maximum
DropPacketTX監(jiān)聽每秒丟失出包數(shù)Count/SecondinstanceId, port, vipAverage、Minimum缕贡、Maximum
DropTrafficRX監(jiān)聽每秒丟失入bit數(shù)bit/sinstanceId, port, vipAverage翁授、Minimum、Maximum
DropTrafficTX監(jiān)聽每秒丟失出bit數(shù)bit/sinstanceId, port, vipAverage晾咪、Minimum收擦、Maximum
InstanceActiveConnection實(shí)例每秒活躍連接數(shù)Count/SecondinstanceIdAverage、Minimum谍倦、Maximum
InstanceDropConnection實(shí)例每秒丟失連接數(shù)Count/SecondinstanceIdAverage塞赂、Minimum、Maximum
InstanceDropPacketRX實(shí)例每秒丟失入包數(shù)Count/SecondinstanceIdAverage昼蛀、Minimum宴猾、Maximum
InstanceDropPacketTX實(shí)例每秒丟失出包數(shù)Count/SecondinstanceIdAverage、Minimum叼旋、Maximum
InstanceDropTrafficRX實(shí)例每秒丟失入bit數(shù)bit/sinstanceIdAverage仇哆、Minimum、Maximum
InstanceDropTrafficTX實(shí)例每秒丟失出bit數(shù)bit/sinstanceIdAverage夫植、Minimum税产、Maximum
InstanceInactiveConnection實(shí)例每秒非活躍連接數(shù)Count/SecondinstanceIdAverage、Minimum偷崩、Maximum
InstanceMaxConnection實(shí)例每秒最大并發(fā)連接數(shù)Count/SecondinstanceIdAverage辟拷、Minimum、Maximum
InstanceNewConnection實(shí)例每秒新建連接數(shù)Count/SecondinstanceIdAverage阐斜、Minimum衫冻、Maximum
InstancePacketRX實(shí)例每秒入包數(shù)Count/SecondinstanceIdAverage、Minimum谒出、Maximum
InstancePacketTX實(shí)例每秒出包數(shù)Count/SecondinstanceIdAverage隅俘、Minimum邻奠、Maximum
InstanceTrafficRX實(shí)例每秒入bit數(shù)bit/sinstanceIdAverage、Minimum为居、Maximum
InstanceTrafficTX實(shí)例每秒出bit數(shù)bit/sinstanceIdAverage碌宴、Minimum、Maximum
InstanceMaxConnectionUtilization最大連接數(shù)使用率%instanceIdAverage蒙畴、Maximum贰镣、Minimum
InstanceNewConnectionUtilization新建連接數(shù)使用率%instanceIdAverage、Maximum膳凝、Minimum
7層協(xié)議監(jiān)控指標(biāo)
Metric描述單位DimensionsStatistics
Qps端口維度的QPSCount/SecondinstanceId, port, vipAverage
Rt端口維度的請求平均延時msinstanceId, port, vipAverage
StatusCode2xx端口維度的slb返回給client的2xx狀態(tài)碼統(tǒng)計Count/SecondinstanceId, port, vipAverage
StatusCode3xx端口維度的slb返回給client的3xx狀態(tài)碼統(tǒng)計Count/SecondinstanceId, port, vipAverage
StatusCode4xx端口維度的slb返回給client的4xx狀態(tài)碼統(tǒng)計Count/SecondinstanceId, port, vipAverage
StatusCode5xx端口維度的slb返回給client的5xx狀態(tài)碼統(tǒng)計Count/SecondinstanceId, port, vipAverage
StatusCodeOther端口維度的slb返回給client的other狀態(tài)碼統(tǒng)計Count/SecondinstanceId, port, vipAverage
UpstreamCode4xx端口維度的rs返回給slb的4xx狀態(tài)碼統(tǒng)計Count/SecondinstanceId, port, vipAverage
UpstreamCode5xx端口維度的rs返回給client的5xx狀態(tài)碼統(tǒng)計Count/SecondinstanceId, port, vipAverage
UpstreamRt端口維度的rs發(fā)給proxy的平均請求延遲msinstanceId, port, vipAverage
InstanceQps實(shí)例維度的QPSCount/SecondinstanceIdAverage
InstanceRt實(shí)例維度的請求平均延時msinstanceIdAverage
InstanceStatusCode2xx實(shí)例維度的slb返回給client的2xx狀態(tài)碼統(tǒng)計Count/SecondinstanceIdAverage
InstanceStatusCode3xx實(shí)例維度的slb返回給client的3xx狀態(tài)碼統(tǒng)計Count/SecondinstanceIdAverage
InstanceStatusCode4xx實(shí)例維度的slb返回給client4xx狀態(tài)碼統(tǒng)計Count/SecondinstanceIdAverage
InstanceStatusCode5xx實(shí)例維度的slb返回給client的5xx狀態(tài)碼統(tǒng)計Count/SecondinstanceIdAverage
InstanceStatusCodeOther實(shí)例維度的slb返回給client的Other狀態(tài)碼統(tǒng)計Count/SecondinstanceIdAverage
InstanceUpstreamCode4xx實(shí)例維度的rs返回給slb的4xx狀態(tài)碼統(tǒng)計Count/SecondinstanceIdAverage
InstanceUpstreamCode5xx實(shí)例維度的rs返回給slb的5xx狀態(tài)碼統(tǒng)計Count/SecondinstanceIdAverage
InstanceUpstreamRt實(shí)例維度的rs發(fā)給proxy的平均請求延遲msinstanceIdAverage
InstanceQpsUtilizationQPS使用率%instanceIdAverage碑隆、Maximum、Minimum