Events and Reporting APIs

Overview of GraphQL object types available to query the Rubrik Events and Reporting components.

ActivitySeriesConnection

ActivitySeriesConnection is an object type that represents the information associated with an activity or event series on Rubrik clusters.

The Cluster object uses the activitySeriesConnection query to identify the different activities associated with Rubrik clusters.

Use case: Retrieving event details

Use the Rubrik GraphQL API to query the number of backup failures on a specified Rubrik cluster.

GraphQL query

QUERY='{
  "query": "query ActivitySeriesConnection($clusterId: [UUID!]) {
  "query": "  activitySeriesConnection(
  "query": "    filters: {
  "query": "      cluster: {id: $clusterId}
  "query": "      lastActivityType: [Backup]
  "query": "      lastActivityStatus: [Failure]
  "query": "    }
  "query": "  ) {
  "query": "    count
  "query": "  }
  "query": "}
"
}'

curl -X POST https://$account.my.rubrik.com/api/graphql \
--header "authorization: Bearer $access_token" \
--header "content-type: application/json" \
--data "$(echo $QUERY)"

Here the query uses the activitySeriesConnection query construct defined in the Cluster object type to request the details of activities related to the Rubrik cluster identified by $cluster_id.

type Cluster {
   activitySeriesConnection(
       first: Int,
       after: String,
       last: Int,
       before: String,
       sortBy: ActivitySeriesSortByEnum,
       filters: ActivitySeriesFilterInput
   ): ActivitySeriesConnection!
}

The filters argument of activitySeriesConnection specifies the requested constraints in the query. The filters argument is of type ActivitySeriesFilterInput, and has fields that can be used to filter the activities.

For example, the query uses the lastActivityType, lastActivityStatus, and the cluster fields to filter the backup failures that occurred on the Rubrik cluster and returns the number of failures as a value of count.

Response type

The ActivitySeriesConnection object models the response of the GraphQL query.

type ActivitySeriesConnection {
    edges: [ActivitySeriesEdge!]!
    nodes: [ActivitySeries!]!
    pageInfo: PageInfo!
    count: Int!
}

The definition of ActivitySeriesConnection allows the GraphQL query to request the count of events that fit the specified criteria.

Sample response

The response specifies the number of backup failures as a value of the field count.

{
  "data": {
    "activitySeriesConnection": {
      "count": 2,
      "__typename": "ActivitySeriesConnection"
    }
  },
  "loading": false,
  "networkStatus": 7
}

SnappableConnection

SnappableConnection is an object type that represents the different workload types managed by Rubrik clusters.

The Cluster object uses the snappableConnection query to retrieve the workload details necessary for generating reports.

Use case: Retrieving object details

Use the Rubrik GraphQL API to query the total number of protected vSphere virtual machines on a Rubrik cluster with a specified ID. The query also retrieves the total number of snapshots taken and the total number of snapshots missed for the protected vSphere virtual machines on the specified Rubrik cluster.

GraphQL query

QUERY='{
  "query": "query SnappableConnection($clusterId: [UUID!]) {
  "query": "  snappableConnection(
  "query": "    filter: {
  "query": "      cluster: {id: $clusterId}
  "query": "      objectType: VmwareVirtualMachine
  "query": "      protectionStatus: Protected
  "query": "    }
  "query": "  ) {
  "query": "    count
  "query": "    aggregation {
  "query": "      totalSnapshots
  "query": "      missedSnapshots
  "query": "    }
  "query": "  }
  "query": "}
"
}'

curl -X POST https://$account.my.rubrik.com/api/graphql \
--header "authorization: Bearer $access_token" \
--header "content-type: application/json" \
--data "$(echo $QUERY)"

Here the query uses the snappableConnection query construct defined in the Cluster object type to create a GraphQL query that requests the details of the protected virtual machines.

type Cluster {
    snappableConnection(
        first: Int,
        after: String,
        last: Int,
        before: String,
        filter: SnappableFilterInput
    ): SnappableConnection!
}

The filter argument of snappableConnection specifies the requested constraints in the query. The filter argument is of type SnappableFilterInput and has fields that can be used to filter the protected objects.

For example, the query uses the cluster, objectType, and protectionStatus fields to retrieve the number of protected objects of type VmwareVirtualMachine that exist on the Rubrik cluster identified by the $cluster_id and returns the number as a value of count.

Response type

The SnappableConnection object models the data in the response of the GraphQL query.

For example, the query requests the count of events that fit the specified criteria. The totalSnapshots and missedSnapshots are fields of SnappableAggregation type.

type SnappableConnection {
    edges: [SnappableEdge!]!
    nodes: [Snappable!]!
    pageInfo: PageInfo!
    count: Int!
    aggregation: SnappableAggregation!
}

Sample response

The response includes the requested information as shown below.

{
  "data": {
    "snappableConnection": {
      "count": 461,
      "aggregation": {
        "totalSnapshots": 6979,
        "missedSnapshots": 8123,
        "__typename": "SnappableAggregation"
      },
      "__typename": "SnappableConnection"
    }
  },
  "loading": false,
  "networkStatus": 7
}