DEV Community

Jorge Montejo
Jorge Montejo

Posted on AI-assisted

Selfhosted version of Nestjs Observe

Dashboard image example

The problem

If you use @nestjs/observe to monitor your NestJS apps, your telemetry (requests, errors, logs, traces) lives in an external service with plan limits. I wanted the same experience, but running on my own infrastructure.

So I built selfhosted-nestjs-observe: a self-hosted collector and dashboard that works with the @nestjs/observe agent.

What's inside

  • Drop-in collector: you only change the agent's endpoint. Nothing else in your code changes.

Up and running in a minute

The image is published to GHCR (amd64 and arm64):

mkdir observe && cd observe
curl -fsSLO https://raw.githubusercontent.com/MontejoJorge/selfhosted-nestjs-observe/main/deploy/docker-compose.yml
curl -fsSL -o .env https://raw.githubusercontent.com/MontejoJorge/selfhosted-nestjs-observe/main/deploy/.env.example
# set POSTGRES_PASSWORD in .env
docker compose up -d
Enter fullscreen mode Exit fullscreen mode

Open http://localhost:3000, create a project and an application, and copy the API key (the secret is shown only once).

Connect your NestJS app

export const { ObserveModule, ObserveInstrument } = createObserveModule();

@Module({
  imports: [
    ObserveModule.forRoot({
      endpoint: process.env.OBSERVE_ENDPOINT, // your collector
      appKey: process.env.OBSERVE_APP_KEY,
      appSecret: process.env.OBSERVE_APP_SECRET,
      serviceId: 'orders-api',
      forwardLogs: true,
    }),
  ],
})
export class AppModule {}
Enter fullscreen mode Exit fullscreen mode

👉 GitHub: https://github.com/MontejoJorge/selfhosted-nestjs-observe

Top comments (1)

Collapse
 
kostyatretyak profile image
Костя Третяк • • Edited

As far as I understand, the creator of NestJS built a data monitoring solution from @nestjs/observe using an LLM, yet he seems to believe that a large number of people will pay for a subscription to something they could easily build themselves in a week. In my view, that is quite naive. Your project proves this point.