Self hosting

Sentry

Copy page

Add sentry monitoring to your agent services

Overview

Learn how to add Sentry monitoring to your Inkeep Agent Framework services.

Step 1: Install Sentry

pnpm install @sentry/node

Step 2: Update your .env file

Add your Sentry DSN to the .env file in the root of your workspace.

SENTRY_DSN=https://<your-sentry-dsn>@sentry.io/<your-sentry-project>

Step 3: Configure Sentry

In apps/run-api and apps/manage-api create a new file called sentry.ts and add the following code:

import * as Sentry from "@sentry/node";

Sentry.init({
  dsn: process.env.SENTRY_DSN,
  sampleRate: 1.0,
  tracesSampleRate: 1.0,
});

In apps/run-api/src/index.ts and apps/manage-api/src/index.ts add the following code to the top of the file before all other imports:

import "./sentry";

Forward Error Logs to Sentry

You can use pino-sentry-transport to forward error logs to Sentry.

Step 1: Install pino-sentry-transport

pnpm install pino-sentry-transport

Step 2: Configure pino-sentry-transport

Add the following code to the top of your apps/run-api/src/index.ts file:

logger = getLogger('agents-run-api');
logger.addTransport({
  target: 'pino-sentry-transport',
  options: {
    sentry: {
      dsn: process.env.SENTRY_DSN,
    },
  },
});

Add the following code to the top of your apps/manage-api/src/index.ts file:

logger = getLogger('agents-manage-api');
logger.addTransport({
  target: 'pino-sentry-transport',
  options: {
    sentry: {
      dsn: process.env.SENTRY_DSN,
    },
  },
});

Addition Resources

For more information on how to configure your Sentry you can consult the official Sentry Node.js documentation.