7. GraphOS metrics & client awareness
3m

Overview

provides us with observability tools to monitor the health and performance of our . These tools help surface patterns in how our supergraph gets used, which helps us continue to improve it.

In this lesson, we will:

  • Explore the and metrics provided by
  • Set up client awareness to indicate which s were sent by which client

Sending (fake) traffic to the supergraph

We're still in tutorial-land, so there isn't any real production traffic going to our . Unless you actually went ahead and shared your API with others, in which case, good for you!

Let's go ahead and get some numbers in here so we can walk through what it might look like if we did have more traffic.

The Code Sandbox below contains a script that takes a URL and sends requests to it over a period of time. We'll use it to send fake traffic to our supergraph.

Go ahead and enter your URL (you can find that at the top of your 's README page). Then press the button to trigger the script!

Note: Right now, our Poetic Plates API does not have any protection against malicious queries or denial-of-service (DoS) attacks. In a future course, we'll cover more techniques to secure your . In the meantime, you can check out the Apollo technote about the topic to learn more about rate limiting, setting timeouts, pagination and more.

Now we're ready to dive into our metrics!

Operation metrics

Let's head back to Studio, where our metrics live. First, let's check out Operations.

https://studio.apollographql.com

Operations page in Studio

This gives us an overview of request rates, service time, and error percentages, including specific operations for each of these that might be worth drilling deeper into.

We recommend that clients clearly name each GraphQL they send to the , so we can easily view them in our metrics.

We can also filter to select a particular to see more specific details about its usage, as well as its signature, which is the shape of the query. We can see the number of requests that have been made and how long each request takes over time.

https://studio.apollographql.com

Operations page filter for a specific operation in Studio

https://studio.apollographql.com

Operations page details for a specific operation in Studio

Field metrics

Next, let's check out metrics. Head over to the Fields page.

Beside each , we'll see the number of requesting operations, which is the number of s in a given period that have included that particular .

https://studio.apollographql.com

Fields page in Studio

Note: There's another type of metric called field executions. To see this metric, you'll need a higher volume of requests being sent to your . You can learn more about the difference between executions and requesting s in the Apollo documentation.

And once again we can dive deeper. Click the metrics button for the to navigate to a detailed view.

https://studio.apollographql.com

Fields page details for a specific field in Studio

We can use both and metrics to monitor the health and usage of our 's types and fields and determine where we can start to improve, based on how they're performing and how our clients are using them.

Client awareness

Client awareness is another powerful feature of . Over on the Clients page we can check out how each of our clients is using our , such as which s they're requesting the most, any issues they're running into and which s they're using. Having access to client-specific metrics is cool because it gives us a heads up on when to deprecate or optimize certain fields.

https://studio.apollographql.com

Clients page in Studio

For both s and metrics, you can also see client usage information when you dig into a specific operation or field.

To enable client awareness, clients should send two specific HTTP headers in their requests: apollographql-client-name and apollographql-client-version.

Note: Client version metrics are only available on Enterprise plans.

We recommend encouraging all downstream clients to include those client-specific headers with every request. This information will show up on so we can see exactly where requests are coming from.

Note: If you're using Apollo Client, you can add the name and version properties when you instantiate the ApolloClient class. You can read the Apollo documentation for a code snippet example.

Practice

Which of the following headers could be included with every request to set up GraphOS client awareness?
Which of the following operation metrics does GraphOS provide?

Key takeaways

  • metrics provide an overview of operation request rates, service time, and error percentages within a given time period or for a specific operation.
  • metrics include the requesting s metric, which lists the number of operations in a given period that have included the particular field.
  • To set up client-aware metrics in , incoming requests should include one of these headers: apollographql-client-name and apollographql-client-version.

Up next

We're now equipped with helpful observability tools to give us a peek into our as more and more clients start using it. Speaking of clients, let's take advantage of a cool feature from our cloud to improve the client querying experience.

Previous

Share your questions and comments about this lesson

Your feedback helps us improve! If you're stuck or confused, let us know and we'll help you out. All comments are public and must follow the Apollo Code of Conduct. Note that comments that have been resolved or addressed may be removed.

You'll need a GitHub account to post below. Don't have one? Post in our Odyssey forum instead.