next-forgenext-forge
Mask

Monitoring

Centralized logging and uptime monitoring.

next-forge uses BetterStack by default for centralized logging and uptime monitoring.

Uptime Monitoring

Setting up monitoring

Uptime monitoring functionality is configured through BetterStack's dashboard. When you create your project, I recommend adding some specific URLs to monitor. Assuming we're using next-forge.com and it's subdomains, here's what you should add:

  1. next-forge.com - the web project, should be up if the index page returns a successful response.
  2. app.next-forge.com - the app project, should be up if the index page returns a successful response.
  3. api.next-forge.com/health - the api project, should be up if the health route returns a successful response. This is a stub endpoint that runs on Edge runtime so it's very quick.

Usage in the UI

next-forge provides a Status component in @repo/design-system that displays the current status of the application. You can see an example of this in the website footer.

The status component shows 3 potential states:

  • All systems normal - 100% of the uptime monitors are reporting up
  • Partial outage - at least one uptime monitor is reporting down
  • Degraded performance - 0% of the uptime monitors are reporting up

This functionality relies on the BETTERSTACK_API_KEY and BETTERSTACK_URL environment variables.

Logging

The logging functionality is abstracted through a simple wrapper in packages/design-system/lib/log.ts that provides a consistent logging interface across environments. In development, logs are output to the console for easy debugging. In production, logs are sent to BetterStack Logs where they can be searched, filtered, and analyzed.

To use this logging setup, simply import and use the log object. It shares the same interface as the console object, so you can replace console with log in your codebase.

page.tsx
import { log } from '@repo/design-system/lib/log';
 
log.info('Hello, world!');

On this page