Cloud Trace Service (CTS)¶
Cloud Trace is an effective monitoring tool that allows users to analyze their cloud resources using traces. A tracker is automatically generated when the service is started. This tracker monitors access to all the respective user’s cloud resources by means of the traces generated. The monitoring logs can be saved in the object storage cost-effectively and in the long term. The Cloud Trace service can also be used in conjunction with Simple Message Notification, with the user receiving a message when certain events occur. Cloud Trace is free of charge.
CTS Tracker¶
A tracker will be automatically created after CTS is enabled. All traces recorded by CTS are associated with the tracker. Only one management tracker is currently created for each account in a region. On the management console, you can query the last seven days of operation records. To obtain more operation records, you can enable Object Storage Service (OBS) and deliver operation records to OBS buckets for long-term storage in real time.
Create Tracker¶
This interface is used to create a CTS Tracker instance with parameters.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
attrs = {
"bucket_name": "cloudtraceservice",
"file_prefix_name": "file-",
"lts": {
"is_lts_enabled": True,
"log_group_name": "CTS",
"log_topic_name": "system-trace",
"log_group_id": "1186622b-78ec-11ea-997c-286ed488c87f",
"log_topic_id": "751f0409-78ec-11ea-90c7-286ed488c880"
},
"status": "enabled",
"tracker_name": "system",
"detail": ""
}
tracker = conn.cts.create_tracker(**attrs)
Get Tracker¶
This interface is used to get a CTS Tracker by name or ID or an instance of
class Tracker
.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
tracker_name_or_id = "system"
tracker = conn.cts.get_tracker(tracker_name_or_id)
print(tracker)
Delete Tracker¶
This interface is used to delete a CTS Tracker instance by id
or an instance of class
Tracker
.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
conn.cts.delete_tracker()
Update Tracker¶
This interface is used to update a CTS Tracker instance by
using name or an instance of class
Tracker
and provide new
attributes.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
tracker = "system"
attrs = {
"bucket_name": "cloudtraceservice",
"file_prefix_name": "newPrefix-",
"lts": {
"is_lts_enabled": True,
"log_group_name": "CTS",
"log_topic_name": "system-trace",
"log_group_id": "1186622b-78ec-11ea-997c-286ed488c87f",
"log_topic_id": "751f0409-78ec-11ea-90c7-286ed488c880"
},
"status": "enabled",
"tracker_name": "system",
"detail": ""
}
tracker = conn.cts.get_tracker(tracker)
conn.cts.update_tracker(tracker, **attrs)
CTS Traces¶
Traces are the messuremant values of a CTS Tracker.
List Traces¶
This interface is used to query all CTS Traces of a CTS tracker and to filter the output with query parameters.
import openstack
openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')
tracker_name = 'system'
query = {
"trace_rating": "warning"
}
for trace in conn.cts.traces(tracker_name, **query):
print(trace)