GraphQL Mesh Metrics Plugin
The Stellate Mesh Metrics Plugin is a robust tool designed to integrate Stellate with The Guild Mesh framework. This framework is used to construct GraphQL Gateways over GraphQL and non-GraphQL services, such as REST, gRPC, and more.
Our Mesh Server Metrics Plugin enables metrics logging, allowing for a seamless connection with the Stellate service for performance insights and analytics.
The Mesh Metrics Plugin is a JavaScript-based plugin. We also support the Ruby Metrics Plugin, Strawberry Metrics Plugin, and Java Metrics Plugin.
Benefits of the Mesh Metrics Plugin
The Stellate Mesh Metrics Plugin lets you collect metrics without setting up the Stellate Edge proxy. For more information about the Stellate Edge proxy metrics, read Stellate Edge Proxy Metrics.
Benefits of the Mesh Metrics Plugin
- Setup and integration with just a few lines of code.
- Ability to log metrics, which are useful for monitoring and analyzing API usage.
- The Mesh plugin, as do all of the plugins for JavaScript-based servers, takes a
fetch
function as an argument. This enables you to use the plugin in any JavaScript environment. If you are running NodeJS you can use thenode-fetch
package, and in an edge environment (such as Cloudflare Workers) you can pass the global fetch function.
Before You Begin
Before you install and use the Stellate Mesh Metrics Plugin, you need to have Mesh installed and set up. For information about the Mesh set up, read The Guild Mesh documentation. Additionally, you need to:
Set Up a Stellate Service: You must have an active Stellate service set up. Our GraphQL Mesh Plugin is designed to work with your Stellate service.
Create a Logging Token: To implement this plugin, you need to create a logging token specific to your Stellate service. This token is used to authenticate and log metrics data from your GraphQL API to your Stellate dashboard. You can get your logging token by going to your Stellate Dashboard > Services > Your Service > Config > Token.
Install the Mesh Metrics Plugin
To install and use the Mesh plugin, use the following steps:
- Have a Stellate service and create a logging token in place. See the prior Before You Begin section for more information.
- Install
@graphql-mesh/cli
packages and other packages, as needed. Read GraphQL Mesh Installation for more information. - Copy and paste the following JavaScript plugin code to your server:
// envelopPlugins.ts
import { createStellateLoggerPlugin } from 'stellate/envelop'
import { MeshPlugin } from '@graphql-mesh/types'
const plugins: MeshPlugin = [
createStellateLoggerPlugin({
serviceName: '${serviceName}',
token: '${loggingToken}',
// a fetch compliant function, can be from `node-fetch` if you are running in NodeJS,
// or the global fetch function if running in a v8 environment (e.g. Cloudflare Workers)
fetch: fetch,
}),
]
// reference this file using 'additionalEnvelopPlugins' in your .meshrc.yaml config file
export default plugins
- Start the server to begin handling requests.
- Refresh your dashboard to show the incoming requests and metrics, highlighting the plugin's capability to track Mesh GraphQL API usage.
Discover more
JavaScript Server Plugins
Other Language Plugins