Collecting data using REST APIs
Use REST APIs to send data to TrueSight Intelligence. The API endpoint URL is: https://api.truesight.bmc.com/
For more information, see TrueSight Intelligence SDK for Java on GitHub . To use an SDK that supports the Post methods for metrics, measurements, and events, see Using the TrueSight Intelligence SDK for Java.
Make an authenticated REST API call. |
| Add metric(s) to your account. |
| Add measure(s) for the metric(s) you added to your account. |
| Send events along with values to your account. |
To make an authenticated REST API call
- Navigate to Admin > Account Manager and view the Product Security section to view security details.
Copy the API token to a temporary location. For more information, see the Product Security section of the TrueSight Account Manager.
Note
Your email address and API token are used to ensure authorized REST APIs send data to your account. Share the API key with authorized individuals only.
- Provide this key as part of the header.
Replace<API token>
in the example below with your account TrueSight Intelligence API key and replace<email>
with your account email address.
curl https://api.truesight.bmc.com/v1/events \
-u <email>:<API token> \
API methods used to manage metrics
Note
The following examples use cURL on a Linux computer for transferring data to TrueSight Intelligence.
This example creates a metric named freememorysize, for a source type titled Sample_Device.
Required fields
To send metric data, you must provide values for the name, displayName, displayNameShort, unit, and defaultAggregate fields.
curl https://api.truesight.bmc.com/v1/metrics \
-X POST \
-u <email>:<api-token> \
-H "Content-Type: application/json" \
-d '{
"name": "freememorysize",
"description": "Size of the Free Memory",
"displayName": "Free Memory Size",
"displayNameShort": "Free Mem",
"unit": "bytecount",
"defaultAggregate": "avg",
"type":"Sample_Device"
}'
This example creates two metrics, freememorysize and totalmemorysize for a source type titled Sample_Device.
curl https://api.truesight.bmc.com/v1/batch/metrics \
-X POST \
-u <email>:<api-token> \
-H "Content-Type: application/json" \
-d '[
{
"name": "freememorysize",
"description": "Size of the Free Memory",
"displayName": "Free Memory Size",
"displayNameShort": "Free Mem",
"unit": "bytecount",
"defaultAggregate": "avg",
"type":"Sample_Device"
},
{
"name": "totalmemorysize",
"description": "Total Memory Size",
"displayName": "Total Memory Size",
"displayNameShort": "Total Mem",
"unit": "bytecount",
"defaultAggregate": "avg",
"type":"Sample_Device"
}
]'
For more information, see /v1/post/batch/metrics.
curl https://api.truesight.bmc.com/v1/metrics \
-X GET \
-u <email>:<api-token>
For more information, see /v1/get/metrics.
curl https://api.truesight.bmc.com/v1/metrics/:Metric_Name \
-X PUT \
-u <email>:<api-token> \
-H "Content-Type: application/json" \
-d
' {
"description": "A new description",
"displayName": "My metric",
"displayNameShort": "My met",
"unit": "number",
"defaultAggregate": "avg"
}'
For more information, see https://api.truesight.bmc.com/documentation#/metrics .
curl https://api.truesight.bmc.com/v1/metrics/Metric_Name \
-X DELETE \
-u <email>:<api-token> \
-H "Content-Type: application/json"
For more information, see /v1/delete/metrics/:metric.
For more information, see
/v1/post/metrics.
API methods used to manage measurements
Note
The following examples use cURL on a Linux computer for transferring data to TrueSight Intelligence.
Note
Create a metric before you add measure data for the metric.
This example sends one data point using Unix time in milliseconds as 1459286820000 (3/29/2016, 2:27:00 PM PST). This API call should be repeated for the time range with required time interval and data values.
Required fields
To send measurement data, you must provide values for the source, metric, and measure fields.
curl https://api.truesight.bmc.com/v1/measurements \
-X POST \
-u <email>:<api-token> \
-H "Content-Type: application/json" \
-d '
{
"source": "sample.corp.com",
"metric": "freememorysize",
"measure": 3.0,
"timestamp": 1459286820,
"metadata": {
"app_id":"Sample App"}
}'
For more information, see /v1/post/measurements.
Note
Create a metric before you add measure data for the metric.
This example sends two data points using Unix time in milliseconds as 1459286820000 (3/29/2016, 2:27:00 PM PST). This API call should be repeated for the time range with required time interval and data values.
curl https://api.truesight.bmc.com/v1/measurements \
-X POST \
-u <email>:<api-token> \
-H "Content-Type: application/json" \
-d '
[
[
"sample.corp.com",
"freememorysize",
3.0,
1459286820,
{"origin":"sample.corp.com"}
],
[
"sample.corp.com",
"totalmemorysize",
3.0,
1459286820,
{"origin":"sample.corp.com"}
]
]'
For more information, see /v1/post/measurementsBatch.
curl https://api.truesight.bmc.com/v1/measurements/CPU?start=1416863824973&end=1416863825973 \
-X GET \
-u <email>:<api-token>
For more information, see /v1/get/measurements/:metric.
API methods used to manage events
Note
The following examples use cURL on a Linux computer for transferring data to TrueSight Intelligence.
Fingerprint fields are defined to have unique values that do not change with time. For example, an event ID is used to identify an event, and the status of the event can be either 'open' or 'close'. The event ID field is never updated in this case. If the value for any fingerprint field is changed, a new event is created.
Ensure that the value of the fingerprint fields are not changed when sending multiple values for other event parameters.
This example creates an event using Unix time in milliseconds as 1459299931000 (3/29/2016, 6:05:31 PM PST).
Required fields
To send event data, you must provide values for the title, source.ref, source.type and fingerprint fields.
curl https://api.truesight.bmc.com/v1/events \
-X POST \
-u <email>:<api-token> \
-H "Content-Type: application/json" \
-d \
' {
"source":
{
"ref": "sample.corp.com",
"type": "sample.corp.com",
"name": "sample.corp.com"
},
"sender":
{
"ref": "sample.corp.com",
"type": "sample.corp.com",
"name": "sample.corp.com"
},
"fingerprintFields": ["@title","uid"],
"title": "Sample event",
"eventClass": "EVENT",
"status": "CLOSED",
"severity": "INFO",
"createdAt": 1459299931000,
"properties":
{
"uid": "fcc603a4-bde1-4927-878e-3fea0a41d24f",
"app_id": "Sample App",
"hostIp": "127.0.0.1",
"hostName": "sample.corp.com",
"thresholdValue": "0",
"entityId": "sample.corp.com",
"entityTypeId": "SAMPLE_DEVICE",
"entityAttrId": " idlecpupercentusage",
"entityAttrUnit": "%",
"entityAttrValue": "65.07"
}
} '
Use event query parameters to list events. For more information, see /v1/get/events.
curl https://api.truesight.bmc.com/v1/events \
-X GET \
-u <email>:<api-token>
For more information, see /v1/get/events/:event_id.
Use event query parameters to list raw events. For more information, see /v1/get/events/raw.
Info
- Use the eventClass field to assign a type to the event. This is used by TrueSight Intelligence to categorize events, and you can filter the event list using this field. For example, if you are sending events from various social media sources and want to bucket them, use Social as the value for eventClass.
- Use the app_id field to associate the event to a TrueSight Intelligence App. Navigate to Apps, select your application, and click Events to view the associated events.
For more information, see /v1/post/events.
Comments
Log in or register to comment.