Configuring REST Observer jobs
Use the REST Observer for obtaining topology data through REST endpoints. This observer is a counterpart to the File Observer.
Before you begin
For the Swagger API documentation, see REST Observer for Agile Service Manager .
About this task
The REST Observer passes topology data using a RESTful set of interfaces, which provide REST APIs that enable the following functionality:
- Management of Listen and bulk-replace job types.
- The insert-update (HTTP POST) of resources.
- The insert-update (HTTP POST) of relationships.
- The insert-replacement (HTTP PUT) of resources.
- The deletion (HTTP DELETE) of resources.
- A REST API that supports the deletion (HTTP DELETE) of all relationships of a particular type from a specified resource.
- A REST API that supports the deletion (HTTP DELETE) of a specific relationship.
Restriction: Resources created through REST can have a provider, but not an observer.
Benefits: Using the REST Observer rather than the File Observer or Topology Service APIs includes the following benefits:
- The ability to provide data through HTTP REST Endpoints instead of files.
- The processing performed by all observers in their framework ensures that metadata about observations from observers is managed correctly.
- A simple way of deleting all edges of a given type on a resource or a specific edge instance.
To use the REST Observer, a job request must be issued (HTTP POST) to the Observer instance job management APIs before sending data to the Resource and Relationship APIs.
Listen
A long-running listen job capable of consuming topology data over a long period. A listen job is designed to support scenarios where the input data stream is unpredictable, or little or no consistency or versioning of resources exists within the data stream.
Synchronize (bulk replace)
A long-running job with the same resource replace semantics as the File Observer. Bulk-replace jobs are designed to support scenarios where a known set of resources are subject to updates or versioning, and a prior observation about resources is to be replaced with a new one. This job provides a new set of resources and relationships and synchronizes them to the topology service, causing any previous data provided by the observer to be deleted and replaced with the new data.
Note: In both cases, a provider job parameter is required to identify the origin of the data being provided to the observer job.
Once a job request has been successfully submitted, you can start to provide data to the Resource and Relationship APIs on behalf of a particular job instance.
The Resource and Relationship APIs may respond with an HTTP 503 Service Unavailable response with a Retry-After: 10 seconds in the header. This indicates that even though the request against those APIs is valid, the observer has not been able to ascertain that metadata about the job is held in IBM Cloud Pak® for AIOps yet; this may be due to, for example, any prevailing conditions in the network that support the micro-services.
Tip: If such a response is received, try the request again later.
Procedure
Define or edit the following parameters, then click Run job to save and run the job.
Encryption requirement: See the Configuring observer jobs security topic for more information.
Important: Ensure that the body is structured correctly. When posting the body, information included in the body after the closing } that matches an opening { is ignored, and no error is recorded.
Parameter | Action | Details |
---|---|---|
Unique ID | Enter a unique name for the job | Required |
Provider | Specify the name of the program or system to provide data | Required |
Access scope | Enter text to provide a scope for the resources. Access scope can help map alerts to resources when resources in different scopes share the same parameters, such as matchTokens. | Optional. Tip: You can define access scope for locations, project names, namespaces, etc. |
Generate debug support file | Set this parameter to 'True' in order to capture the output of the next scheduled job run as a file. This file will be stored with an observer's log files and can be used to debug observer issues, for example at the request of your designated support team, or while using a test environment. For one-off jobs (that is, Load jobs), this parameter reverts to 'False' after the next completed run. To examine the output produced, you can load the generated debug file using the File Observer. | Optional |
Observer job description | Enter additional information to describe the job | Optional |
Job schedule | Specify when the job runs | Optional. Load jobs only. |
REST Observer API access
API name: topology-rest-observer
Public API URLs: /aiops/api/application-manager/topology-rest-observer/v1/*
For information on how to obtain route and token information, see Accessing the console.
For information on how to obtain your token, see Accessing APIs.
Swagger API documentation
For the Swagger API documentation, see Topology REST Observer API. The documentation explains how to use the REST Observer APIs.
Creating cross-data origin relationships
Using the REST Observer functionality, you can create edges between resources from different observations or providers.
It requires both the uniqueID
and the provider of the resources at each end of the link (so typically applies to previously observed resources).
In the following syntax examples, note the _toProvider
and _fromProvider
edge properties.
You can define an edge from a resource in the current observation to one owned by a different provider. This example needs to be POSTed to the REST observer's /rest/resources
endpoint:
{
"uniqueId":"host1.ibm.com",
"entityTypes":["host"],
"name":"host1",
"_references":
[
{
"_edgeType":"connectedTo",
"_toProvider":"someOtherProvider",
"_toUniqueId":"host2.ibm.com"
}
]
}
You can define an edge from a resource between two different providers. This example needs to be POSTed to the REST observer's /rest/references
endpoint:
{
"_fromProvider":"providerOne",
"_fromUniqueId":"host1-interface1",
"_edgeType":"connectedTo",
"_toProvider":"providerTwo",
"_toUniqueId":"host2-interface1"
}
Example listen job
The following examples show how to use the REST Observer listen job to create and adjust a small topology.
Start the Listen job
Use the following example as a model.
curl -u PROXY_USER[:PROXY_PASSWORD] -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' -d '{
"unique_id": "my job",
"type": "listen",
"parameters": {
"provider": "MyListenJob"
}
}' 'https://localhost/1.0/rest-observer/jobs/listen'
Verify that the listen job is running
curl -u PROXY_USER[:PROXY_PASSWORD] -X GET --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' 'https://localhost/1.0/rest-observer/jobs/my%20job'
Create a 'person' resource
This example creates a person resource called 'Thomas Watson'.
curl -u PROXY_USER[:PROXY_PASSWORD] -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' --header 'JobId: my job' -d '{
"name": "Thomas Watson",
"uniqueId": "Thomas Watson",
"entityTypes": [
"person"
]
}' 'https://localhost/1.0/rest-observer/rest/resources'
Create an 'organization' resource
This example creates an 'organization' resource of 'IBM'.
curl -u PROXY_USER[:PROXY_PASSWORD] -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' --header 'JobId: my job' -d '{
"name": "IBM",
"uniqueId": "IBM",
"entityTypes": [
"organization"
]
}' 'https://localhost/1.0/rest-observer/rest/resources'
Create a 'manages' relationship
This example creates a 'manages' releationship between Thomas Watson and IBM.
curl -u PROXY_USER[:PROXY_PASSWORD] -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' --header 'JobId: my job' -d '{
"_fromUniqueId": "Thomas Watson",
"_edgeType": "manages",
"_toUniqueId": "IBM"
}' 'https://localhost/1.0/rest-observer/rest/references'
Create a new 'location' resource
This example creates a 'location' resource of 'Campbell, New York' for Thomas Watson, and a location relationship (an edgeType of locatedAt).
curl -u PROXY_USER[:PROXY_PASSWORD] -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' --header 'JobId: my job' -d '{
"name": "Campbell, New York",
"uniqueId": "Campbell, New York",
"entityTypes": [
"location"
],
"_references": [
{
"_fromUniqueId": "Thomas Watson",
"_edgeType": "locatedAt"
}
]
}' 'https://localhost/1.0/rest-observer/rest/resources'
Replace the location resource with one having latitude and longitude properties
curl -u PROXY_USER[:PROXY_PASSWORD] -X PUT --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' --header 'JobId: my job' -d '{
"name": "Campbell, New York",
"uniqueId": "Campbell, New York",
"entityTypes": [
"location"
],
"longitude": -77.196918,
"latitude": 42.232909
}' 'https://localhost/1.0/rest-observer/rest/resources'
Delete all 'locatedAt' relationships
curl -u PROXY_USER[:PROXY_PASSWORD] -X DELETE --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' --header 'JobId: my job' 'https://localhost/1.0/rest-observer/rest/resources/Thomas%20Watson/references/both/locatedAt'
Delete the location
curl -u PROXY_USER[:PROXY_PASSWORD] -X DELETE --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' --header 'JobId: my job' 'https://localhost/1.0/rest-observer/rest/resources/Campbell%2C%20New%20York'
Delete the manages relationship
curl -u PROXY_USER[:PROXY_PASSWORD] -X DELETE --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' --header 'JobId: my job' 'https://localhost/1.0/rest-observer/rest/resources/Thomas%20Watson/references/both/manages/IBM'
Example bulk-replace job
The following examples show how to use the REST Observer bulk replace job to create and adjust a small topology.
Note: These examples use a mixture of the provided scripts in $ASM_HOME/bin and the cURL command.
Submit a bulk-replace job request with the unique ID of 'my bulk replace'
curl -u PROXY_USER[:PROXY_PASSWORD] -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' -d '{
"unique_id": "my bulk replace",
"type": "bulk replace",
"parameters": {
"provider": "Me"
}
}' 'https://localhost/1.0/rest-observer/jobs/bulk_replace'
Verify that the bulk-replace job is running
curl -u PROXY_USER[:PROXY_PASSWORD] -X GET --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' 'https://localhost/1.0/rest-observer/jobs/my%20bulk%20replace'
Submit a location resource for the city of Coventry
curl -u PROXY_USER[:PROXY_PASSWORD] -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' --header 'JobId: my bulk replace' -d '{
"name": "Coventry",
"uniqueId": "Coventry",
"entityTypes": [
"location"
]
}' 'https://localhost/1.0/rest-observer/rest/resources'
Submit a location resource for the town of Rugby
curl -u PROXY_USER[:PROXY_PASSWORD] -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' --header 'JobId: my bulk replace' -d '{
"name": "Rugby",
"uniqueId": "Rugby",
"entityTypes": [
"location"
]
}' 'https://localhost/1.0/rest-observer/rest/resources'
Submit a location resource for the Town of Leamington Spa with relationships to the existing resources of Coventry and Rugby
curl -u PROXY_USER[:PROXY_PASSWORD] -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' --header 'JobId: my bulk replace' -d '{
"name": "Leamington Spa",
"uniqueId": "Leamington Spa",
"entityTypes": [
"location"
],
"_references": [
{
"_toUniqueId": "Coventry",
"_edgeType": "routesVia"
},
{
"_toUniqueId": "Rugby",
"_edgeType": "routesVia"
}
]
}' 'https://localhost/1.0/rest-observer/rest/resources'
Check your progress by rendering the topology
Having completed this set of observations, initiate a synchronize request for 'my bulk replace' job.
curl -u PROXY_USER[:PROXY_PASSWORD] -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' -d '' 'https://localhost/1.0/rest-observer/jobs/my%20bulk%20replace/synchronize'
Provide a new topology for the 'my bulk replace' job
This example submits a location resource for the town of Leamington Spa with relationships to the towns of Warwick and Stratford-Upon-Avon (resource placeholders).
curl -u PROXY_USER[:PROXY_PASSWORD] -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' --header 'JobId: my bulk replace' -d '{
"name": "Leamington Spa",
"uniqueId": "Leamington Spa",
"entityTypes": [
"location"
],
"_references": [
{
"_toUniqueId": "Warwick",
"_edgeType": "routesVia"
},
{
"_toUniqueId": "Stratford-upon-Avon",
"_edgeType": "routesVia"
}
]
}' 'https://localhost/1.0/rest-observer/rest/resources'
Provide the resource data for the Town of Warwick resource placeholder, thus fully creating the resource
curl -u PROXY_USER[:PROXY_PASSWORD] -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' --header 'JobId: my bulk replace' -d '{
"name": "Warwick",
"uniqueId": "Warwick",
"entityTypes": [
"location"
]
}' 'https://localhost/1.0/rest-observer/rest/resources'
Provide the resource data for the town of Stratford-upon-Avon resource placeholder, thus fully creating the resource
curl -u PROXY_USER[:PROXY_PASSWORD] -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' --header 'JobId: my bulk replace' -d '{
"name": "Stratford-upon-Avon",
"uniqueId": "Stratford-upon-Avon",
"entityTypes": [
"location"
]
}' 'https://localhost/1.0/rest-observer/rest/resources'
Initiate a synchronize request for the 'my bulk replace' job. This signifies to the Observer that it should instruct the system to replace the previous set of observations with the new ones.
Note: The new data is available immediately as it is provided. The synchronize request simply deletes any resources previously observed that were not observed this time. In the current example, Coventry and Rugby were not observed, and therefore they are deleted.
curl -u PROXY_USER[:PROXY_PASSWORD] -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' -d '' 'https://localhost/1.0/rest-observer/jobs/my%20bulk%20replace/synchronize'