CTS Event Source¶
For the use of CTS triggers, please refer to Using a CTS Trigger.
CTS example event¶
{
"cts": {
"time": 1529996047,
"user": {
"name": "userName",
"id": "5b726c4fbfd84821ba866bafaaf56aax",
"domain": {
"name": "domainName",
"id": "b2b3853af40448fcb9e40dxj89505ba"
}
},
"request": {},
"response": {},
"code": 204,
"service_type": "FunctionGraph",
"resource_type": "graph",
"resource_name": "workflow-2be1",
"resource_id": "urn:fgs:region:projectId:graph:workflow-2be1",
"trace_name": "deleteGraph",
"trace_type": "ConsoleAction",
"record_time": 1529996047,
"trace_id": "69be64a7-0233-11e8-82e4-e5d37911193e",
"trace_status": "normal"
}
}
Parameter description¶
Parameter |
Type |
Description |
|---|---|---|
time |
Int |
(Epoch timestamp in milliseconds) |
user |
Map |
Information about the user who initiated this request |
request |
Map |
Event request content |
response |
Map |
Incident response content |
code |
Int |
Event response code, such as 200, 400 |
service_type |
String |
Abbreviation of the sender, such as vpc, ecs, etc. |
resource_type |
String |
The sender resource type, such as vm, vpn, etc. |
resource_name |
String |
Resource name, such as the name of a virtual machine in the ecs service |
trace_name |
String |
Event name, such as: startServer, shutDown, etc. |
trace_type |
String |
The event source type, such as ApiCall |
record_time |
String |
The time when the cts service receives this trace (Epoch timestamp in milliseconds) |
trace_id |
String |
Unique identifier for the event |
trace_status |
String |
Status of the event |
For full description of all parameters see CTS Event Reference.
Example¶
const { CTSEvent } = require("@opentelekomcloud-community/fg-cts-event");
exports.initializer = function (context, callback) {
const logger = context.getLogger();
logger.info("Function initialized");
callback(null, "");
};
exports.handler = async function (event, context) {
const logger = context.getLogger();
logger.info("Function Name:", context.getFunctionName());
const ctsEvent = new CTSEvent(event);
logger.info("CTS Event- Trace type:", ctsEvent.getTraceType());
logger.info("CTS Event- Service type:", ctsEvent.getServiceType());
const output = {
service_type: ctsEvent.getServiceType(),
trace_type: ctsEvent.getTraceType(),
trace_name: ctsEvent.getTraceName(),
};
return output;
};