### Configure get command options Source: https://github.com/checkly/docs/blob/main/cli/checkly-status-pages.mdx Examples for formatting the output of the get command. ```bash npx checkly status-pages get --output=json npx checkly status-pages get -o md ``` -------------------------------- ### Checkly API Check: Setup Script Example Source: https://github.com/checkly/docs/blob/main/redirects.md An example of a setup script for an API check. Setup scripts run before the main check logic and can be used for tasks like authentication or data preparation. ```javascript export default { async setup() { const response = await fetch('https://api.example.com/login', { method: 'POST', body: JSON.stringify({ username: 'test', password: 'password' }), }); const data = await response.json(); return { token: data.token }; }, async test({ page, request, data }) { // Use data.token in your check const response = await request.get('https://api.example.com/users', { headers: { Authorization: `Bearer ${data.token}` }, }); expect(response.status()).toBe(200); }, }; ``` -------------------------------- ### Interactive Setup Example Source: https://github.com/checkly/docs/blob/main/cli/checkly-init.mdx Initiate an interactive setup process for Checkly by running the `checkly init` command without any specific options. ```bash npx checkly init ``` -------------------------------- ### Start App with uWSGI Source: https://github.com/checkly/docs/blob/main/resolve/traces/instrumentation/django.mdx Example command to start your application using uWSGI with specified master, processes, and threads. ```bash uwsgi --http :8000 --wsgi-file myapp.wsgi --master --processes 4 --threads 2 ``` -------------------------------- ### Checkly CLI setup prompts Source: https://github.com/checkly/docs/blob/main/guides/startup-guide-detect-communicate-resolve.mdx Example of the interactive prompts encountered during the project initialization process. ```text Hi Nica Mellifera! Let's get you started on your monitoring as code journey! ✔ Where do you want to create your new project? … detect-comm-resolve ◼ Cool. Your project will be created in the directory "/Users/nica/checkly/examples/detect-comm-resolve" ? Which template would you like to use for your new project? › - Use arrow-keys. Return to submit. ❯ An advanced TypeScript project with multiple examples and best practices (recommended) An advanced JavaScript project with multiple examples and best practices A boilerplate TypeScript project with basic config A boilerplate JavaScript project with basic config ✔ Would you like to install NPM dependencies? (recommended) … yes ✔ Packages installed successfully ✔ Would you like to initialize a new git repo? (optional) … no ``` -------------------------------- ### Start App with Gunicorn Source: https://github.com/checkly/docs/blob/main/resolve/traces/instrumentation/django.mdx Example command to start your application using Gunicorn with specified workers and threads. ```bash gunicorn myapp.wsgi -c gunicorn.config.py --workers 2 --threads 2 ``` -------------------------------- ### Run Checkly Init Command Source: https://github.com/checkly/docs/blob/main/cli/checkly-init.mdx Execute the `checkly init` command to start the setup process. This command can be run with various options to customize the initialization. ```bash npx checkly init [options] ``` -------------------------------- ### Checkly CLI Get Examples Source: https://github.com/checkly/docs/blob/main/cli/checkly-checks.mdx Examples demonstrating common uses of the `checkly checks get` command, including viewing basic details, filtering by time range, and grouping statistics. ```bash # View check details, recent results, and stats npx checkly checks get 12345 ``` ```bash # View stats for the last 7 days npx checkly checks get 12345 --stats-range=last7Days ``` ```bash # Break down stats by location npx checkly checks get 12345 --group-by=location ``` -------------------------------- ### Manual Setup with beforeEach/afterEach Source: https://github.com/checkly/docs/blob/main/guides/developer-fixtures.mdx This snippet demonstrates a manual approach to running setup and teardown functions before and after each test using native JavaScript/TypeScript modules. This method requires repeating the setup in each test file. ```typescript import {setup, teardown } from "./standardScripts.ts" test.beforeEach(() => { setup(); }); //add tests here test.afterEach(() => { teardown(); }); ``` -------------------------------- ### Get command usage examples Source: https://github.com/checkly/docs/blob/main/cli/checkly-status-pages.mdx Common patterns for retrieving status page details. ```bash # View status page details with cards and services npx checkly status-pages get 12345 # Get status page details as JSON npx checkly status-pages get 12345 --output=json ``` -------------------------------- ### Initialize a New Checkly Project Source: https://github.com/checkly/docs/blob/main/cli/checkly-skills.mdx Use the `initialize` action to generate LLM-optimized Markdown for setting up a new Checkly project from scratch. This context guides an agent through installing packages, creating config files, and scanning for resources. ```bash npx checkly skills initialize ``` -------------------------------- ### Start Application Source: https://github.com/checkly/docs/blob/main/resolve/traces/instrumentation/laravel.mdx Start your application server. Interactions triggered by Checkly synthetic monitoring will now generate traces. ```bash php artisan serve ``` -------------------------------- ### Get Account Members as JSON Example Source: https://github.com/checkly/docs/blob/main/cli/checkly-account.mdx Example demonstrating how to retrieve account members data in JSON format for programmatic use. ```bash # Get results as JSON npx checkly account members --output=json ``` -------------------------------- ### Example package.json with dependencies Source: https://github.com/checkly/docs/blob/main/detect/synthetic-monitoring/playwright-checks/custom-dependencies.mdx This is an example package.json file showing how to include dependencies and devDependencies for a Playwright Check Suite. Checkly installs these dependencies automatically. ```json { "dependencies": { "axios": "^1.6.0" }, "devDependencies": { "@faker-js/faker": "^9.7.0", "@playwright/test": "^1.40.0" } } ``` -------------------------------- ### Request Chaining Example in JavaScript Source: https://github.com/checkly/docs/blob/main/detect/synthetic-monitoring/api-checks/api-structure.mdx Illustrates request chaining by creating a user in a setup script and using the created user's ID in a subsequent request. Environment variables are used to store and retrieve dynamic data. ```javascript // Setup script - create test user const userResponse = await fetch('https://api.example.com/users', { method: 'POST', body: JSON.stringify({ name: 'Test User', email: `test+${Date.now()}@example.com` }) }) const userData = await userResponse.json() process.env.TEST_USER_ID = userData.id // Main request uses created user ID // URL: https://api.example.com/users/{{TEST_USER_ID}}/profile ``` -------------------------------- ### List Account Members and Pending Invites Example Source: https://github.com/checkly/docs/blob/main/cli/checkly-account.mdx A basic example to list all account members and pending invites. ```bash # List account members and pending invites npx checkly account members ``` -------------------------------- ### Install Checkly CLI Source: https://github.com/checkly/docs/blob/main/quickstarts/playwright-check.mdx Install the Checkly CLI for managing your monitoring configurations. If using TypeScript, also install `jiti` for proper bundling. ```bash npm install --save-dev checkly ``` ```bash npm install --save-dev jiti ``` -------------------------------- ### Install OpenTelemetry SDK for Go Source: https://github.com/checkly/docs/blob/main/resolve/traces/instrumentation/golang.mdx Installs the necessary OpenTelemetry packages for Go. Ensure you have Go installed and configured. ```bash go get "go.opentelemetry.io/otel" \ "go.opentelemetry.io/otel/propagation" \ "go.opentelemetry.io/otel/sdk/trace" \ "go.opentelemetry.io/otel/exporters/otlp/otlptrace" \ "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp" \ "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" ``` -------------------------------- ### Search Account Members Example Source: https://github.com/checkly/docs/blob/main/cli/checkly-account.mdx Example demonstrating how to search for members by name or email. ```bash # Search by name or email npx checkly account members --search="alex" ``` -------------------------------- ### Install Pulumi CLI using npm Source: https://github.com/checkly/docs/blob/main/integrations/iac/pulumi/setup.mdx Install the Pulumi CLI globally using npm. Ensure Node.js is installed and in your PATH. ```bash npm install -g @pulumi/pulumi ``` -------------------------------- ### Checkly Test Sessions Examples Source: https://github.com/checkly/docs/blob/main/cli/checkly-test-sessions.mdx Common examples for viewing and inspecting test sessions using the Checkly CLI. ```bash # View a recorded test session npx checkly test-sessions get ``` ```bash # Wait for a running test session to complete npx checkly test-sessions get --watch ``` ```bash # Inspect a test session error group npx checkly test-sessions get --error-group= ``` ```bash # Get the session as JSON npx checkly test-sessions get --output=json ``` -------------------------------- ### Monitor Frequency Examples Source: https://github.com/checkly/docs/blob/main/constructs/url-monitor.mdx Examples demonstrating different frequency settings for critical, standard, and background service monitoring. ```typescript // Critical service monitoring new UrlMonitor("critical-service", { name: "Critical Service Uptime", frequency: Frequency.EVERY_30S, // Every 30 seconds maxResponseTime: 2000 }) ``` ```typescript // Regular website monitoring new UrlMonitor("website-monitor", { name: "Website Availability", frequency: Frequency.EVERY_5M, // Every 5 minutes maxResponseTime: 5000 }) ``` ```typescript // Background service monitoring new UrlMonitor("background-service", { name: "Background Service Health", frequency: Frequency.EVERY_30M, // Every 30 minutes maxResponseTime: 10000 }) ``` -------------------------------- ### GitHub Actions Workflow for Checkly Deployment Source: https://github.com/checkly/docs/blob/main/detect/uptime-monitoring/cli-configuration.mdx An example GitHub Actions workflow to automate the testing and deployment of Checkly monitors on push events to the main branch. It includes setup for Node.js, dependency installation, and environment variable configuration for API key and account ID. ```yaml name: Deploy Checkly Monitors on: push: branches: [main] paths: ['monitoring/**'] jobs: deploy-monitoring: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup Node.js uses: actions/setup-node@v3 with: node-version: '18' cache: 'npm' - name: Install dependencies run: npm ci - name: Test monitors run: npx checkly test env: CHECKLY_API_KEY: ${{ secrets.CHECKLY_API_KEY }} CHECKLY_ACCOUNT_ID: ${{ vars.CHECKLY_ACCOUNT_ID }} - name: Deploy monitors run: npx checkly deploy env: CHECKLY_API_KEY: ${{ secrets.CHECKLY_API_KEY }} CHECKLY_ACCOUNT_ID: ${{ vars.CHECKLY_ACCOUNT_ID }} ENVIRONMENT: production BASE_URL: https://api.myapp.com ``` -------------------------------- ### Setup Script Configuration Source: https://github.com/checkly/docs/blob/main/constructs/api-check.mdx Demonstrates how to use setup scripts, either by referencing a file or providing inline code, to prepare test data or authentication before an API check. ```APIDOC ## Setup Script Configuration ### Description Configures a script to run before an API Check execution, useful for setting up test data or authentication tokens. ### Parameters #### Request Body - **entrypoint** (string) - Optional - Path to a `.js` or `.ts` file containing the setup script. - **content** (string) - Optional - Inline JavaScript/TypeScript code as a string. You must provide either `entrypoint` or `content`, but not both. ### Usage Examples #### File Reference ```ts new ApiCheck("api-with-setup", { name: "API with Setup Script", setupScript: { entrypoint: path.join(__dirname, "scripts/api-setup.ts"), }, request: { method: "GET", url: "https://api.example.com/users", }, }) ``` #### Inline Script ```ts new ApiCheck('inline-setup', { name: 'API with Inline Setup', setupScript: { content: ` const token = await getToken() request.headers['Authorization'] = \`Bearer \${token}\` ` }, request: { url: 'https://api.example.com/users' } }) ``` ``` -------------------------------- ### Initialize a Checkly project Source: https://github.com/checkly/docs/blob/main/cli/overview.mdx Run this command to start a new project and follow the interactive prompts to set up your configuration. ```bash npx checkly init ``` -------------------------------- ### Basic DNS Monitor Example Source: https://github.com/checkly/docs/blob/main/constructs/dns-monitor.mdx A basic example demonstrating how to set up a DNS monitor to check if an A record for `example.com` resolves to a specific IP address. ```APIDOC ## POST /api/dns-monitors ### Description Creates a new DNS monitor to verify DNS record resolution. ### Method POST ### Endpoint /api/dns-monitors ### Parameters #### Request Body - **name** (string) - Required - The name of the monitor. - **description** (string) - Optional - A description for the monitor. - **activated** (boolean) - Optional - Whether the monitor is active. - **maxResponseTime** (number) - Optional - Maximum response time in milliseconds before marking as failed. - **degradedResponseTime** (number) - Optional - Response time threshold in milliseconds for degraded status. - **frequency** (Frequency) - Required - The frequency to run the monitor. - **locations** (string[]) - Required - The locations to run the monitor from. - **request** (object) - Required - DNS request configuration. - **query** (string) - Required - The DNS query (domain name or IP address). - **recordType** (DnsRecordType) - Required - DNS record type: A, AAAA, CNAME, MX, NS, TXT, SOA. - **nameServer** (string) - Optional - Custom DNS server to query. - **port** (number) - Optional - Port of the DNS server. - **protocol** (DnsProtocol) - Optional - Protocol to use: UDP or TCP. - **assertions** (DnsAssertion[]) - Optional - Response assertions. ### Request Example ```json { "name": "DNS A Record Monitor", "description": "Asserts `example.com` A record resolves to the **expected IP**.", "activated": true, "maxResponseTime": 1000, "degradedResponseTime": 500, "frequency": "EVERY_5M", "locations": ["us-east-1", "eu-central-1"], "request": { "query": "example.com", "recordType": "A", "assertions": [ { "type": "jsonAnswer", "path": "$.Answer[0].data", "comparison": "equals", "value": "93.184.216.34" } ] } } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the created DNS monitor. - **name** (string) - The name of the monitor. - **status** (string) - The current status of the monitor. #### Response Example ```json { "id": "monitor-123", "name": "DNS A Record Monitor", "status": "HEALTHY" } ``` ``` -------------------------------- ### Slack Integration Setup Example Source: https://github.com/checkly/docs/blob/main/detect/uptime-monitoring/alerting.mdx Example configuration for Slack alerts, specifying the channel and message format including monitor status, error details, and quick action buttons. ```yaml Channel: "#monitoring-alerts" Message Format: - Monitor name and status - Error details and location - Response time and availability metrics - Quick action buttons ``` -------------------------------- ### Independent test sequence Source: https://github.com/checkly/docs/blob/main/learn/playwright/writing-tests.mdx An example of tests refactored to be independent by encapsulating setup requirements within each test. ```text test1: - creates user1 - asserts user1 has been created test2: - (setup: creates user1) - logs in with user1 - asserts user1 has logged in successfully test3: - (setup: creates user1) - (setup: logs in with user1) - goes through checkout as user1 - asserts that checkout for user1 was successful ``` -------------------------------- ### Initialize Pulumi CLI Source: https://github.com/checkly/docs/blob/main/integrations/iac/pulumi/overview.mdx Verify the Pulumi CLI installation and begin a new project. ```bash $ pulumi ``` ```bash $ pulumi new ``` -------------------------------- ### API Check with Setup Script (File Reference) Source: https://github.com/checkly/docs/blob/main/constructs/api-check.mdx Use a file-based setup script to prepare test data or authentication before an API Check runs. Ensure the script is a valid .js or .ts file. ```typescript new ApiCheck("api-with-setup", { name: "API with Setup Script", setupScript: { entrypoint: path.join(__dirname, "scripts/api-setup.ts"), }, request: { method: "GET", url: "https://api.example.com/users", }, }) ``` -------------------------------- ### Instrument Laravel Code for Tracing Source: https://github.com/checkly/docs/blob/main/redirects.md Example of instrumenting Laravel code using OpenTelemetry. This requires specific package installations and configuration. ```php use OpenTelemetry\Api\Trace\TracerInterface; // ... inside a controller or service $tracer = app(TracerInterface::class); $span = $tracer->span('my_operation'); $span->start(); try { // ... your code } finally { $span->end(); } ``` -------------------------------- ### Implement authentication setup in auth.setup.ts Source: https://github.com/checkly/docs/blob/main/learn/playwright/authentication.mdx Perform the login flow and save the resulting cookies and local storage to a JSON file for reuse. ```ts import { test as setup, expect } from '@playwright/test' import path from 'path' const authFile = path.join(__dirname, '../playwright/.auth/user.json') setup('authenticate', async ({ page }) => { await page.goto('https://danube-web.shop/') await page.getByRole('button', { name: 'Log in' }).click() await page.getByPlaceholder('Email').fill(process.env.USER_EMAIL as string) await page.getByPlaceholder('Password').fill(process.env.USER_PASSWORD as string) await page.getByRole('button', { name: 'Sign In' }).click() await expect(page.locator('#login-message')) .toContainText(`Welcome back, ${process.env.USER_EMAIL as string}`) await page.context().storageState({ path: authFile }) }); ``` -------------------------------- ### Basic Agentic Check Example Source: https://github.com/checkly/docs/blob/main/constructs/agentic-check.mdx Configure a basic Agentic Check to monitor a website's loading status. Ensure 'checkly/constructs' is installed. ```typescript import { AgenticCheck, Frequency } from 'checkly/constructs' new AgenticCheck('homepage-health', { name: 'Homepage Health Check', prompt: 'Navigate to https://example.com and verify the page loads correctly.', activated: true, frequency: Frequency.EVERY_1H, }) ``` -------------------------------- ### Setup Script for Authentication Header Source: https://github.com/checkly/docs/blob/main/detect/synthetic-monitoring/api-checks/setup-and-teardown.mdx This setup script imports an authentication client, retrieves a token, and sets it as the 'Authorization' header for the request. It assumes the token retrieval logic is in a separate module. ```typescript import { getToken } from './common/auth-client' const token = await getToken() request.headers['Authorization'] = `Bearer ${token}` ``` -------------------------------- ### Define Playwright Check Suite in checkly.config.ts Source: https://github.com/checkly/docs/blob/main/detect/synthetic-monitoring/playwright-checks/configuration.mdx Configure Playwright Check Suites by specifying the Playwright config path and adding a `playwrightChecks` property to your `checkly.config.ts/js` file. This example shows a basic setup for a suite named 'all-pwt-tests'. ```typescript import { defineConfig } from 'checkly' import { Frequency } from 'checkly/constructs' export default defineConfig({ // ... checks: { playwrightConfigPath: './playwright.config.ts', playwrightChecks: [ { name: 'all-pwt-tests', logicalId: 'all-tests', } ], }, }) ``` -------------------------------- ### Verify Project Files Source: https://github.com/checkly/docs/blob/main/integrations/iac/pulumi/overview.mdx List files in the directory to ensure the project was initialized correctly. ```bash $ ls ``` -------------------------------- ### Start Rails Server Source: https://github.com/checkly/docs/blob/main/resolve/traces/instrumentation/ruby-on-rails.mdx Launch the Rails application with the configured instrumentation. ```bash rails server ``` -------------------------------- ### Define Emergency One-Time Maintenance Window Source: https://github.com/checkly/docs/blob/main/constructs/maintenance-window.mdx Create a one-time maintenance window for immediate needs like emergency security patches. This example sets the window to start in one hour and end in four hours from the current time. ```typescript // For immediate one-time maintenance const now = new Date() const inOneHour = new Date(now.getTime() + 60 * 60 * 1000) const inFourHours = new Date(now.getTime() + 4 * 60 * 60 * 1000) new MaintenanceWindow("emergency-fix", { name: "Emergency Security Patch", tags: ["security", "critical"], startsAt: inOneHour, // Start in 1 hour endsAt: inFourHours, // End in 4 hours (no repeat) }) ``` -------------------------------- ### Setup Script Error Handling Source: https://github.com/checkly/docs/blob/main/detect/synthetic-monitoring/api-checks/setup-and-teardown.mdx Demonstrates error handling in a setup script. If a critical environment variable like 'API_KEY' is missing, an error is thrown, which will abort the entire check. ```typescript // This error will abort the check if (!process.env.API_KEY) { throw new Error('API_KEY environment variable is required') } ``` -------------------------------- ### Download File using HTTP Request in Playwright Source: https://github.com/checkly/docs/blob/main/learn/playwright/file-download.mdx Use this method to download files by extracting the href attribute and making an HTTP GET request. Ensure you have axios and fs modules installed. This approach is useful when you need programmatic control over the download process. ```typescript // Example code for file download using HTTP request import { test, expect } from '@playwright/test'; import axios from 'axios'; import fs from 'fs'; test('download file with HTTP request', async ({ page }) => { // Login to the website await page.goto('https://danube-web.shop/login'); await page.fill('#email', process.env.USER_EMAIL!); await page.fill('#password', process.env.USER_PASSWORD!); await page.click('#login-button'); // Navigate to account page await page.goto('https://danube-web.shop/account'); // Extract download link const downloadLink = await page.getAttribute('a[href*="receipt"]', 'href'); // Download file using HTTP request const response = await axios.get(downloadLink, { responseType: 'stream' }); const downloadPath = './downloaded-receipt.pdf'; const writer = fs.createWriteStream(downloadPath); response.data.pipe(writer); await new Promise((resolve, reject) => { writer.on('finish', resolve); writer.on('error', reject); }); // Compare with fixture file const downloadedFile = fs.readFileSync(downloadPath); const fixtureFile = fs.readFileSync('./fixtures/expected-receipt.pdf'); expect(downloadedFile).toEqual(fixtureFile); }); ``` -------------------------------- ### Configure list command options Source: https://github.com/checkly/docs/blob/main/cli/checkly-status-pages.mdx Examples for filtering and formatting the list output. ```bash npx checkly status-pages list --limit=50 npx checkly status-pages list -l 10 ``` ```bash npx checkly status-pages list --cursor= ``` ```bash npx checkly status-pages list --compact ``` ```bash npx checkly status-pages list --output=json npx checkly status-pages list -o md ``` -------------------------------- ### List Available Runtimes Source: https://github.com/checkly/docs/blob/main/cli/checkly-runtimes.mdx Use this command to see all available runtime environments and their dependency versions. The output provides details on the runtime name, description, stage, and a list of installed packages with their versions. ```bash npx checkly runtimes ``` -------------------------------- ### Setup and Teardown for Todo API with Playwright Hooks Source: https://github.com/checkly/docs/blob/main/detect/synthetic-monitoring/multistep-checks/examples.mdx This example demonstrates using `beforeAll` and `afterAll` hooks to manage test data for a Todo API. It ensures no pre-existing data interferes with the test and cleans up created data afterward. Requires a CRUD API key. ```typescript import { test, expect } from "@playwright/test" const baseUrl = "https://crudapi.co.uk/api/v1/todo" const headers = { Authorization: `Bearer ${process.env.CRUD_API_KEY}`, "Content-Type": "application/json", } /** * Share state between hooks and test.steps */ let createdResources = null /** * Use `beforeAll` as a setup script * to make sure no todo's exist. */ test.beforeAll(async ({ request }) => { const response = await request.get(baseUrl, { headers }) const { items } = await response.json() expect(items.length).toEqual(0) }) /** * Use `afterAll` as a teardown script * to remove the created todo before the check ends */ test.afterAll(async ({ request }) => { if (createdResources) { const response = await request.delete(baseUrl, { headers, data: createdResources, }) expect(response).toBeOK() } }) test("Todo List", async ({ request }) => { await test.step("Create a Todo", async () => { const response = await request.post(baseUrl, { headers, data: [ { title: "Testing Checkly Multistep checks", done: true, }, ], }) expect(response).toBeOK() const { items } = await response.json() createdResources = items }) }) ``` -------------------------------- ### Initialize Pulumi Project Source: https://github.com/checkly/docs/blob/main/integrations/iac/pulumi/overview.mdx Create a new Pulumi project using the JavaScript template. ```bash $ pulumi new javascript ``` -------------------------------- ### Install Pulumi CLI using curl Source: https://github.com/checkly/docs/blob/main/integrations/iac/pulumi/setup.mdx Install the Pulumi CLI by downloading and executing the official installation script. ```bash curl -fsSL https://get.pulumi.com | sh ``` -------------------------------- ### Install Pulumi CLI using Yarn Source: https://github.com/checkly/docs/blob/main/integrations/iac/pulumi/setup.mdx Install the Pulumi CLI globally using Yarn. Ensure Yarn is installed and in your PATH. ```bash yarn global add @pulumi/pulumi ``` -------------------------------- ### Initialize Terraform Project Source: https://github.com/checkly/docs/blob/main/integrations/iac/terraform/overview.mdx Initializes your Terraform project, downloading the Checkly provider and setting up the backend. ```bash terraform init ``` -------------------------------- ### Specify configuration file for import Source: https://github.com/checkly/docs/blob/main/cli/checkly-import.mdx Use a custom configuration file instead of the default. ```bash npx checkly import --config= npx checkly import -c= ``` ```bash $ npx checkly import --config="./checkly.staging.config.ts" ``` -------------------------------- ### Basic DNS Monitor Example Source: https://github.com/checkly/docs/blob/main/constructs/dns-monitor.mdx Configures a basic DNS monitor to check if the A record for `example.com` resolves to a specific IP address. Ensure you have the Checkly CLI project initialized and the domain to monitor. ```typescript import { Frequency, DnsAssertionBuilder, DnsMonitor } from "checkly/constructs" new DnsMonitor("dns-monitor", { name: "DNS A Record Monitor", description: "Asserts `example.com` A record resolves to the **expected IP**.", activated: true, maxResponseTime: 1000, degradedResponseTime: 500, frequency: Frequency.EVERY_5M, locations: ["us-east-1", "eu-central-1"], request: { query: "example.com", recordType: "A", assertions: [ DnsAssertionBuilder.jsonAnswer("$.Answer[0].data").equals("93.184.216.34") ], }, }) ``` -------------------------------- ### Override Dependency Install Command with pw-test Source: https://github.com/checkly/docs/blob/main/cli/checkly-pw-test.mdx Customize the dependency installation command using --install-command, overriding the default 'npm install --dev'. ```bash npx checkly pw-test --install-command='npm install --no-scripts' ``` ```bash npx checkly pw-test --install-command='pnpm install --frozen-lockfile' ``` -------------------------------- ### Deployment Confirmation Prompt Source: https://github.com/checkly/docs/blob/main/quickstarts/playwright-check.mdx This is an example of the confirmation prompt you will see when deploying your project. Type 'yes' to proceed. ```bash > You are about to deploy your project "my-app-monitoring" to account "My Account". Do you want to continue? … yes Successfully deployed project "my-app-monitoring" to account "My Account". ``` -------------------------------- ### Customizing Dependency Installation Command Source: https://github.com/checkly/docs/blob/main/detect/synthetic-monitoring/playwright-checks/timeouts.mdx Use `installCommand` in your check suite configuration to specify a custom dependency installation command. This can help prevent timeouts during installation by skipping certain scripts. ```yaml installCommand: 'npm install --ignore-scripts' ``` -------------------------------- ### Initialize Project with Checkly CLI Source: https://github.com/checkly/docs/blob/main/guides/monitoring-ecommerce-apps-using-playwright.mdx Bootsrap a new project with the Checkly CLI by running this command in your terminal. ```bash mkdir checkly-mac-cli-example && cd $_ ``` -------------------------------- ### Deploy Checkly Monitors with Environment Variables Source: https://github.com/checkly/docs/blob/main/detect/uptime-monitoring/cli-configuration.mdx Deploy monitors to Checkly using the CLI. Examples show deploying all monitors, deploying with specific environment variables, testing before deploying, and previewing changes. ```bash # Deploy all monitors npx checkly deploy # Deploy with environment variables ENVIRONMENT=production BASE_URL=https://api.myapp.com npx checkly deploy # Test before deploying npx checkly test # Preview changes npx checkly deploy --preview ``` -------------------------------- ### API Check with Setup Script Configuration Source: https://github.com/checkly/docs/blob/main/detect/synthetic-monitoring/api-checks/setup-and-teardown.mdx Defines an API check that utilizes a separate setup script for pre-request logic, such as authentication. The `entrypoint` property specifies the path to the setup script. ```typescript import { ApiCheck } from '@checkly/cli/constructs' import * as path from 'path' new ApiCheck('api-check-1', { name: 'Fetch Product Data', setupScript: { entrypoint: path.join(__dirname, 'setup.ts'), }, request: { method: 'GET', url: 'https://api.acme.com/v1/products' } }) ``` -------------------------------- ### Example package.json for private package Source: https://github.com/checkly/docs/blob/main/detect/synthetic-monitoring/playwright-checks/custom-dependencies.mdx This example demonstrates how to declare a private package as a devDependency in your package.json. Ensure your registry is configured correctly for authentication. ```json { "devDependencies": { "@your-org/private-package": "^2.3.0" } } ``` -------------------------------- ### Install Claude Code Source: https://github.com/checkly/docs/blob/main/guides/claude-code-monitoring.mdx Installs the Claude Code CLI tool globally. ```bash npm install -g @anthropic-ai/claude-code ``` -------------------------------- ### Setup OpenTelemetry SDK in Go Source: https://github.com/checkly/docs/blob/main/resolve/traces/instrumentation/golang.mdx Sets up the OpenTelemetry SDK for Go, including configuring the propagator and tracer provider. This file should be placed at the root of your project. ```go package main import ( "context" "errors" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/exporters/otlp/otlptrace" "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp" "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/sdk/trace" ) func setupOTelSDK(ctx context.Context) (shutdown func(context.Context) error, err error) { var shutdownFuncs []func(context.Context) error shutdown = func(ctx context.Context) error { var err error for _, fn := range shutdownFuncs { err = errors.Join(err, fn(ctx)) } shutdownFuncs = nil return err } handleErr := func(inErr error) { err = errors.Join(inErr, shutdown(ctx)) } prop := newPropagator() otel.SetTextMapPropagator(prop) racerProvider, err := newTraceProvider() if err != nil { handleErr(err) return } shutdownFuncs = append(shutdownFuncs, tracerProvider.Shutdown) otel.SetTracerProvider(tracerProvider) return } func newPropagator() propagation.TextMapPropagator { return propagation.NewCompositeTextMapPropagator( propagation.TraceContext{}, propagation.Baggage{}, ) } func newTraceProvider() (*trace.TracerProvider, error) { traceClient := otlptracehttp.NewClient() var traceExporter, err = otlptrace.New(context.Background(), traceClient) if err != nil { return nil, err } bsp := trace.NewBatchSpanProcessor(traceExporter) racerProvider := trace.NewTracerProvider( trace.WithSampler(trace.AlwaysSample()), trace.WithSpanProcessor(bsp), ) return tracerProvider, nil } ``` -------------------------------- ### Install Checkly CLI Source: https://github.com/checkly/docs/blob/main/cli/installation.mdx Install the Checkly CLI as a development dependency in your project. ```bash npm i --save-dev checkly ``` -------------------------------- ### Show Pending Invites Example Source: https://github.com/checkly/docs/blob/main/cli/checkly-account.mdx Example to filter and display only pending invitations. ```bash # Show pending invites npx checkly account members --type=invite --status=pending ``` -------------------------------- ### Import resources with CLI Source: https://github.com/checkly/docs/blob/main/cli/checkly-import.mdx Basic command to initiate the import process for resources. ```bash npx checkly import [resources] [options] ``` -------------------------------- ### Run Go Application Source: https://github.com/checkly/docs/blob/main/resolve/traces/instrumentation/golang.mdx Execute the application after configuring the required environment variables. ```bash go run . ``` -------------------------------- ### Install TypeScript dependencies Source: https://github.com/checkly/docs/blob/main/cli/installation.mdx Install the necessary dependencies to support TypeScript configuration files. ```bash npm i --save-dev ts-node typescript ``` -------------------------------- ### Find Account Admins Example Source: https://github.com/checkly/docs/blob/main/cli/checkly-account.mdx Example to filter and display only members with the 'admin' role. ```bash # Find account admins npx checkly account members --role=admin ``` -------------------------------- ### Run application with instrumentation Source: https://github.com/checkly/docs/blob/main/resolve/traces/instrumentation/nodejs.mdx Start the Node.js application using the -r flag to preload the tracing configuration. ```bash node -r ./tracing.js index.js ```