Reference: Gateway examples for Reporting

Tanium Gateway provides a GraphQL API integration point for Tanium solutions, including Reporting. Reporting queries and mutations retrieve reports or report results, export and import report definitions, and delete reports and Reporting dashboards.

For more information about Gateway example syntax, see Reference: Filter syntax and Reference: Gateway examples.

Reporting query filter syntax

Reporting queries support the following filter fields:

  • authorNames

  • contentSetNames

  • createdAfter

  • createdBefore

  • labels

  • moduleNames

  • text

For more information on syntax, see reportFieldFilter in the Documentation Explorer pane of the query explorer.

Report author

You can filter reports based on the author name. Define a filter object using the syntax:

JSON
{authorNames: [name-1, name-2, name-...n]}

For example, the following request filters and returns only report definitions whose author is either testadmin-1 or testadmin-2:

JSON
query exampleGetReportsByAuthor($author1: String!, $author2: String!) {
  reports(filter: {authorNames: [$author1, $author2]}) {
    edges {
      node {
        id
      }
    }
  }
}

Include the count and time variables in the Variables panel or in your variables dictionary:

JSON
{
  "author1": "testadmin-1",
  "author2": "testadmin-2"
}

Content set membership

You can filter reports based on the report content set membership. Define a filter object using the syntax:

JSON
{contentSetNames: [content-set-name-1, content-set-name-2, content-set-name-...n]}

If you define multiple solutions, a report only needs to match one of the content sets to pass the filter.

For example, the following request filters and returns only report definitions belonging to the Base or Default content sets:

JSON
query exampleGetReportsByContentSet($contentSet1: String!, $acontentSet2: String!) {
  reports(filter: {contentSetNames: [$contentSet1, $contentSet2]}) {
    edges {
      node {
        id
      }
    }
  }
}

Include the content set variables in the Variables panel or in your variables dictionary:

JSON
{
  "contentSet1": "Base",
  "contentSet2": "Default"
}

Creation time

You can filter reports based on the report creation time, either before or after a specified time. To filter reports created before a specified time, define a filter object using the syntax:

JSON
{createdBefore: rfc-3339-time}

For example, the following request filters and returns only report definitions created before 2022-01-01T00:00:00Z:

JSON
query exampleGetReportsBefore($timeBefore: Time) {
  reports(filter: {createdBefore: $timeBefore}) {
    edges {
      node {
        id
      }
    }
  }
}

Include the timestamp variable in the Variables panel or in your variables dictionary:

JSON
{
  "timeBefore": "2022-01-01T00:00:00Z"
}

To filter reports created after a specified time, define a filter object using the syntax:

JSON
{createdAfter: rfc-3339-time}

For example, the following request filters and returns only report definitions created after 2022-01-01T00:00:00Z:

JSON
query exampleGetReportsAfter($timeAfter: Time) {
  reports(filter: {createdAfter: $timeAfter}) {
    edges {
      node {
        id
      }
    }
  }
}

Include the timestamp variable in the Variables panel or in your variables dictionary:

JSON
{
  "timeAfter": "2022-01-01T00:00:00Z"
}

Report labels

You can filter reports based on the associated labels. Define a filter object using the syntax:

JSON
{labels: [label-1label-1, label-2, label-...n]}

If you define multiple labels, a report only needs to match one of the labels to pass the filter.

For example, the following request filters and returns only report definitions with a label of testlabel-1 or testlabel-2:

JSON
query exampleGetReportsByLabel($label1: String!, $label2: String!) {
  reports(filter: {labels: [$label1, $label2]}) {
    edges {
      node {
        id
      }
    }
  }
}

Include the label variables in the Variables panel or in your variables dictionary:

JSON
{
  "label1": "testlabel-1",
  "label2": "testlabel-2"
}

Associated Tanium solution

You can filter reports based on the associated Tanium solution. Define a filter object using the syntax:

JSON
{moduleNames: [solution-1, solution-2, solution-...n]}

If you define multiple solutions, a report only needs to match one of the solutions to pass the filter.

For example, the following request filters and returns only report definitions associated with Tanium Interact or Tanium Asset:

JSON
query exampleGetReportsBySolution($solution1: String!, $solution2: String!) {
  reports(filter: {moduleNames: [$solution1, $solution2]}) {
    edges {
      node {
        id
      }
    }
  }
}

Include the solution name variables in the Variables panel or in your variables dictionary:

JSON
{
  "solution1": "Tanium Interact",
  "solution2": "Tanium Asset"
}

Name or description text

You can filter reports based on text in the report name or report description. Define a filter object using the syntax:

JSON
{text: text-string}

For example, the following request filters and returns only report definitions that have test-string either in the name or the definition:

JSON
query exampleGetReportsByText($text: String) {
  reports(filter: {text: $text}) {
    edges {
      node {
        id
      }
    }
  }
}

Include the text variable in the Variables panel or in your variables dictionary:

JSON
{
  "text": "test-string"
}

Delete a report by ID

mutation.reportDelete

Delete a report by ID

The reportDelete mutation requires Reporting 1.32 or later and the Report write permission.

The following mutation deletes the report that matches the referenced ID.

JSON
mutation exampleDeleteReport($id: ID!) {
  reportDelete(ref: {id: $id}) {
    id
    error {
      message
      retryable
      timedOut
    }
  }
}

Include the report ID variable in the Variables panel or in your variables dictionary.

JSON
{
  "id": "12345678-90ab-cdef-1234-567890abcdef"
}

Example response:

JSON
{
  "data": {
    "reportDelete": {
      "id": "12345678-90ab-cdef-1234-567890abcdef",
      "error": null
    }
  }
}

Delete a Reporting dashboard by ID

mutation.reportingDashboardDelete

Delete a Reporting dashboard by ID

The reportingDashboardDelete mutation requires Reporting 1.32 or later and the Dashboard write permission.

The following mutation deletes the Reporting dashboard that matches the referenced ID.

JSON
mutation exampleDeleteReportingDashboard($id: ID!) {
  reportingDashboardDelete(ref: {id: $id}) {
    id
    error {
      message
      retryable
      timedOut
    }
  }
}

Include the Reporting dashboard ID variable in the Variables panel or in your variables dictionary.

JSON
{
  "id": "12345678-90ab-cdef-1234-567890abcdef"
}

Example response:

JSON
{
  "data": {
    "reportingDashboardDelete": {
      "id": "12345678-90ab-cdef-1234-567890abcdef",
      "error": null
    }
  }
}

Get a report

query.report

Get a report by ID

The following query retrieves the report that matches the referenced ID.

JSON
query exampleGetReportByID($id: ID!) {
  report(ref: {id: $id}) {
    id
    author {
      user {
        id
      }
      persona {
        id
      }
    }
    contentSet {
      id
    }
    createdTime
    description
    favorite
    labels
    lastModifiedBy {
      user {
        id
      }
      persona {
        id
      }
    }
    modifiedTime
    moduleName
    name
    viewDetails {
      columns {
        name
      }
    }
  }
}

Include the report ID variable in the Variables panel or in your variables dictionary.

JSON
{
  "id": "12345678-90ab-cdef-1234-567890abcdef"
}

Example response:

JSON
{
  "data": {
    "report": {
      "id": "12345678-90ab-cdef-1234-567890abcdef",
      "author": {
        "user": {
          "id": "1"
        },
        "persona": {
          "id": "0"
        }
      },
      "contentSet": {
        "id": "21"
      },
      "createdTime": "2022-01-01T05:33:35.838686969Z",
      "description": "",
      "favorite": false,
      "labels": null,
      "lastModifiedBy": {
        "user": {
          "id": "1"
        },
        "persona": {
          "id": "0"
        }
      },
      "modifiedTime": "2022-06-01T05:33:35.838686969Z",
      "moduleName": null,
      "name": "Example report",
      "viewDetails": {
        "columns": [
          {
            "name": "Example report column"
          }
        ]
      }
    }
  }
}

Get the ID of a report

query.reports

Get an ID of a report

The following query retrieves reports that have the text "Example report" in the name or description, and returns the ID for each report.

JSON
query exampleGetReportIDs($first: Int, $text: String) {
  reports(first: $first, filter: {text: $text}) {
    edges {
      node {
        id
        description
        name
      }
    }
  }
}

Include the pagination and text variables in the Variables panel or in your variables dictionary.

JSON
{
  "first": 2,
  "text": "Example report"
}

Example response:

JSON
{
  "data": {
    "reports": {
      "edges": [
        {
          "node": {
            "id": "12345678-90ab-cdef-1234-567890abcdef",
            "description": "Example description",
            "name": "Example report"
          }
        },
        {
          "node": {
            "id": "abcdef12-3456-7890-abcd-ef1234567890",
            "description": "Example report 2",
            "name": "Report example"
          }
        }
      ]
    }
  }
}

Get multiple reports

query.reports

Get reports

The following query retrieves the first 2 reports.

JSON
query exampleGetReports($first: Int) {
  reports(first: $first) {
    edges {
      node {
        id
        author {
          user {
            id
          }
          persona {
            id
          }
        }
        contentSet {
          id
        }
        createdTime
        description
        favorite
        labels
        lastModifiedBy {
          user {
            id
          }
          persona {
            id
          }
        }
        modifiedTime
        moduleName
        name
      }
    }
  }
}

Include the pagination variable in the Variables panel or in your variables dictionary.

JSON
{
  "first": 2
}

Example response:

JSON
{
  "data": {
    "reports": {
      "edges": [
        {
          "node": {
            "id": "12345678-90ab-cdef-1234-567890abcdef",
            "author": {
              "user": {
                "id": "1"
              },
              "persona": {
                "id": "0"
              }
            },
            "contentSet": {
              "id": "21"
            },
            "createdTime": "2022-01-01T05:33:35.838686969Z",
            "description": "Example description",
            "favorite": false,
            "labels": null,
            "lastModifiedBy": {
              "user": {
                "id": "1"
              },
              "persona": {
                "id": "0"
              }
            },
            "modifiedTime": "2022-03-17T05:33:35.838686969Z",
            "moduleName": null,
            "name": "Example report"
          }
        },
        {
          "node": {
            "id": "abcdef12-3456-7890-abcd-ef1234567890",
            "author": {
              "user": {
                "id": "2"
              },
              "persona": {
                "id": "1"
              }
            },
            "contentSet": {
              "id": "123"
            },
            "createdTime": "2022-01-01T19:58:08.175603337Z",
            "description": "Example report 2",
            "favorite": false,
            "labels": null,
            "lastModifiedBy": {
              "user": {
                "id": "3"
              },
              "persona": {
                "id": "0"
              }
            },
            "modifiedTime": "2022-06-01T19:58:08.175603337Z",
            "moduleName": null,
            "name": "Example report 2"
          }
        }
      ]
    }
  }
}

Get report result data

query.reportResultData

Get report results by report ID

Using reportResultData in a request requires:

  • Reporting 1.12.144 or later to submit the query

  • Reporting 1.35.36 or later to use query.reportResultData (summarize) and query.reportResultData.edges.node.count to retrieve row counts in the response

Important: The cursor refresh functionality (query.reportResultData.collectionInfo.startCursor, query.reportResultData (refresh) is deprecated and no longer functions. If a query request using query.reportResultData fails, resubmit the original query request at least 60 seconds after the initial failed response.

The following query retrieves column values for the first 2 report results, and summarizes the results by returning a count of duplicate rows. The query also retrieves report definition details, including report column name, sourceName, and sourceColumnName.

JSON
query exampleGetReportResultData($id: ID!, $first: Int, $summarize: Boolean!) {
  reportResultData(id: $id, first: $first, summarize: $summarize) {
    edges {
      node {
        columns {
          values
        }
        count
      }
    }
    viewDetails {
      columns {
        name
        sourceName
        sourceColumnName
      }
    }
  }
}

Include the ID, pagination, and summary variables in the Variables panel or in your variables dictionary.

JSON
{
  "id": "12345678-90ab-cdef-1234-567890abcdef",
  "first": 2,
  "summarize": true
}

Example response:

JSON
{
  "data": {
    "reportResultData": {
      "edges": [
        {
          "node": {
            "columns": [
              {
                "values": [
                  "Npcap OEM"
                ]
              },
              {
                "values": [
                  "1.10"
                ]
              },
              {
                "values": [
                  "Windows 10 Enterprise"
                ]
              }
            ],
            "count": 10
          }
        },
        {
          "node": {
            "columns": [
              {
                "values": [
                  "Microsoft Visual C++ 2013 Redistributable (x86) - 12.0.21005"
                ]
              },
              {
                "values": [
                  "12.0.21005.1"
                ]
              },
              {
                "values": [
                  "Windows 10 Enterprise"
                ]
              }
            ],
            "count": 10
          }
        }
      ],
      "viewDetails": {
        "columns": [
          {
            "name": "Name",
            "sourceName": "Installed Applications",
            "sourceColumnName": "Name"
          },
          {
            "name": "Version",
            "sourceName": "Installed Applications",
            "sourceColumnName": "Version"
          },
          {
            "name": "Operating System",
            "sourceName": "Operating System",
            "sourceColumnName": "Operating System"
          }
        ]
      }
    }
  }
}

For reports with multiple results, you can retrieve a page of data and a page end cursor, then submit your request, defining after in the input equal to the page end cursor to retrieve the next page of results. You can repeat this until hasNextPage equals false in the response, signifying that no more pages of data exist.

The following query retrieves column values for the first 2 report results, and summarizes the results by returning a count of duplicate rows. This query also retrieves hasNextPage, to determine whether at least one more page of data exists, and endCursor, to pass this cursor value in a separate request and retrieve the next page of results.

JSON
query exampleGetPaginatedResultData($id: ID!, $first: Int, $summarize: Boolean!) {
  reportResultData(id: $id, first: $first, summarize: $summarize) {
    edges {
      node {
        columns {
          values
        }
        count
      }
    }
    viewDetails {
      columns {
        name
        sourceName
        sourceColumnName
      }
    }
    pageInfo {
      hasPreviousPage
      hasNextPage
      startCursor
      endCursor
    }
  }
}

Include the ID, pagination, and summary variables in the Variables panel or in your variables dictionary.

JSON
{
  "id": "12345678-90ab-cdef-1234-567890abcdef",
  "first": 2,
  "summarize": true
}

Example response:

JSON
{
  "data": {
    "reportResultData": {
      "edges": [
        {
          "node": {
            "columns": [
              {
                "values": [
                  "example-endpoint-1"
                ]
              },
              {
                "values": [
                  "192.0.2.10"
                ]
              }
            ],
            "count": 1
          }
        },
        {
          "node": {
            "columns": [
              {
                "values": [
                  "example-endpoint-2"
                ]
              },
              {
                "values": [
                  "192.0.2.20"
                ]
              }
            ],
            "count": 1
          }
        }
      ],
      "viewDetails": {
        "columns": [
          {
            "name": "Computer Name",
            "sourceName": "Computer Name",
            "sourceColumnName": "Computer Name"
          },
          {
            "name": "IP Address",
            "sourceName": "IP Address",
            "sourceColumnName": "IP Address"
          }
        ]
      },
      "pageInfo": {
        "hasPreviousPage": false,
        "hasNextPage": true,
        "startCursor": "MjMwNDUzOTM6MA==",
        "endCursor": "MjMwNDUzOTM6MQ=="
      }
    }
  }
}

The following query defines after in the input equal to the prior endCursor value of MjMwNDUzOTM6MQ== to retrieve the next page of results.

JSON
query exampleGetPaginatedResultData($id: ID!, $first: Int, $after: Cursor, $summarize: Boolean!) {
  reportResultData(id: $id, first: $first, after: $after, summarize: $summarize) {
    edges {
      node {
        columns {
          values
        }
        count
      }
    }
    viewDetails {
      columns {
        name
        sourceName
        sourceColumnName
      }
    }
    pageInfo {
      hasPreviousPage
      hasNextPage
      startCursor
      endCursor
    }
  }
}

Include the ID, pagination, and summary variables in the Variables panel or in your variables dictionary.

JSON
{
  "id": "12345678-90ab-cdef-1234-567890abcdef",
  "first": 2,
  "after": "MjMwNDUzOTM6MQ==",
  "summarize": true
}

Example response:

JSON
{
  "data": {
    "reportResultData": {
      "edges": [
        {
          "node": {
            "columns": [
              {
                "values": [
                  "example-endpoint-3"
                ]
              },
              {
                "values": [
                  "192.0.2.30"
                ]
              }
            ],
            "count": 1
          }
        },
        {
          "node": {
            "columns": [
              {
                "values": [
                  "example-endpoint-4"
                ]
              },
              {
                "values": [
                  "192.0.2.40"
                ]
              }
            ],
            "count": 1
          }
        }
      ],
      "viewDetails": {
        "columns": [
          {
            "name": "Computer Name",
            "sourceName": "Computer Name",
            "sourceColumnName": "Computer Name"
          },
          {
            "name": "IP Address",
            "sourceName": "IP Address",
            "sourceColumnName": "IP Address"
          }
        ]
      },
      "pageInfo": {
        "hasPreviousPage": true,
        "hasNextPage": true,
        "startCursor": "MjMwNDUzOTM6Mg==",
        "endCursor": "MjMwNDUzOTM6Mw=="
      }
    }
  }
}

Export report definition

query.reportExport

Export a report by ID

The following query exports the report definition that matches the referenced ID. You can import this definition using the importReportmutation.

JSON
query exampleExportReportDefinition($id: ID!) {
  reportExport(ref: {id: $id}) {
    reportDefinition
  }
}

Include the report ID variable in the Variables panel or in your variables dictionary.

JSON
{
  "id": "12345678-90ab-cdef-1234-567890abcdef"
}

Example response:

JSON
{ "data": { "reportExport": { "reportDefinition":
          "{\"id\":\"12345678-90ab-cdef-1234-567890abcdef\",
          \"displayName\":\"Example Report\", \"description\":\"Example API
          Gateway Reporting functionality\",
          \"contentSet\":{\"name\":\"Reporting\"},
          \"sourceView\":{\"id\":\"source data\",
          \"querySpec\":{\"hasChanged\":true, \"sources\":{\"Computer
          Name\":{\"id\":\"Computer Name\",
          \"sensor\":{\"sensorName\":\"Computer Name\", \"flatten\":true}}, \"IP
          Address\":{\"id\":\"IP Address\", \"sensor\":{\"sensorName\":\"IP
          Address\", \"flatten\":false}}}, \"selects\":[{\"id\":\"1\",
          \"sourceColumn\":{\"sourceId\":\"Computer Name\",
          \"columnName\":\"Computer Name\"}, \"displayName\":\"Computer Name\",
          \"display\":{}}, {\"id\":\"2\", \"sourceColumn\":{\"sourceId\":\"IP
          Address\", \"columnName\":\"IP Address\"}, \"displayName\":\"IP
          Address\", \"display\":{}}]},
          \"summary\":{\"countId\":\"summary_count_id\",
          \"displayName\":\"Count\"}},
          \"display\":{\"advanced_filters_enabled\":true,
          \"available_additional_filters\":[],
          \"available_quick_filters\":[\"quick:base:computerGroup\",
          \"quick:base:endpointLastSeen\", \"quick:base:os\"], \"version\":1},
          \"categories\":[{\"name\":\"Test\"}], \"meta\":{\"class\":\"USER\",
          \"type\":\"V2\"}}" } } }

Import report definition

mutation.reportImport

Import a report definition

The following query imports a report definition that you exported using the reportExportquery.

JSON
mutation exampleImportReportDefinition($allowDuplicate: Boolean!, $reportDefinition: String!) {
  reportImport(
    input: {allowDuplicate: $allowDuplicate, reportDefinition: $reportDefinition}
  ) {
    report {
      id
    }
    error {
      message
      retryable
      timedOut
    }
  }
}

Include the report ID variable in the Variables panel or in your variables dictionary.

PYTHON
{ "allowDuplicate": false, "reportDefinition":
          "{\"id\":\"12345678-90ab-cdef-1234-567890abcdef\",
          \"displayName\":\"Example report import\", \"description\":\"Example
          import functionality\", \"contentSet\":{\"name\":\"Reporting\"},
          \"sourceView\":{\"id\":\"source data\",
          \"querySpec\":{\"hasChanged\":true, \"sources\":{\"Computer
          Name\":{\"id\":\"Computer Name\",
          \"sensor\":{\"sensorName\":\"Computer Name\", \"flatten\":true}}, \"IP
          Address\":{\"id\":\"IP Address\", \"sensor\":{\"sensorName\":\"IP
          Address\", \"flatten\":false}}}, \"selects\":[{\"id\":\"1\",
          \"sourceColumn\":{\"sourceId\":\"Computer Name\",
          \"columnName\":\"Computer Name\"}, \"displayName\":\"Computer Name\",
          \"display\":{}}, {\"id\":\"2\", \"sourceColumn\":{\"sourceId\":\"IP
          Address\", \"columnName\":\"IP Address\"}, \"displayName\":\"IP
          Address\", \"display\":{}}]},
          \"summary\":{\"countId\":\"summary_count_id\",
          \"displayName\":\"Count\"}},
          \"display\":{\"advanced_filters_enabled\":true,
          \"available_additional_filters\":[],
          \"available_quick_filters\":[\"quick:base:computerGroup\",
          \"quick:base:endpointLastSeen\", \"quick:base:os\"], \"version\":1},
          \"categories\":[{\"name\":\"Test\"}], \"meta\":{\"class\":\"USER\",
          \"type\":\"V2\"}}" }

Example response:

JSON
{
  "data": {
    "reportImport": {
      "report": {
        "id": "abcdef12-3456-7890-abcd-ef1234567890"
      },
      "error": null
    }
  }
}

Get refreshed report result data

query.reportResultData.collectionInfo.startCursor, query.reportResultData (refresh)

Stability: 0 - Deprecated

Retrieve report results collection start cursor

Important: The cursor refresh functionality (query.reportResultData.collectionInfo.startCursor, query.reportResultData (refresh) is deprecated and no longer functions. If a query request using query.reportResultData fails, resubmit the original query request at least 60 seconds after the initial failed response.

The following query retrieves report details. The query requests collectionInfo.startCursor, which is populated in the response only if the data is not ready within 30 seconds. Use the collectionInfo.startCursor value for refreshing the request.

JSON
query exampleGetReportResultCursor($id: ID!, $first: Int) {
  reportResultData(id: $id, first: $first) {
    edges {
      node {
        columns {
          values
        }
      }
    }
    collectionInfo {
      active
      startCursor
    }
  }
}

Include the pagination and report ID variables in the Variables panel or in your variables dictionary.

JSON
{
  "id": "12345678-90ab-cdef-1234-567890abcdef",
  "first": 2
}

Example response for an ongoing collection with a startCursor value, meaning that the data is not yet ready to be returned:

JSON
{
  "data": {
    "reportResultData": {
      "edges": [],
      "collectionInfo": {
        "active": true,
        "startCursor": "4t2cB0ZGNPqy4J4P7O7opwz/24/5zgPi6OinDAA=:0"
      }
    }
  }
}

Refresh report results collection using starting cursor

The following query refreshes the collection using the returned startCursor value:

JSON
query exampleRefreshReportResultCursor($id: ID!, $first: Int, $refresh: Cursor) {
  reportResultData(id: $id, first: $first, refresh: $refresh) {
    edges {
      node {
        columns {
          values
        }
      }
    }
    collectionInfo {
      active
      startCursor
    }
  }
}

Include the pagination and report ID variables in the Variables panel or in your variables dictionary:

JSON
{
  "id": "12345678-90ab-cdef-1234-567890abcdef",
  "first": 2,
  "refresh": "4t2cB0ZGNPqy4J4P7O7opwz/24/5zgPi6OinDAA=:0"
}

Example response with a completed collection:

JSON
{
  "data": {
    "reportResultData": {
      "edges": [
        {
          "node": {
            "columns": [
              {
                "values": [
                  "Example computer 1"
                ]
              },
              {
                "values": [
                  "2001:DB8::1234",
                  "192.0.2.10"
                ]
              }
            ]
          }
        },
        {
          "node": {
            "columns": [
              {
                "values": [
                  "Example computer 2"
                ]
              },
              {
                "values": [
                  "2001:DB8::1234",
                  "192.0.2.20"
                ]
              }
            ]
          }
        }
      ],
      "collectionInfo": {
        "active": false,
        "startCursor": null
      }
    }
  }
}