Use New Relic GraphQL API to query entities

To query your data with the New Relic GraphQL API, New Relic uses the concept of an entity. An entity provides unified access to all the things you monitor with New Relic, including but not limited to:

Entity definition

Each entity has similar traits:

  • A unique entity GUID identifies it.
  • It exists over a span of time, even if it is a short period.
  • It provides a useful entry point for exploring data about specific metrics and events, or for exploring data related to other entities.

Requirements

Owner, Admins, or Add-on managers.

You must have a user-specific API key to run GraphQL queries. To create an API key, use the or GraphQL API explorer or New Relic UI.

Search for entities

New Relic searches for entities by their attributes (primarily their name), but also by type of entity and other values. The search returns basic data about entities matching the search criteria. Then, from the basic query results, you can query a specific entity by its GUID.

To use the New Relic GraphQL API to query one or more entities:

  1. Run a basic query with the New Relic GraphQL API explorer to find entities that match your search criteria. For example:

    query($query: String!) {
      actor {
        entitySearch(query: $query) {
          count
          results {
            entities {
              name
              entityType
              guid
            }
          }
        }
      }
    }
    
  2. Add the following variables to the Query variables section:

    {"query": "nerd-graph"}
    {"query": "name like 'nerd-graph'"}
  3. Review the basic categories from the query results to find a specific entity, or to review relationships between existing entities.

  4. Use a specific entity's GUID to query deeper into its related data. For example:

    query($guids: [EntityGuid!]) {
      actor {
        entities(guids: $guids) {
          entityType
          name
        }
      }
    }
  5. Add the following variables to the Query variables section:

    {"guids": "entity-guid-here"}

For more help

Recommendations for learning more: