Today we’re going to explore how to use Postman to navigate the New Relic GraphQL API, NerdGraph, and use it to explore your telemetry data, update your account, and a lot more. Postman provides a lot of support for building with APIs and with the recently released New Relic public API collection, you can leverage that support to supercharge your usage of our GraphQL API.
What is NerdGraph?
NerdGraph is the New Relic GraphQL API, and with it, you can get all the information you need with a single query. GraphQL is a query language for APIs that allows you to compose flexible requests to an API in a less structured manner than with the standard REST API. For example, you may wish to get summary data on your application performance monitoring (APM) entities. To do so, you can send the following GraphQL request to NerdGraph:
{
actor {
entitySearch(query: "name like 'nerdgraph' and domainType = 'APM-APPLICATION'") {
results {
entities {
name
... on ApmApplicationEntityOutline {
apmSummary {
errorRate
apdexScore
webResponseTimeAverage
responseTimeAverage
}
}
}
}
}
}
}
You can even use NRQL, New Relic’s query language inside a NerdGraph request for truly customized results. In this example, you are requesting all transaction data within the past hour:
{
actor {
account(id: YOUR_ACCOUNT_ID) {
nrql(query: "SELECT count(*) FROM Transaction SINCE 1 HOUR AGO") {
results
}
}
}
}
While GraphQL can be a very powerful tool in working with your New Relic data, you may not know right away what to put in a query or how to structure one. The New Relic NerdGraph documentation and the New Relic GraphQL explorer are excellent places to begin when learning how to use queries.
Use the new Nerdgraph API collection with Postman
We’ve added a new resource for you to learn about queries with the new Nerdgraph API collection on Postman.
What is Postman?
Postman is a tool that helps you use and build with APIs. It enables seamless collaboration and experimentation in a graphical interface that is friendly for both the newcomer and the veteran to API development. An API collection in Postman is a group of saved requests and descriptions that are editable and customizable by the user. API collections in Postman come with benefits such as error detection in query formulation, auto-suggestions, the ability to define variables to use across requests, and more.
Let’s take a look at how the new Postman Nerdgraph API collection can help you in your work with New Relic.
One of the major benefits of using the Postman Nerdgraph API collection is that you get auto-complete support for your queries right away. For example, if you are querying for your account data, as soon as you begin typing, Postman suggests next steps for you.
The example video below demonstrates this:
How does the auto-complete work so well? Postman automatically refreshes the schema from New Relic NerdGraph for you, so that you always have access to the most up-to-date suggestions when using the New Relic API collection.
Get started with the Postman Nerdgraph API collection
First, visit the API collection homepage at https://www.postman.com/new-relic. From there, you can select to the API collection, which will open either in your browser or inside your Postman client.
Next, provide your API key to your copy of the collection. You can find your API key in New Relic under the API Keys section.
Then, create a Postman Environment and define it as a variable. We’ve already set up a recommended variable name for you to use inside the collection: new_relic_api_key
, so you need only to define its value inside your new Environment.
To create a new Postman Environment, select the Environments button in the right-hand side navigation menu.
You’ll also need to define the API key as a variable inside your new environment. Enter the name as new_relic_api_key
, select secret as the type in the dropdown, and provide your API key in the current value field.
There’s an important distinction between the current and initial value fields. The initial value is synced with members of your team who share the Postman workspace, so if you don’t want to share your API key across your team, fill out only the current value field.
Next, select the plus symbol to create a new environment. You will be prompted to name it. You can name it anything that makes sense for your work, for example, “Production” or “Staging.”
Once you have finished and saved, you are ready to go!
The collection is organized into two separate top-level folders: mutations and queries. Within the mutations folder, you will find sub-folders organized by topics for all the areas of your New Relic account you can modify. The queries folder contains top-level requests that will get you started in requesting data from your account.
다음 단계
Want to try this out on your own free account? Sign up today to try all New Relic features with 100/GB of free data ingest.
Have any questions about the processes described in this blog post? Connect with the New Relic Developer Relations team on our community Slack or send us an email at devrel@newrelic.com!
Did you know you can also monitor your API performance from Postman with New Relic? Learn how to get instant API observability with the Postman integration and quickstart.
이 블로그에 표현된 견해는 저자의 견해이며 반드시 New Relic의 견해를 반영하는 것은 아닙니다. 저자가 제공하는 모든 솔루션은 환경에 따라 다르며 New Relic에서 제공하는 상용 솔루션이나 지원의 일부가 아닙니다. 이 블로그 게시물과 관련된 질문 및 지원이 필요한 경우 Explorers Hub(discuss.newrelic.com)에서만 참여하십시오. 이 블로그에는 타사 사이트의 콘텐츠에 대한 링크가 포함될 수 있습니다. 이러한 링크를 제공함으로써 New Relic은 해당 사이트에서 사용할 수 있는 정보, 보기 또는 제품을 채택, 보증, 승인 또는 보증하지 않습니다.