Odyssey

GraphOS: From Development to Launch

Workshop introFollow-along: GraphOS ExplorerExercise: Explore ExplorerGraphOSExercise: Creating a supergraphFollow-along: Metrics and observabilityFollow-along: Using `@defer`Making changes to the supergraphFollow-along: Schema checks & deployFollow-along: Schema publishExercise: Schema checksWhat's in a supergraph?Exercise: Add a subgraphExercise: Exploring entities & rover devFollow-along: Connecting data with entitiesWhat's next?
6. Follow-along: Metrics and observability
3m

Sending fake traffic

We've just launched our supergraph, so it hasn't received much traffic at all yet. 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 supergraph 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 supergraph'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 supergraph. In the meantime, you can check out the Apollo technote about the topic to learn more about rate limiting, setting timeouts, pagination and more.

If operations are failing to reach your supergraph's endpoint, go back to Studio and check your supergraph Settings under the Cloud Router section.

We need to make sure that our config.yaml file has been correctly configured for CORS and that we've explicitly set allow_any_origin to true. Jump back into the last section for a more detailed look at each one of these steps.

Still having trouble? Visit the Odyssey forums to get help.

GraphOS Metrics

Let's head back to Studio, where our supergraph metrics live. Here, we'll see the kinds of insights Studio assembles for our supergraph based on usage, latency, and errors. We'll start with the Operations page.

Operation metrics

The Operations page focuses on just that—operations that have been sent to our supergraph! We've just faked a bunch of operations through the Code Sandbox, so we should be seeing some data here.

https://studio.apollographql.com

Operations page in Studio

We'll find an overview of operation request rates, service time, and error percentages, including specific operations for each of these that might be worth drilling deeper into.

This page also comes with some helpful filters which let us customize the specific time period, clients, and operations we want to see data for. By default, we'll see metrics for operations executed in the last day.

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

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

By clicking into an individual operation, we can see more specific metrics along with the operation signature, which shows us the particular fields that were involved in the operation. With that knowledge, we can jump over into the Fields tab to dig deeper.

Field metrics

The Fields page lists all of the fields in our schema, sectioned by the type they appear on. Here we can investigate the fields in our operation, reviewing which clients have requested them and how often.

When our graph starts to receive more traffic, we can get resolver-level metrics—which let us drill a lot deeper to see what's going on with each field and where there might be a higher level of latency.

With a GraphOS enterprise plan, we can set the sampling rate to be higher; this lets us see field-level insights with less traffic.

Slow queries

When we analyze our graph's metrics, we can compare which queries are taking the longest to resolve. The Operations page includes a section called Slowest p95 Service Time; here we'll see the names of the operations, along with the time—either in seconds, or milliseconds, typically—it took for them to resolve.

https://studio.apollographql.com

The Operations page in Studio, highlighting the slowest service time section.

Note: The "p95" indicates that the time given for each operation is something of an upper limit. 95% of the operation's executions actually complete faster than the reported value, but this way we can more easily see the worst time an operation takes to resolve.

The query GetRecipePage stands out here as the slowest operation—with a whopping three seconds to resolve! Let's look at how we tackle queries with parts that resolve more slowly than others in the next section.

Previous
Next

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.

              launched

              The process of applying a set of updates to a supergraph. Launches are usually triggered by making changes to one of your published subgraph schemas.

              supergraph

              A unified, federated graph composed of separate GraphQL APIs using Apollo Federation. Enables a microservices architecture that exposes a unified GraphQL API to clients.

              supergraph

              A unified, federated graph composed of separate GraphQL APIs using Apollo Federation. Enables a microservices architecture that exposes a unified GraphQL API to clients.

              supergraph

              A unified, federated graph composed of separate GraphQL APIs using Apollo Federation. Enables a microservices architecture that exposes a unified GraphQL API to clients.

              supergraph

              A unified, federated graph composed of separate GraphQL APIs using Apollo Federation. Enables a microservices architecture that exposes a unified GraphQL API to clients.

              operations

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              supergraph

              A unified, federated graph composed of separate GraphQL APIs using Apollo Federation. Enables a microservices architecture that exposes a unified GraphQL API to clients.

              supergraph

              A unified, federated graph composed of separate GraphQL APIs using Apollo Federation. Enables a microservices architecture that exposes a unified GraphQL API to clients.

              metrics

              Measurements of the router's behavior that can be exported and monitored, for example, the number of in-flight requests.

              Operations

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              supergraph

              A unified, federated graph composed of separate GraphQL APIs using Apollo Federation. Enables a microservices architecture that exposes a unified GraphQL API to clients.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              operations

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              metrics

              Measurements of the router's behavior that can be exported and monitored, for example, the number of in-flight requests.

              GraphQL

              An open-source query language and specification for APIs that enables clients to request specific data, promoting efficiency and flexibility in data retrieval.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              supergraph

              A unified, federated graph composed of separate GraphQL APIs using Apollo Federation. Enables a microservices architecture that exposes a unified GraphQL API to clients.

              metrics

              Measurements of the router's behavior that can be exported and monitored, for example, the number of in-flight requests.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              metrics

              Measurements of the router's behavior that can be exported and monitored, for example, the number of in-flight requests.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              graph

              A schema-based data model representing how different data elements interconnect and can be accessed.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              GraphOS

              A platform for building and managing a supergraph. It provides a management plane to test and ship changes and runtime capabilities to secure and monitor the graph.

              enterprise plan

              An Apollo plan featuring self-hosted routing, advanced security and schema delivery features, access control, and more.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              graph

              A schema-based data model representing how different data elements interconnect and can be accessed.

              metrics

              Measurements of the router's behavior that can be exported and monitored, for example, the number of in-flight requests.

              operations

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              query

              A request for specific data from a GraphQL server. Clients define the structure of the response, enabling precise and efficient data retrieval.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              NEW COURSE ALERT

              Introducing Apollo Connectors

              Connectors are the new and easy way to get started with GraphQL, using existing REST APIs.

              Say goodbye to GraphQL servers and resolvers—now, everything happens in the schema!

              Take the course