Retrieve Health Test Results

To find the results of a health test, you retrieve a list of all configurations, query for an execution of a particular configuration, then query for the individual results of that execution.

This example shows how to retrieve results for the latest execution of a health test configuration. You can also retrieve results for tests executed at a different time.

Prerequisites

  • Log in to vRealize Automation as a system administrator and a tenant administrator. In addition, the tenant administrator must have fabric administrator permissions to use the health broker proxy server.
  • Verify that the appliance name and fully qualified domain name of the vRealize Automation instance are available.
  • Verify that you have a valid HTTP bearer token that matches your login credentials. See REST API Authentication.

Procedure

  1. Use the health broker proxy server to get an authentication token for the health services API.
    curl -X GET --insecure "https://$vRA/healthbroker-proxy-server/api/authn/all HTTP/1.1" -H "accept: text/html" -H "authorization: Bearer $token"
    For details regarding input and output for this request, see Syntax for Requesting a Health Services Token.
    A successful request returns an authentication token that you include in subsequent API requests.
  2. For convenience, store the token in a variable.
    export healthtoken="EXAMPLE-HEALTH-TOKEN-TEXT"
  3. Retrieve a list of health test configurations.
    curl -X GET --insecure "https://$vRA:8090/health/config/configurations HTTP/1.1" -H "x-xenon-auth-token: $healthtoken"
    For details regarding input and output for this request see Syntax to Retrieve a List of Configurations.
  4. Examine the response for configurations listed under documentLinks.
    "documentLinks": [ 
        "/health/config/configurations/80dc3a6f1478553368707000",
        "/health/config/configurations/8277769f1478213933292000",
        "/health/config/configurations/80dc3a6f1478545923685000"
    ],
    Every time the Health Broker runs a test configuration, an execution is created.
  5. Submit a request to find the latest execution for one of the health test configurations.
    curl -X POST --insecure "https://$vRA:8090/core/health-query-tasks HTTP/1.1" -H "content-type: application/json" -H "x-xenon-auth-token: $healthtoken"
    
    The query body specifies the configuration /health/config/configurations/8277769f1478213933292000 as the value to match.
    {
        "taskInfo": {
            "isDirect": true
        },
        "querySpec": {
            "query": {
                "occurance": "MUST_OCCUR",
                "booleanClauses": [{
                    "occurance": "MUST_OCCUR",
                    "term": {
                        "propertyName": "documentKind",
                        "matchValue": "com:vmware:healthbroker:states:ExecutionServiceState",
                        "matchType": "TERM"
                    }
                },
                {
                    "occurance": "MUST_OCCUR",
                    "term": {
                        "propertyName": "configurationLink",
                        "matchValue": "/health/config/configurations/8277769f1478213933292000",
                        "matchType": "TERM"
                    }
                }]
            },
            "sortTerm": {
                "propertyName": "startedTimestamp",
                "propertyType": "LONG"
            },
            "sortOrder": "DESC",
            "resultLimit": 1,
            "options": ["TOP_RESULTS",
            "EXPAND_CONTENT",
            "SORT"]
        }
    }
    For details regarding input and output for this request see Syntax to Filter for Latest Execution of a Configuration.
  6. Examine the execution document contained in the response to find the overallResultLink.
    "overallResultsLink": "/health/result/overall-results/Report_vRA_20161103-22.59.03.0373",
    This is the latest execution of the configuration.
  7. Submit a request to find all the individual results for the latest execution.
    curl -X POST --insecure "https://$vRA:8090/core/health-query-tasks HTTP/1.1" -H "content-type: application/json" -H "x-xenon-auth-token: $healthtoken"
    
    The query body specifies the value for the overallResultsLink as the value to match.
    {
        "taskInfo": {
            "isDirect": true
        },
        "querySpec": {
            "query": {
                "occurance": "MUST_OCCUR",
                "booleanClauses": [{
                    "occurance": "MUST_OCCUR",
                    "term": {
                        "propertyName": "documentKind",
                        "matchValue": "com:vmware:healthbroker:states:IndividualTestResultServiceState",
                        "matchType": "TERM"
                    }
                },
                {
                    "occurance": "MUST_OCCUR",
                    "term": {
                        "propertyName": "overallResultsLink",
                        "matchValue": "/health/result/overall-results/Report_vRA_20161103-22.59.03.0373",
                        "matchType": "TERM"
                    }
                }]
            },
            "sortTerm": {
                "propertyName": "state",
                "propertyType": "STRING"
            },
            "sortOrder": "DESC",
            "options": ["EXPAND_CONTENT",
            "SORT"]
        }
    }
    For details regarding input and output for this request see Syntax to Find All Individual Results.

Results

Detailed test results output in a textual representation facilitate programmatic post-processing. In cases where a check fails, a message describing the failure appears in the output.

{
  "testMethod": { 
    "name": "vRealize Automation Node Common Name Certificate Check", 
    "description": "This test case verifies that the vRA node certificate Common names match that of it's server. This test is most useful for distributed/HA environments.",
    "descriptionType": "text",
    "severity": "CRITICAL",
    "methodName": "areVraNodeCertsCommonNameValid", 
    "accessLevel": "INFRASTRUCTURE",
    "enabled": false,
    "configurationReferences": []
  },
  "startTime": "1478213951731",  
  "endTime": "1478213960684", 
  "state": "FAILED", 
  "message": "Not all checks were successful. See the following errors for more details: \njava.io.IOException: Unable to get the certificate of your server [cava-pn-210-066.eng.vmware.com:443]. Please confirm configuration information. The returned exception is: [java.net.UnknownHostException: cava-pn-210-066.eng.vmware.com] \n", 
  "remediationType": "html",
  "remediation": "http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2106583", 
  "overallResultsLink": "/health/result/overall-results/Report_vRA_20161103-22.59.03.0373", 
}