Cloud Eye Service (CES)¶
Cloud Eye (CES) is a high-performance monitoring service with integrated alarm functions. Open Telekom Cloud users benefit from a dashboard with a basic overview of resources and their current status. Users can configure the alarm function in such a way that they receive notifications via SMS or email. Monitoring with the Cloud Eye Service is activated by default; the free service does not need to be booked or activated.
CES Alarm Rule¶
The alarm function is based on collected metrics. You can set alarm rules for key metrics of cloud services. When the metric data triggers the conditions set in the alarm rule, Cloud Eye sends emails, or text messages, to you, or sends HTTP/HTTPS requests to the servers. In this way, you are immediately informed of cloud service exceptions and can quickly handle the faults to avoid service losses.
Cloud Eye uses the SMN service to notify users. This requires you to create a topic and add subscriptions to this topic on the SMN console first. Then when you create alarm rules, you can enable the Alarm Notification function and select the created topic. When an error occurs, Cloud Eye can broadcast alarm information to those subscriptions in real time.
Create Alarm Rule¶
This interface is used to create a CES alarm with parameters.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"alarm_name": "alarm-test",
"alarm_description": "Test Alarm description",
"metric": {
"namespace": "SYS.ECS",
"dimensions": [
{
"name": "instance_id",
"value": "33328f02-3814-422e-b688-bfdba93d4051"
},
{
"name": "instance_id",
"value": "04ab9572-8c9c-41b6-bcc8-51068463b123"
}
],
"metric_name": "network_outgoing"
},
"condition": {
"period": 300,
"filter": "average",
"comparison_operator": ">=",
"value": 6,
"unit": "B/s",
"count": 1
},
"alarm_enabled": True,
"alarm_action_enabled": True,
"alarm_level": 2,
"ok_actions": [
{
"type": "notification",
"notificationList": [
"urn:smn:region:68438a86d98e427e907e0097b7e35d48:sd",
"urn:smn:eu-de:16d53a84a13b49529d2e2c3646691222:Error"]
}
],
"alarm_actions": [
{
"type": "notification",
"notificationList": [
"urn:smn:region:68438a86d98e427e907e0097b7e35d48:sd",
"urn:smn:eu-de:16d53a84a13b49529d2e2c3646691222:Error"]
}
]
}
alarm = conn.ces.create_alarm(**attrs)
print(alarm)
# OSC command
'''
openstack --os-cloud otc ces alarm create --description "Test Alarm" \
--namespace SYS.ECS \
--dimension name=instance_id,value=33328f02-3814-422e-b688-bfdba93d4123 \
--dimension name=instance_id,value=33328f02-3814-422e-b688-bfdba93d4052 \
--metric-name "network_outgoing" --period '300' --filter average \
--comparison-operator '>=' --value '6' --unit 'B/s' --count '1' \
--enabled True --action-enabled True --level 2 --ok-action-type notification \
--ok-action-notification-list \
'urn:smn:region:68438a86d98e427e907e0097b7e35d48:sd' \
--ok-action-notification-list \
'urn:smn:eu-de:16d53a84a13b49529d2e2c3646691222:Error' \
--alarm-action-type notification --alarm-action-notification-list \
'urn:smn:region:68438a86d98e427e907e0097b7e35d48:sd' \
--alarm-action-notification-list \
'urn:smn:eu-de:16d53a84a13b49529d2e2c3646691222:Error' alarm-test
'''
Get Alarm Rule¶
This interface is used to get a CES alarm rule by name or ID or an instance of
class Alarm
.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
alarm = 'alarm_id'
alarm = conn.ces.get_alarm(alarm)
print(alarm)
Delete Alarm Rule¶
This interface is used to delete a CES Alarm Rule instance by id
or an instance of class
Tracker
.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
alarm = 'al1596533022051EZVV2nlZ8'
alarm = conn.ces.find_alarm(alarm)
alarm = conn.ces.delete_alarm(alarm)
print(alarm)
Switch Alarm Rule State¶
This interface is used to switch the Alarm Rule State by using name or id.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
alarm = 'alarm_name_or_id'
alarm = conn.ces.find_alarm(alarm)
alarm = conn.ces.switch_alarm_state(alarm)
print(alarm)
Monitoring Data Management¶
Monitoring / Metric data is used to generate and query custom monitoring data.
List Metric Data¶
This interface is used to query all CES metric data and to filter the output with query parameters.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
query = {
'namespace': 'SYS.ECS',
'metric_name': 'cpu_util',
'from': '1556625600000', # unix timestamp in ms
'to': '1556632800000', # unix timestamp in ms
'period': 1,
'filter': 'average',
'dim.0': 'instance_id,6e83e6e7-3bf4-4b5b-b390-e80447ef5733', # key, value
}
for data in conn.ces.metric_data(**query):
print(data)
Miscellaneous¶
List Metrics¶
This API is used to query the metric list. You can specify the namespace, metric, dimension, sorting order, start records, and the maximum number of records when using this API to query metrics.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
for metric in conn.ces.metrics():
print(metric)
List Quotas¶
This API is used to query a resource quota and the used amount. The current resource refers to alarm rules only.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
for quota in conn.ces.quotas():
print(quota)
List Host Configuration / Event Data¶
This API is used to query the host configuration for a specified event type in a specified period of time. You can specify the dimension of data to be queried.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
query = {
'namespace': 'SYS.ECS',
'type': 'instance_host_info',
'dim.0': 'instance_id,6e83e6e7-3bf4-4b5b-b390-e80447ef1234', # key, value
'from': '1596067200', # unix timestamp in ms
'to': '1597929178' # unix timestamp in ms
}
for data in conn.ces.event_data(**query):
print(data)