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.

To make an authenticated REST API call

  1. Navigate to Admin > Account Manager and view the Product Security section to view security details.
  2. 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.

    api_token.png

  3. 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.
Example: Retrieve events from your account
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 two metrics, freememorysize and totalmemorysize for a source type titled Sample_Device.

POST - Create a batch of metrics
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.

GET - View the list of metrics
curl https://api.truesight.bmc.com/v1/metrics \
-X GET \
-u <email>:<api-token>

For more information, see /v1/get/metrics.

PUT - Update the values for a metric
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.

DELETE - Remove a metric
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_metric.png

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 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.

POST - Create batch measurements for metrics
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.

GET - List of measurements associated to a metric
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.

Events are uniquely identified by the fingerprint fields and grouped by event class.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.

  

Use event query parameters to list events. For more information, see /v1/get/events.

GET - View the list of 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.

API_mapping.png

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*