Uploading metric data to the API#

Upload metrics data by using an external client to access REST API endpoints.

Uploading data to the API#

UrbanCodeā„¢ Velocity provides a lot of plug-ins that you can use to integrate data into your releases and values streams. If a plug-in is not available for your environment, or if you prefer to manage your own data integration, you can use an external client to upload data to the REST API.

The following examples use the Curl command line tool for typical POST use cases. You authorize requests with user access keys that you create in UrbanCode Velocity.

Normalized metrics example#

The following example provides a Curl POST request that sends metrics data to the https://my_velocity:port/api/v1/metrics endpoint:

curl -k --request POST \
--url https://my_velocity:port/api/v1/metrics \
-H "content-type: application/json" \
-H "Authorization: UserAccessKey 373511fa-3b99-4b31-8866-94d81f72095e" \
--data '{
"tenantId": "5ade13625558f2c6688d15ce",
"dataSet": "Homegrown",
"record": {
"metricDefinitionId": "Unit Tests",
"recordName": "UT on ABC",
"pluginType": "plugin",
"executionDate": "2019-05-01T21:09:00.000Z",
"dataFormat": "custom",
"value":
{ "passed": 38, "failed": 1 }

},
"application":
{ "name": "my-app" }

}'

Metrics file upload example#

The following example provides a Curl POST request that uploads a file at the https://my_velocity:port/api/v1/upload endpoint:

curl --request POST \
--url https://my_velocity:port/api/v1/metrics/upload \
-H "Authorization: UserAccessKey 373511fa-3b99-4b31-8866-94d81f72095e" \
-F file=@junit.xml \
-F 'payload={
"tenantId": "5ade13625558f2c6688d15ce",
"dataSet": "Feb",
"application":
{ "name": "my App22" }

,
"environment": "Prod",
"record":
{ "metricDefinitionId": "Functional Tests", "pluginType": "junitXML", "dataFormat": "junitXML" }

}
' \
-k

Deployment data example#

The following example provides a Curl POST request that sends Jenkins deployment data to the https://my_velocity:port/api/v1/deployments endpoint:

curl --request POST \
-H "Authorization: UserAccessKey 373511fa-3b99-4b31-8866-94d81f72095e" \
-H 'content-type: application/json' \
-k --url https://my_velocity:port/api/v1/deployments \
--data '{
"id_external": 8888,
"tenant_id": "5ade13625558f2c6688d15ce",
"version_name": "1.2.3",
"version_id_external": "V1.2.3",
"result": "Succeeded",
"description" : "Application API Release Failed",
"by_user": "username",
"application":
{ "name": "cool-Jenkins-App" }

,
"start_time": "2019-02-02 00:10:58.856+00:00",
"end_time": "2019-02-02 00:12:58.856+00:00",
"type": "Jenkins",
"environment_id": "165b09e6-6ece-dd8b-13db-5fe60d5bb402",
"environment_name": "QA"
}'

Build data example#

The following example provides a Curl POST request that sends build data to the https://my_velocity:port/api/v1/builds endpoint:

curl -k --request POST \
--url https://my_velocity/api/v1/builds \
-H "content-type: application/json" \
-H "Authorization: UserAccessKey 373511fa-3b99-4b31-8866-94d81f72095e" \
--data '{
"id": "131",
"source": "Jenkins",
"tenantId": "5ade13625558f2c6688d15ce",
"name": "HCL Build",
"status": "failure",
"application":
{ "name": "Velocity SE" }

,
"url": "https:/12.34.20.45/job/VSE/master/5",
"number": 5,
"labels": ["Everything"],
"startTime": "2019-03-14 20:10:58.856+00:00",
"endTime": "2019-03-14 20:10:58.856+00:00",
"requestor": "admin"
}'

Parent topic: Managing plug-ins