Ability to export a list of registered inventory systems

Solution Verified - Updated

Environment

  • Red Hat Insights
  • Red Hat Hybrid Cloud Console

Issue

  • How do I export a list of registered inventory systems from Red Hat Insights?

Resolution

There are two ways to export a list of inventory systems:

  • Red Hat Hybrid Cloud Console
  • Red Hat Hybrid Cloud Export Service API

Exporting via the Console

To export a list of systems via the Console, follow these steps:

  1. Navigate to This content is not included.This content is not included.https://console.redhat.com/insights/inventory.
  2. Click the Export data icon (Next to the Delete button). You will be presented with two output format choices: CSV or JSON.
  3. Click the desired format. A pop-up message will appear in the top right reporting that the export has begun processing. Once it's complete, a second pop-up notification will be displayed near the browser's download button.
  4. Click the browser's download button to access the report.

Exporting via the API

Systems can be exported using the Red Hat Insights Export Service API at https://console.redhat.com/api/export/v1.
The API workflow is the following:

  1. Initiate an export with a POST /exports request, for example:

    • POST https://console.redhat.com/api/export/v1/exports

    A sample POST body includes the following:

    { 
      "name": "Inventory Export",
      "format": "json",
      "sources": [ 
         {
           "application": "urn:redhat:application:inventory", 
           "resource": "urn:redhat:application:inventory:export:systems"
         }  
      ] 
    }
    

    The export service's response will include an export id that can be used in subsequent requests.

    Example using the curl command (using token-based authentication with service accounts):

    $ curl -X POST "https://console.redhat.com/api/export/v1/exports" -H 'accept: application/json' -H 'Content-Type: application/json' -H 'Authorization: Bearer <access_token>' -d '{ "name": "Inventory Export", "format": "json", "sources": [ { "application": "urn:redhat:application:inventory", "resource": "urn:redhat:application:inventory:export:systems" } ] }' | jq
    
  2. Retrieve the export's status with a GET status request.

    • GET /exports/{export_id}/status

    The response will include a status field indicating the state of the request. Once the status is set to Complete, the export report can be downloaded.

    Example using the curl command (using token-based authentication with service accounts):

    $ curl -X GET 'https://console.redhat.com/api/export/v1/exports/<export_id>/status' -H 'accept: application/json' -H 'Authorization: Bearer <access_token>' |jq
    
  3. Download the export report with a GET /exports/{export_id} request.

    • GET /exports/{export_id}

    The response will be a zip file containing some metadata, a README, and the actual report in the desired format (json or csv).

    Example using the curl command (using token-based authentication with service accounts):

    $ curl -X GET 'https://console.redhat.com/api/export/v1/exports/<export_id>' -H 'accept: application/zip' -H 'Authorization: Bearer <access_token>' --output export.zip
    

Resources

Please reference the following resources for more information and guidance:

SBR
Product(s)

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.