Apollo GraphQL App Insights Configuration
(~7 minutes) Instructions for adding Azure Monitor - App Insights logging to Apollo GraphQL
Initialize App Insights and Import Types
Add App Insights to the data-access project:
In terminal go to azure-quickstart/data-access
and issue the following command:
Add "APPINSIGHTS_INSTRUMENTATIONKEY" to your localsettings.json with the Instrumentation Key from application insights
Instrumentation Key: In Azure: Go to the Application Insights resource named sharethrift. The Instrumental key will be under essentials.
Add the following to the top of the index.ts
to initialize the App Insights client as early as possible and to import the types needed for the plugin. Note in the configuration we've defined a custom property of "functionArea" to help organize our logs and make them easier to query.
Define the Apollo Plugin
This plugin logs some valuable information:
Metrics: apollo-query / apollo-error
Quickly see the volume of queries / errors in Azure Monitor
Exceptions:
Track down details of errors through Azure Log Analytics
Add the plugin to Apollo Server
Resources:
Principled GraphQL - Structured Logging
Last updated