### Setup Vector with Script Source: https://betterstack.com/docs/logs/postgresql Downloads and executes a setup script to install and configure Vector for PostgreSQL logs. This script handles installation, configuration, and service management. ```bash [label Set up Vector] curl -sSL https://telemetry.betterstack.com/setup-vector/postgresql/$SOURCE_TOKEN \ -o /tmp/setup-vector.sh && \ bash /tmp/setup-vector.sh ``` -------------------------------- ### Install and start Elasticsearch exporter Source: https://betterstack.com/docs/logs/elasticsearch Downloads and executes the installation script for the Elasticsearch exporter. ```bash curl -sSL https://telemetry.betterstack.com/install/elasticsearch_exporter | sudo -E bash ``` -------------------------------- ### Set up Vector with Setup Script Source: https://betterstack.com/docs/logs/docker Use this script to automatically install and configure Vector for your Better Stack source on supported platforms. It handles installation, configuration, and service management. ```bash curl -sSL https://telemetry.betterstack.com/setup-vector/docker/$SOURCE_TOKEN \ -o /tmp/setup-vector.sh && \ bash /tmp/setup-vector.sh ``` -------------------------------- ### Install and configure Vector on Windows Source: https://betterstack.com/docs/logs/nginx Commands to install the Vector MSI, replace the configuration file, and start the service. ```powershell powershell Invoke-WebRequest https://packages.timber.io/vector/latest/vector-x64.msi -OutFile vector-latest-x64.msi msiexec /i vector-latest-x64.msi ``` ```powershell $config_yaml_path = "C:\Program Files\Vector\config\vector.yaml" $backup_path = "C:\Program Files\Vector\config\vector-backup.yaml" Move-Item -Path "$config_yaml_path" -Destination "$backup_path" Invoke-RestMethod -Uri https://telemetry.betterstack.com/vector-yaml/nginx/$SOURCE_TOKEN | Add-Content $config_yaml_path ``` ```powershell & "C:\Program Files\Vector\bin\vector" --config "C:\Program Files\Vector\config\vector.yaml" ``` -------------------------------- ### Set up Vector with Setup Script Source: https://betterstack.com/docs/logs/mysql Use this script to automatically install and configure Vector for your Better Stack source on supported Linux distributions. It handles installation, configuration, and service management. ```bash [label Set up Vector] curl -sSL https://telemetry.betterstack.com/setup-vector/mysql/$SOURCE_TOKEN \ -o /tmp/setup-vector.sh && \ bash /tmp/setup-vector.sh ``` -------------------------------- ### Install and configure Vector on Windows Source: https://betterstack.com/docs/logs/haproxy Commands to install the Vector MSI, configure the YAML file, and start the service on Windows. ```powershell powershell Invoke-WebRequest https://packages.timber.io/vector/latest/vector-x64.msi -OutFile vector-latest-x64.msi msiexec /i vector-latest-x64.msi ``` ```powershell $config_yaml_path = "C:\Program Files\Vector\config\vector.yaml" $backup_path = "C:\Program Files\Vector\config\vector-backup.yaml" Move-Item -Path "$config_yaml_path" -Destination "$backup_path" Invoke-RestMethod -Uri https://telemetry.betterstack.com/vector-yaml/haproxy/$SOURCE_TOKEN | Add-Content $config_yaml_path ``` ```powershell & "C:\Program Files\Vector\bin\vector" --config "C:\Program Files\Vector\config\vector.yaml" ``` -------------------------------- ### Set Up Vector with Setup Script Source: https://betterstack.com/docs/logs/minio Use the provided curl command to download and execute a setup script for Vector on Linux systems. This script installs Vector, configures it for your Better Stack source, and enables/restarts the service. ```bash curl -sSL https://telemetry.betterstack.com/setup-vector/minio/$SOURCE_TOKEN \ -o /tmp/setup-vector.sh && \ bash /tmp/setup-vector.sh ``` -------------------------------- ### Set up Vector on Linux Source: https://betterstack.com/docs/logs/apache Executes a setup script to install and configure Vector for an Apache source on Linux systems. ```bash curl -sSL https://telemetry.betterstack.com/setup-vector/apache/$SOURCE_TOKEN \ -o /tmp/setup-vector.sh && \ bash /tmp/setup-vector.sh ``` -------------------------------- ### Set up Vector on Linux/macOS Source: https://betterstack.com/docs/logs/traefik Use a setup script to install and configure Vector for Traefik with metrics collection. The script will prompt for confirmation before making changes. ```bash curl -sSL https://telemetry.betterstack.com/setup-vector/traefik_with_metrics/$SOURCE_TOKEN \ -o /tmp/setup-vector.sh && \ bash /tmp/setup-vector.sh ``` -------------------------------- ### Start data collection Source: https://betterstack.com/docs/errors/js-tag/install The betterstack('init', opts) call starts data collection. You can pass options like environment, release, autoPageview, and debug. ```javascript betterstack('init', { environment: 'production', release: '1.4.2', }); ``` -------------------------------- ### Deploying the Google Cloud integration to your entire organization Source: https://betterstack.com/docs/logs/google-cloud This script deploys the Google Cloud integration to your entire organization, granting access to all projects. ```bash curl -sLO https://raw.githubusercontent.com/BetterStackHQ/gcp/refs/heads/main/setup.sh chmod +x setup.sh ./setup.sh \ --project=my-project-id \ --org-id=organization-numeric-id \ --source-token=$SOURCE_TOKEN \ --ingesting-host=$INGESTING_HOST ``` -------------------------------- ### Custom configuration before init Source: https://betterstack.com/docs/errors/js-tag/install Example of setting custom configuration options for the Better Stack JavaScript tag before initializing it. ```javascript betterstack('config', { environment: 'production', release: 'abcdef012345', sentry: { ignoreErrors: ['TestError'], }, }); betterstack('init'); ``` -------------------------------- ### Set up Vector for MongoDB Logging (Linux/macOS) Source: https://betterstack.com/docs/logs/mongodb Installs and configures Vector for MongoDB logging using a setup script. This script handles Vector installation, configuration for your Better Stack source, and service management. ```bash curl -sSL https://telemetry.betterstack.com/setup-vector/mongodb/$SOURCE_TOKEN \ -o /tmp/setup-vector.sh && \ bash /tmp/setup-vector.sh ``` -------------------------------- ### Set up Vector for Redis Logs (Linux) Source: https://betterstack.com/docs/logs/redis Installs and configures Vector for Redis log collection using a setup script. The script handles installation, configuration for your Better Stack source, and service enablement. It prompts for confirmation before making changes. ```bash curl -sSL https://telemetry.betterstack.com/setup-vector/redis/$SOURCE_TOKEN \ -o /tmp/setup-vector.sh && \ bash /tmp/setup-vector.sh ``` -------------------------------- ### Deploying the Google Cloud integration using gcloud bash script Source: https://betterstack.com/docs/logs/google-cloud This script deploys the Google Cloud integration to a single project. ```bash curl -sLO https://raw.githubusercontent.com/BetterStackHQ/gcp/refs/heads/main/setup.sh chmod +x setup.sh ./setup.sh \ --project=my-project-id \ --source-token=$SOURCE_TOKEN \ --ingesting-host=$INGESTING_HOST ``` -------------------------------- ### Install Vector on Linux (Manual) Source: https://betterstack.com/docs/logs/apache Installs Vector using the official manual installer script. ```sh curl --proto '=https' --tlsv1.2 -sSf https://sh.vector.dev | sh -s -- -y ``` -------------------------------- ### Install Vector on Linux (generic) Source: https://betterstack.com/docs/logs/log-forwarding Installs Vector using the official installer script. ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.vector.dev | sh -s -- -y ``` -------------------------------- ### Install Vector on Windows using official installer Source: https://betterstack.com/docs/logs/log-forwarding Downloads and installs Vector on Windows using the official MSI installer. ```powershell powershell Invoke-WebRequest https://packages.timber.io/vector/latest/vector-x64.msi -OutFile vector-latest-x64.msi msiexec /i vector-latest-x64.msi ``` -------------------------------- ### Start MySQL Exporter Source: https://betterstack.com/docs/logs/mysql Start the exporter service on Linux or macOS. ```sh systemctl start mysqld_exporter ``` ```sg launchctl start com.prometheus.mysqld_exporter ``` -------------------------------- ### Install Vector on Linux APT Source: https://betterstack.com/docs/logs/vector Configures the APT repository and installs the Vector package. ```sh [label Install Vector] bash -c "$(curl -L https://setup.vector.dev)" apt-get install vector ``` -------------------------------- ### Install PostgreSQL exporter Source: https://betterstack.com/docs/logs/postgresql Downloads and installs the latest version of the postgres exporter. ```bash curl -sSL https://telemetry.betterstack.com/install/postgres_exporter | sudo -E bash ``` -------------------------------- ### Example cURL Source: https://betterstack.com/docs/uptime/api/single-slack-integration Example cURL request to get a single Slack integration. ```curl curl --request GET \ --url https://uptime.betterstack.com/api/v2/slack-integrations/37 \ --header "Authorization: Bearer $TOKEN" ``` -------------------------------- ### Set up Vector via script Source: https://betterstack.com/docs/logs/elasticsearch Downloads and runs the automated setup script for Vector. ```bash curl -sSL https://telemetry.betterstack.com/setup-vector/elasticsearch_with_metrics/$SOURCE_TOKEN \ -o /tmp/setup-vector.sh && \ bash /tmp/setup-vector.sh ``` -------------------------------- ### Fulltext search: Match GET or POST requests Source: https://betterstack.com/docs/logs/using-logtail/live-tail-query-language Filters logs where the log message contains 'Started GET' or 'Started POST'. ```text /Started (GET|POST)/ ``` -------------------------------- ### Set up Vector via script Source: https://betterstack.com/docs/logs/rabbitmq Automated installation and configuration script for supported Linux and macOS environments. ```bash curl -sSL https://telemetry.betterstack.com/setup-vector/rabbitmq/$SOURCE_TOKEN \ -o /tmp/setup-vector.sh && \ bash /tmp/setup-vector.sh ``` -------------------------------- ### Set up Vector via script Source: https://betterstack.com/docs/logs/haproxy Automated installation and configuration script for supported Linux distributions. ```bash curl -sSL https://telemetry.betterstack.com/setup-vector/haproxy/$SOURCE_TOKEN \ -o /tmp/setup-vector.sh && \ bash /tmp/setup-vector.sh ``` -------------------------------- ### Example Request Source: https://betterstack.com/docs/logs/api/get-a-single-collector This example shows how to retrieve details for a single collector using cURL. ```shell curl -L -H "Authorization: Bearer $TOKEN" \ "https://telemetry.betterstack.com/api/v1/collectors/1" ``` -------------------------------- ### Set up Vector on Linux/macOS Source: https://betterstack.com/docs/logs/redis This script installs and configures Vector for your Better Stack source. It handles installation, configuration, and service management. Run this script with your SOURCE_TOKEN. ```bash [label Set up Vector] curl -sSL https://telemetry.betterstack.com/setup-vector/redis_with_metrics/$SOURCE_TOKEN \ -o /tmp/setup-vector.sh && \ bash /tmp/setup-vector.sh ``` -------------------------------- ### Example cURL Source: https://betterstack.com/docs/uptime/api/get-a-single-monitor This example shows how to retrieve a single monitor using cURL. ```shell curl --request GET \ --url https://uptime.betterstack.com/api/v2/monitors/123456789 \ --header "Authorization: Bearer $TOKEN" ``` -------------------------------- ### Example cURL Source: https://betterstack.com/docs/uptime/api/get-a-single-status-page-subscriber This example shows how to retrieve a specific status page subscriber using cURL. ```bash curl --request GET \ --url https://uptime.betterstack.com/api/v2/status-pages/987654321/subscribers/123456789 \ --header "Authorization: Bearer $TOKEN" ``` -------------------------------- ### Install Monolog Logtail Package Source: https://betterstack.com/docs/logs/php Install the Better Stack Monolog client library using Composer. Choose the appropriate version based on your Monolog setup. ```bash composer require logtail/monolog-logtail ``` ```bash composer require logtail/monolog-logtail:^2.0.0 ``` -------------------------------- ### Set up Vector on Ubuntu Source: https://betterstack.com/docs/logs/ubuntu Run this script to install and configure Vector on your Ubuntu server for Better Stack. It handles Vector installation, configuration for your source, and service management. The script prompts for confirmation before making changes. ```bash [label Set up Vector] curl -sSL https://telemetry.betterstack.com/setup-vector/ubuntu/$SOURCE_TOKEN \ -o /tmp/setup-vector.sh && \ bash /tmp/setup-vector.sh ``` -------------------------------- ### Incident Started Payload Source: https://betterstack.com/docs/uptime/api/reporting Example JSON payload for an 'incident.started' event. ```json { "dt": "2026-05-13T12:30:00.000Z", "event": "incident.started", "message": "Incident \"My Website is Down\" started — Connection refused", "organization_id": "org_123", "team_id": "team_456", "incident_id": 201, "incident_name": "My Website is Down", "resource_type": "monitor", "resource_id": 789, "resource_name": "My Website", "incident_cause": "Connection refused", "regions": ["us-east-1", "eu-central-1"], "escalation_policy_id": 111 } ``` -------------------------------- ### Get Incident cURL Request Source: https://betterstack.com/docs/uptime/api/list-a-single-incident Example command to fetch an incident using cURL. ```shell curl --request GET \ --url https://uptime.betterstack.com/api/v3/incidents/123456789 \ --header "Authorization: Bearer $TOKEN" ``` -------------------------------- ### Example cURL Source: https://betterstack.com/docs/logs/api/create-a-source This example shows how to create a new HTTP source using cURL. ```shell curl --request POST \ --url https://telemetry.betterstack.com/api/v1/sources \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/json" \ --data '{ "name": "My new HTTP source", "platform": "http", "data_region": "us_east" }' ``` -------------------------------- ### Verify Logging with kubectl describe Source: https://betterstack.com/docs/logs/aws-fargate Example output showing that logging is successfully enabled for a pod. ```text $ kubectl describe pods/sample-app-97bfb67f7-8hq6l Name: sample-app-97bfb67f7-8hq6l Namespace: default ... Annotations: CapacityProvisioned: 0.25vCPU 0.5GB Logging: LoggingEnabled kubectl.kubernetes.io/restartedAt: 2023-09-05T17:02:29+02:00 ... Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal LoggingEnabled 3m41s fargate-scheduler Successfully enabled logging for pod Normal Scheduled 2m53s fargate-scheduler Successfully assigned default/sample-app-97bfb67f7-8hq6l to fargate-ip-10-0-128-131.eu-north-1.compute.internal ``` -------------------------------- ### Install and configure Vector on Linux Source: https://betterstack.com/docs/logs/haproxy Manual installation, service creation, configuration download, and restart commands for Linux systems. ```sh curl --proto '=https' --tlsv1.2 -sSf https://sh.vector.dev | sh -s -- -y ``` ```sh mkdir -p /etc/vector mkdir -p /var/lib/vector/ cat <<-'SERVICE' >> /etc/systemd/system/vector.service [Unit] Description=Vector Documentation=https://vector.dev After=network-online.target Requires=network-online.target [Service] User=vector Group=vector ExecStart=/root/.vector/bin/vector ExecReload=/bin/kill -HUP $MAINPID Restart=no AmbientCapabilities=CAP_NET_BIND_SERVICE EnvironmentFile=-/etc/default/vector [Install] WantedBy=multi-user.target SERVICE ``` ```bash CONFIG_YAML_PATH="/etc/vector/vector.yaml" BACKUP_SUFFIX=".bak-$(date +%Y%m%d%H%M%S)" mv "${CONFIG_YAML_PATH}" "${CONFIG_YAML_PATH}${BACKUP_SUFFIX}" curl -o "$CONFIG_YAML_PATH" \ https://telemetry.betterstack.com/vector-yaml/haproxy/$SOURCE_TOKEN ``` ```sh systemctl restart vector ``` -------------------------------- ### Install slog-betterstack dependency Source: https://betterstack.com/docs/logs/go Use the go get command to add the Better Stack slog handler to your project dependencies. ```bash go get github.com/samber/slog-betterstack ``` -------------------------------- ### Install Vector and Create Service on Linux Source: https://betterstack.com/docs/logs/vector Installs Vector using the official script and creates a systemd service unit file. ```sh [label Install Vector] curl --proto '=https' --tlsv1.2 -sSf https://sh.vector.dev | sh -s -- -y ``` ```sh [label Create a Vector service] mkdir -p /etc/vector mkdir -p /var/lib/vector/ cat <<-'SERVICE' >> /etc/systemd/system/vector.service [Unit] Description=Vector Documentation=https://vector.dev After=network-online.target Requires=network-online.target [Service] User=vector Group=vector ExecStart=/root/.vector/bin/vector ExecReload=/bin/kill -HUP $MAINPID Restart=no AmbientCapabilities=CAP_NET_BIND_SERVICE EnvironmentFile=-/etc/default/vector [Install] WantedBy=multi-user.target SERVICE ``` -------------------------------- ### cURL Source: https://betterstack.com/docs/logs/api/get-collector-metrics-targets Example cURL command to retrieve a single collector metrics target. ```shell curl "https://telemetry.betterstack.com/api/v1/collectors/1/targets/1" \ -H "Authorization: Bearer $TOKEN" ``` -------------------------------- ### Example: Collector with Configuration Source: https://betterstack.com/docs/logs/api/create-a-collector This example demonstrates creating a Kubernetes collector with specific component configurations and VRL transformations using cURL. ```shell curl -X POST "https://telemetry.betterstack.com/api/v1/collectors" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Configured K8s Collector", "platform": "kubernetes", "configuration": { "components": { "ebpf_metrics": true, "ebpf_red_metrics": true, "ebpf_tracing_full": true, "logs_kubernetes": true, "metrics_databases": false }, "vrl_transformation": ".message = downcase!(.message)", "when_full": "block", "log_line_length_limit_kb": 64, } }' ``` -------------------------------- ### Example cURL Source: https://betterstack.com/docs/logs/api/dashboards/export This cURL command demonstrates how to export a dashboard by making a GET request to the export endpoint. ```shell curl --request GET \ --url "https://telemetry.betterstack.com/api/v2/dashboards/1234/export" \ --header "Authorization: Bearer $TOKEN" ``` -------------------------------- ### Example: Constructing New Ingesting Host Source: https://betterstack.com/docs/logs/aws/direct-connect This example demonstrates how to construct the new ingesting host for AWS Direct Connect based on your current cluster and a chosen AWS region. ```text eu-nbg-2-aws-eu-central-1.betterstackdata.com ``` -------------------------------- ### Setup Vector on Ubuntu or Debian Source: https://betterstack.com/docs/logs/ingesting-data/logs/docker-kubernetes Installs and configures Vector on Ubuntu or Debian systems. ```bash curl -sSL https://telemetry.betterstack.com/setup-vector/docker/$SOURCE_TOKEN \ -o /tmp/setup-vector.sh && \ bash /tmp/setup-vector.sh ``` -------------------------------- ### Example runbook instructions with TODO list Source: https://betterstack.com/docs/uptime/runbooks This markdown example demonstrates how to structure runbook instructions, including tasks that can be checked off. ```markdown ## When to Use Triggered when CPU > 90% for 5+ minutes on a web server. ## Steps - [ ] **Acknowledge the Alert** - [ ] **Find the Affected Server** - Use logs or metrics dashboard to identify the instance/container - Example: `aws ecs list-tasks --cluster web-prod` - [ ] **SSH or Access Container** - `ssh ec2-user@` - [ ] **Diagnose the Issue** - Run `top` or `htop` to find CPU-heavy process - Check application logs - [ ] **Fix or Mitigate** - Restart service if needed - Scale up if traffic is legitimate - [ ] **Verify** - CPU drops below 70% - No 5xx errors - App is responsive ``` -------------------------------- ### Example cURL Source: https://betterstack.com/docs/uptime/api/single-splunk-on-call-integration This cURL command demonstrates how to retrieve a specific Splunk On-Call integration using its ID. ```bash curl --request GET \ --url https://uptime.betterstack.com/api/v2/splunk-on-call/17 \ --header "Authorization: Bearer $TOKEN" ``` -------------------------------- ### Investigate the error Source: https://betterstack.com/docs/ai-sre/writing-code/bulk-resolving-errors Example prompt to get details of a specific error and find related errors. ```bash [label Example prompt] Get the details of the security error. Are there any other errors related to this one so they can be fixed together? ``` -------------------------------- ### Start Vector on Windows Source: https://betterstack.com/docs/logs/apache Launches the Vector executable with the specified configuration file. ```powershell & "C:\Program Files\Vector\bin\vector" --config "C:\Program Files\Vector\config\vector.yaml" ``` -------------------------------- ### Setup Vector configuration on Linux Source: https://betterstack.com/docs/logs/metrics/vector Downloads the Vector configuration for your Better Stack source and applies it. ```bash CONFIG_YAML_PATH="/etc/vector/vector.yaml" BACKUP_SUFFIX=".bak-$(date +%Y%m%d%H%M%S)" mv "${CONFIG_YAML_PATH}" "${CONFIG_YAML_PATH}${BACKUP_SUFFIX}" DOCKER_PRESENT=$(command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1 && echo "true" || echo "false") curl -o "$CONFIG_YAML_PATH" \ "https://telemetry.betterstack.com/vector-yaml/ubuntu/$SOURCE_TOKEN?docker=$DOCKER_PRESENT" ``` -------------------------------- ### Get Status Update cURL Example Source: https://betterstack.com/docs/uptime/api/get-a-single-status-update Use this cURL command to retrieve a specific status update. Replace placeholders with your actual IDs and Bearer token. ```shell curl --request GET \ --url https://uptime.betterstack.com/api/v2/status-pages/123456/status-reports/12345/status-updates/123456 \ --header "Authorization: Bearer $TOKEN" ``` -------------------------------- ### Install Serilog Packages Source: https://betterstack.com/docs/logs/net-c Use the .NET CLI to install the necessary Serilog extension and Better Stack integration packages. ```bash dotnet add package Serilog.Extensions.Logging dotnet add package BetterStack.Logs.Serilog ``` -------------------------------- ### Setup Vector configuration on Linux Source: https://betterstack.com/docs/logs/log-forwarding Downloads the Vector configuration for your Better Stack source on Linux. ```bash CONFIG_YAML_PATH="/etc/vector/vector.yaml" BACKUP_SUFFIX=".bak-$(date +%Y%m%d%H%M%S)" mv "${CONFIG_YAML_PATH}" "${CONFIG_YAML_PATH}${BACKUP_SUFFIX}" DOCKER_PRESENT=$(command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1 && echo "true" || echo "false") curl -o "$CONFIG_YAML_PATH" \ "https://telemetry.betterstack.com/vector-yaml/ubuntu/$SOURCE_TOKEN?docker=$DOCKER_PRESENT" ``` -------------------------------- ### List Slack Integrations cURL Example Source: https://betterstack.com/docs/uptime/api/list-all-slack-integrations Use this cURL command to make a GET request to the Slack integrations endpoint. Ensure you replace `$TOKEN` with your actual API token. ```shell curl --request GET \ --url https://uptime.betterstack.com/api/v2/slack-integrations \ --header "Authorization: Bearer $TOKEN" ``` -------------------------------- ### Example cURL Request to List Alerts Source: https://betterstack.com/docs/logs/api/exploration-alerts/list This cURL command demonstrates how to make a GET request to retrieve alerts for a specific exploration. Ensure you replace `$TOKEN` with your actual API token. ```shell curl --request GET \ --url "https://telemetry.betterstack.com/api/v2/explorations/123/alerts" \ --header "Authorization: Bearer $TOKEN" ``` -------------------------------- ### Example: Basic Collector Source: https://betterstack.com/docs/logs/api/create-a-collector This example shows how to create a basic collector for a Docker platform using cURL. ```shell curl -X POST "https://telemetry.betterstack.com/api/v1/collectors" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "My Docker Collector", "platform": "docker", "note": "For staging environment services." }' ``` -------------------------------- ### Wrap Route Handler with Better Stack Source: https://betterstack.com/docs/logs/javascript/nextjs Wrap your Next.js route handlers with `withBetterStack` to automatically add a logger to requests and log exceptions. This example shows logging within a GET request handler. ```typescript import { withBetterStack, BetterStackRequest } from '@logtail/next'; export const GET = withBetterStack((request: BetterStackRequest) => { request.log.info('Login function called'); // You can create intermediate loggers const log = request.log.with({ scope: 'user' }); log.info('User logged in', { userId: 42 }); return NextResponse.json({ hello: 'world' }); }); ``` ```typescript import { withBetterStack, BetterStackRequest } from '@logtail/next'; export const GET = withBetterStack((req: BetterStackRequest) => { req.log.info('Login function called'); // You can create intermediate loggers const log = req.log.with({ scope: 'user' }); log.info('User logged in', { userId: 42 }); return NextResponse.json({ hello: 'world' }); }); ```