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
對(duì)接api腳本
安裝基礎(chǔ)依賴
pip install aliyun-python-sdk-core
安裝監(jiān)控SDK
pip install aliyun-python-sdk-cms
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 <Project> <Metric>
消息隊(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/s instanceId
instance_message_output 實(shí)例消息消費(fèi)量 byte/s instanceId
topic_message_input topic每分鐘消息生產(chǎn)量 byte/s instanceId宦言,topic
topic_message_output topic每分鐘消息消費(fèi)量 byte/s instanceId滑负,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 <Metric>
負(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 描述 單位 Dimensions Statistics
HeathyServerCount 后端健康ECS實(shí)例個(gè)數(shù) Count instanceId Average、Minimum对人、Maximum
UnhealthyServerCount 后端異常ECS實(shí)例個(gè)數(shù) Count instanceId Average谣殊、Minimum、Maximum
PacketTX 端口每秒流出數(shù)據(jù)包數(shù) Count/Second instanceId, port, vip Average规伐、Minimum蟹倾、Maximum
PacketRX 端口每秒流入數(shù)據(jù)包數(shù) Count/Second instanceId, port, vip Average、Minimum猖闪、Maximum
TrafficRXNew 端口每秒流入數(shù)據(jù)量 bit/s instanceId, port, vip Average、Minimum肌厨、Maximum
TrafficTXNew 端口每秒流出數(shù)據(jù)量 bit/s instanceId, port, vip Average培慌、Minimum、Maximum
ActiveConnection 端口當(dāng)前活躍連接數(shù)柑爸,既客戶端正在訪問SLB產(chǎn)生的連接 Count instanceId, port, vip Average吵护、Minimum、Maximum
InactiveConnection 端口當(dāng)前非活躍連接數(shù)表鳍,既訪問SLB后未斷開的空閑的連接 Count instanceId, port, vip Average馅而、Minimum、Maximum
NewConnection 端口當(dāng)前新建連接數(shù) Count instanceId, port, vip Average譬圣、Minimum瓮恭、Maximum
MaxConnection 端口當(dāng)前并發(fā)連接數(shù) Count instanceId, port, vip Average、Minimum厘熟、Maximum
DropConnection 監(jiān)聽每秒丟失連接數(shù) Count/Second instanceId, port, vip Average屯蹦、Minimum维哈、Maximum
DropPacketRX 監(jiān)聽每秒丟失入包數(shù) Count/Second instanceId, port, vip Average、Minimum登澜、Maximum
DropPacketTX 監(jiān)聽每秒丟失出包數(shù) Count/Second instanceId, port, vip Average阔挠、Minimum、Maximum
DropTrafficRX 監(jiān)聽每秒丟失入bit數(shù) bit/s instanceId, port, vip Average脑蠕、Minimum购撼、Maximum
DropTrafficTX 監(jiān)聽每秒丟失出bit數(shù) bit/s instanceId, port, vip Average、Minimum谴仙、Maximum
InstanceActiveConnection 實(shí)例每秒活躍連接數(shù) Count/Second instanceId Average迂求、Minimum、Maximum
InstanceDropConnection 實(shí)例每秒丟失連接數(shù) Count/Second instanceId Average狞甚、Minimum锁摔、Maximum
InstanceDropPacketRX 實(shí)例每秒丟失入包數(shù) Count/Second instanceId Average、Minimum哼审、Maximum
InstanceDropPacketTX 實(shí)例每秒丟失出包數(shù) Count/Second instanceId Average谐腰、Minimum、Maximum
InstanceDropTrafficRX 實(shí)例每秒丟失入bit數(shù) bit/s instanceId Average涩盾、Minimum十气、Maximum
InstanceDropTrafficTX 實(shí)例每秒丟失出bit數(shù) bit/s instanceId Average、Minimum春霍、Maximum
InstanceInactiveConnection 實(shí)例每秒非活躍連接數(shù) Count/Second instanceId Average砸西、Minimum、Maximum
InstanceMaxConnection 實(shí)例每秒最大并發(fā)連接數(shù) Count/Second instanceId Average址儒、Minimum芹枷、Maximum
InstanceNewConnection 實(shí)例每秒新建連接數(shù) Count/Second instanceId Average、Minimum莲趣、Maximum
InstancePacketRX 實(shí)例每秒入包數(shù) Count/Second instanceId Average鸳慈、Minimum、Maximum
InstancePacketTX 實(shí)例每秒出包數(shù) Count/Second instanceId Average喧伞、Minimum走芋、Maximum
InstanceTrafficRX 實(shí)例每秒入bit數(shù) bit/s instanceId Average、Minimum潘鲫、Maximum
InstanceTrafficTX 實(shí)例每秒出bit數(shù) bit/s instanceId Average翁逞、Minimum、Maximum
InstanceMaxConnectionUtilization 最大連接數(shù)使用率 % instanceId Average溉仑、Maximum挖函、Minimum
InstanceNewConnectionUtilization 新建連接數(shù)使用率 % instanceId Average、Maximum彼念、Minimum
7層協(xié)議監(jiān)控指標(biāo)
Metric 描述 單位 Dimensions Statistics
Qps 端口維度的QPS Count/Second instanceId, port, vip Average
Rt 端口維度的請(qǐng)求平均延時(shí) ms instanceId, port, vip Average
StatusCode2xx 端口維度的slb返回給client的2xx狀態(tài)碼統(tǒng)計(jì) Count/Second instanceId, port, vip Average
StatusCode3xx 端口維度的slb返回給client的3xx狀態(tài)碼統(tǒng)計(jì) Count/Second instanceId, port, vip Average
StatusCode4xx 端口維度的slb返回給client的4xx狀態(tài)碼統(tǒng)計(jì) Count/Second instanceId, port, vip Average
StatusCode5xx 端口維度的slb返回給client的5xx狀態(tài)碼統(tǒng)計(jì) Count/Second instanceId, port, vip Average
StatusCodeOther 端口維度的slb返回給client的other狀態(tài)碼統(tǒng)計(jì) Count/Second instanceId, port, vip Average
UpstreamCode4xx 端口維度的rs返回給slb的4xx狀態(tài)碼統(tǒng)計(jì) Count/Second instanceId, port, vip Average
UpstreamCode5xx 端口維度的rs返回給client的5xx狀態(tài)碼統(tǒng)計(jì) Count/Second instanceId, port, vip Average
UpstreamRt 端口維度的rs發(fā)給proxy的平均請(qǐng)求延遲 ms instanceId, port, vip Average
InstanceQps 實(shí)例維度的QPS Count/Second instanceId Average
InstanceRt 實(shí)例維度的請(qǐng)求平均延時(shí) ms instanceId Average
InstanceStatusCode2xx 實(shí)例維度的slb返回給client的2xx狀態(tài)碼統(tǒng)計(jì) Count/Second instanceId Average
InstanceStatusCode3xx 實(shí)例維度的slb返回給client的3xx狀態(tài)碼統(tǒng)計(jì) Count/Second instanceId Average
InstanceStatusCode4xx 實(shí)例維度的slb返回給client4xx狀態(tài)碼統(tǒng)計(jì) Count/Second instanceId Average
InstanceStatusCode5xx 實(shí)例維度的slb返回給client的5xx狀態(tài)碼統(tǒng)計(jì) Count/Second instanceId Average
InstanceStatusCodeOther 實(shí)例維度的slb返回給client的Other狀態(tài)碼統(tǒng)計(jì) Count/Second instanceId Average
InstanceUpstreamCode4xx 實(shí)例維度的rs返回給slb的4xx狀態(tài)碼統(tǒng)計(jì) Count/Second instanceId Average
InstanceUpstreamCode5xx 實(shí)例維度的rs返回給slb的5xx狀態(tài)碼統(tǒng)計(jì) Count/Second instanceId Average
InstanceUpstreamRt 實(shí)例維度的rs發(fā)給proxy的平均請(qǐng)求延遲 ms instanceId Average
InstanceQpsUtilization QPS使用率 % instanceId Average挪圾、Maximum浅萧、Minimum