CI Analytics
Integrate with Trunk CI Analytics using the API
Last updated
Integrate with Trunk CI Analytics using the API
Last updated
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.
POST
https://api.trunk.io/v1/metrics/trackEvents
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.
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Repo object properties:
For example, the repository https://github.com/trunk-io/jenkins-plugin
would be
Event object properties
Parent object properties:
Payload object properties:
A sequence describes the CI pipeline, job, workflow, etc. Events are grouped under sequences using the sequenceKey
.
Sequence object properties:
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Property | Description | Required |
---|---|---|
Property | Description | Required | Type |
---|---|---|---|
Property | Description | Required | Type |
---|---|---|---|
Property | Description | Required | Type |
---|---|---|---|
Property | Description | Required | Type | Examples |
---|---|---|---|---|
Content-Type*
String
application/json
x-api-token*
String
Trunk API Token
x-source
String
Name of the uploading client
repo*
Object
The repository in which the CI Event ran. See repo schema.
events*
Array
An array of event objects. See event schema.
Content-Type*
String
AO8NCa6G0paE
x-api-token*
String
3HCw9xVi1CBh
x-source
String
JBoUSZxipIYA
repo*
Object
eN1mmETFshzM
events*
Array
Mk0uImz3AIoq
host
The name of the code host for this repository. Currently only github.com
is supported.
owner
The owner of this repository
name
The name of this repository
id
A unique identifier for this event
chainId
The root event id. chainId
is used to group all events that were part of the same run.
parent
The parent event. Not required if this event has no parent.
createdAt
The millisecond epoch marking the start of this event
finishedAt
The millisecond epoch marking the end of this event
conclusion
"SUCCESS" | "FAILURE" | "CANCELLED" | "TIMED_OUT" | "SKIPPED"
payload
An object containing metrics and tags. See payload schema.
sequence
Describes the workflow, pipeline, or job, etc. that this event is from. See sequence schema.
eventId
The parent event's unique identifier
sequenceKey
The key to the parent event's sequence
metrics
Each metric is an object containing the metric key and value (where value is a number). For example: {"k": "duration_ms", "v": 101920}
tags
Each metric is an object containing the tag key and value (where value can be a number or a string). For example: {"k": "runner", "v": "self-hosted"}
platform
The string name of the CI platform. Must be snake_case
.
jenkins
, trunk_merge
.
kind
The type of the sequence.
job
, workflow
key
An identifier for this sequence
. Must be unique within the repo
and < 128 characters.
my-global-uuid
name
The name of this sequence
. These will appear as top-level entries in your CI Analytics dashboards.
Integration Tests [linux]
.
payload
The tags for this sequence. See payload schema. (note: metrics are not supported for a sequence
)
{
metrics: [],
tags: []
}