CI Analytics
Integrate with Trunk CI Analytics using the API
The Trunk CI Analytics API provides access to instrument any CI or build system. The API is an HTTP REST API, returns JSON from all requests, and uses standard HTTP response codes.
All requests must be authenticated by providing the x-api-token
header.
Track Events
POST
https://api.trunk.io/v1/metrics/trackEvents
Track Events
POST
https://api.trunk.io/v1/metrics/trackEvents
The track events endpoint uploads event data about a CI run. Each event contains a start and end timestamp, metrics, tags, and an optional parent association ID.
Headers
Name | Type | Description |
---|---|---|
Content-Type* | String | application/json |
x-api-token* | String | Trunk API Token |
x-source | String | Name of the uploading client |
Request Body
Name | Type | Description |
---|---|---|
repo* | Object | The repository in which the CI Event ran. See repo schema. |
events* | Array | An array of event objects. See event schema. |
Headers
Name | Type | Description |
---|---|---|
Content-Type* | String | AO8NCa6G0paE |
x-api-token* | String | 3HCw9xVi1CBh |
x-source | String | JBoUSZxipIYA |
Request Body
Name | Type | Description |
---|---|---|
repo* | Object | eN1mmETFshzM |
events* | Array | Mk0uImz3AIoq |
Repo
Repo object properties:
Property | Description | Required |
---|---|---|
| The name of the code host for this repository. Currently only | Required |
| The owner of this repository | Required |
| The name of this repository | Required |
For example, the repository https://github.com/trunk-io/jenkins-plugin
would be
Event
Event object properties
Property | Description | Required | Type |
---|---|---|---|
| A unique identifier for this event | Required | String |
| The root event id. | Required | String |
| The parent event. Not required if this event has no parent. | Optional | Object |
| The millisecond epoch marking the start of this event | Required | Number |
| The millisecond epoch marking the end of this event | Optional | Number |
|
| Optional | String |
| An object containing metrics and tags. See payload schema. | Optional | Object |
| Describes the workflow, pipeline, or job, etc. that this event is from. See sequence schema. | Optional | Object |
Parent
Parent object properties:
Property | Description | Required | Type |
---|---|---|---|
| The parent event's unique identifier | Required | String |
| The key to the parent event's sequence | Required | String |
Payload
Payload object properties:
Property | Description | Required | Type |
---|---|---|---|
| Each metric is an object containing the metric key and value (where value is a number). For example: | Required | Object |
| Each metric is an object containing the tag key and value (where value can be a number or a string). For example: | Required | Object |
Sequence
A sequence describes the CI pipeline, job, workflow, etc. Events are grouped under sequences using the sequenceKey
.
Sequence object properties:
Property | Description | Required | Type | Examples |
---|---|---|---|---|
| The string name of the CI platform. Must be | Required | String |
|
| The type of the sequence. | Required | String |
|
| An identifier for this | Required | String |
|
| The name of this | Required | String |
|
| The tags for this sequence. See payload schema. (note: metrics are not supported for a | Required | Object |
|
Example Request
Last updated