Skip to content

Open-source status page, incident response and uptime monitoring

10.9 KB
Raw Blame
import {
  Download,
  FileJson,
  ApiKey as KeyIcon,
  Login,
  Report,
  StatusPage,
  Terminal,
} from "@openstatus/icons";
import {
  Tabs,
  TabsContent,
  TabsList,
  TabsTrigger,
} from "@openstatus/ui/components/ui/tabs";
import React from "react";

import { Code } from "@/components/common/code";
import { Link } from "@/components/common/link";
import {
  Section,
  SectionDescription,
  SectionGroup,
  SectionHeader,
  SectionTitle,
} from "@/components/content/section";

const OS = ["macOS", "Windows", "Linux"] as const;

const installs = [
  {
    title: "Install CLI",
    icon: Terminal,
    description:
      "Install the OpenStatus CLI to set up your monitors straight in your code.",
    command: {
      macOS: [
        "brew install openstatusHQ/cli/openstatus --cask",
        "curl -fsSL https://raw.githubusercontent.com/openstatusHQ/cli/refs/heads/main/install.sh | bash",
      ],
      Linux: [
        "curl -fsSL https://raw.githubusercontent.com/openstatusHQ/cli/refs/heads/main/install.sh | bash",
      ],
      Windows: [
        "iwr https://raw.githubusercontent.com/openstatusHQ/cli/refs/heads/main/install.ps1| iex",
      ],
    },
  },
  {
    title: "Login",
    icon: Login,
    description: "Save your API token for use in subsequent commands.",
    command: "openstatus login",
  },
  {
    title: "Add API Key",
    icon: KeyIcon,
    description: (
      <>
        Or set it as an environment variable. Create an API key in your
        workspace <Link href="/settings/general">settings.</Link>
      </>
    ),
    command: {
      macOS: ["export OPENSTATUS_API_TOKEN=<your-api-token>"],
      Windows: ['$env:OPENSTATUS_API_TOKEN = "<your-api-token>"'],
      Linux: ["export OPENSTATUS_API_TOKEN=<your-api-token>"],
    },
  },
  {
    title: "List Status Pages",
    icon: StatusPage,
    description: "List all status pages in your workspace.",
    command: "openstatus status-page list",
  },
  {
    title: "List Status Reports",
    icon: Report,
    description: "List all status reports in your workspace.",
    command: "openstatus status-report list",
  },
  {
    title: "Import Monitors",
    icon: Download,
    description: "Import monitors from your workspace to a YAML file.",
    command: "openstatus monitors import",
  },
  {
    title: "Manage Monitors",
    icon: FileJson,
    description:
      "Add, remove, or update monitors from a YAML file and apply your changes.",
    command: "openstatus monitors apply",
  },
] satisfies {
  title: string;
  icon: React.ElementType;
  description: React.ReactNode;
  command: string | Record<(typeof OS)[number], string[]>;
}[];

const commands = [
  {
    command: "openstatus monitors list [options]",
    description: "List all monitors in your workspace.",
  },
  {
    command: "openstatus monitors info [monitor-id] [options]",
    description: "Get information about a specific monitor.",
  },
  {
    command: "openstatus monitors trigger [monitor-id] [options]",
    description: "Trigger a monitor.",
  },
  {
    command: "openstatus status-page list [options]",
    description: "List all status pages.",
  },
  {
    command: "openstatus status-page info [page-id]",
    description: "Get status page details.",
  },
  {
    command:
      'openstatus status-report create --title "..." --status investigating --message "..." --page-id 123',
    description: "Create a status report.",
  },
  {
    command:
      'openstatus status-report add-update [report-id] --status resolved --message "..."',
    description: "Add an update to a status report.",
  },
  {
    command: "openstatus status-report list [options]",
    description: "List all status reports.",
  },
];

const templates = [
  {
    description: "MCP server",
    template: `# yaml-language-server: $schema=https://www.openstatus.dev/schema.json

mcp-server:
  name: "HF MCP Server"
  description: "Hugging Face MCP server monitoring"
  frequency: "1m"
  active: true
  regions: ["iad", "ams", "lax"]
  retry: 3
  kind: http
  request:
    url: https://hf.co/mcp
    method: POST
    body: >
      {
        "jsonrpc": "2.0",
        "id": "openstatus",
        "method": "ping"
      }
    headers:
      User-Agent: OpenStatus
      Accept: application/json, text/event-stream
      Content-Type: application/json
  assertions:
    - kind: statusCode
      compare: eq
      target: 200
    - kind: textBody
      compare: eq
      target: '{"result":{},"jsonrpc":"2.0","id":"openstatus"}'
`,
  },
];

const githubActions = [
  {
    description: "Run synthetic tests",
    template: `name: OpenStatus
on: [push]

jobs:
  run-synthetic-tests:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: OpenStatus GitHub Action
        uses: openstatusHQ/openstatus-github-action@v1
        with:
          api_key: \${{ secrets.OPENSTATUS_API_KEY }}`,
  },
  {
    description: "Apply monitors configuration",
    template: `name: OpenStatus
on: [push]

jobs:
  apply-monitors:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: OpenStatus CLI Action
        uses: openstatusHQ/cli-action@v1
        with:
          args: monitors apply
        env:
          OPENSTATUS_API_TOKEN: \${{ secrets.OPENSTATUS_API_TOKEN }}`,
  },
];

export default function Page() {
  return (
    <SectionGroup>
      <Section>
        <SectionHeader>
          <SectionTitle>CLI</SectionTitle>
          <SectionDescription>
            Get started with the CLI to export and manage your monitors in your
            code.{" "}
            <Link
              href="https://www.openstatus.dev/docs/reference/cli-reference/"
              target="_blank"
              rel="noopener noreferrer"
            >
              Read more
            </Link>
            .
          </SectionDescription>
        </SectionHeader>
        <Tabs defaultValue={OS[0]} className="flex flex-col gap-3">
          <TabsList>
            {OS.map((os) => (
              <TabsTrigger key={os} value={os}>
                {os}
              </TabsTrigger>
            ))}
          </TabsList>
          {OS.map((os) => (
            <TabsContent key={os} value={os} className="flex flex-col gap-6">
              {installs.map((step, i) => {
                const commands =
                  typeof step.command === "string"
                    ? step.command
                    : step.command[os];
                return (
                  <div key={i} className="flex flex-col gap-3">
                    <div className="flex flex-col gap-1">
                      <p className="flex items-center gap-2 text-sm font-medium">
                        <step.icon className="size-4" />
                        {step.title}
                      </p>
                      <p className="text-muted-foreground text-sm">
                        {step.description}
                      </p>
                    </div>
                    {typeof commands === "string" ? (
                      <Code>{commands}</Code>
                    ) : (
                      <>
                        {commands.map((command, i) => (
                          <React.Fragment key={command}>
                            <Code>{command}</Code>
                            {i < commands.length - 1 && (
                              <span className="text-muted-foreground">or</span>
                            )}
                          </React.Fragment>
                        ))}
                      </>
                    )}
                  </div>
                );
              })}
            </TabsContent>
          ))}
        </Tabs>
      </Section>
      <Section>
        <SectionHeader>
          <SectionTitle>Commands</SectionTitle>
          <SectionDescription>
            We have a few more commands to run. Check the{" "}
            <Link
              href="https://www.openstatus.dev/docs/reference/cli-reference/"
              target="_blank"
              rel="noopener noreferrer"
            >
              documentation
            </Link>{" "}
            to read more.
          </SectionDescription>
        </SectionHeader>
        <ul className="flex flex-col gap-2">
          {commands.map((command, i) => (
            <li key={i} className="flex flex-col gap-0.5">
              <p className="text-muted-foreground text-xs">
                {command.description}
              </p>
              <Code>{command.command}</Code>
            </li>
          ))}
        </ul>
      </Section>
      <Section>
        <SectionHeader>
          <SectionTitle>Skills</SectionTitle>
          <SectionDescription>
            Add the openstatus skill to let AI agents manage your monitors,
            status pages, and status reports on your behalf.
          </SectionDescription>
        </SectionHeader>
        <Code>npx skills add openstatushq/cli</Code>
      </Section>
      <Section>
        <SectionHeader>
          <SectionTitle>GitHub Action</SectionTitle>
          <SectionDescription>
            We provide you with a github action in case you'd like to use the
            CLI within your CI/CD workflows. Check the{" "}
            <Link
              href="https://github.com/openstatusHQ/openstatus-github-action"
              target="_blank"
              rel="noopener noreferrer"
            >
              GitHub integration
            </Link>{" "}
            page or our{" "}
            <Link
              href="https://www.openstatus.dev/docs/guides/how-to-run-synthetic-test-github-action/"
              target="_blank"
              rel="noopener noreferrer"
            >
              guide
            </Link>{" "}
            to run synthetic tests in a GitHub action.
          </SectionDescription>
        </SectionHeader>
        <div className="flex flex-col gap-6">
          {githubActions.map((action, i) => (
            <div key={i} className="flex flex-col gap-0.5">
              <p className="text-muted-foreground text-xs">
                {action.description}
              </p>
              <Code>{action.template}</Code>
            </div>
          ))}
        </div>
      </Section>
      <Section>
        <SectionHeader>
          <SectionTitle>Templates</SectionTitle>
          <SectionDescription>
            We have a few templates to help you get started. Check the{" "}
            <Link
              href="https://github.com/openstatusHQ/cli-template"
              target="_blank"
              rel="noopener noreferrer"
            >
              <code>@openstatusHQ/cli-template</code>
            </Link>{" "}
            repository for more.
          </SectionDescription>
        </SectionHeader>
        <div className="flex flex-col gap-6">
          {templates.map((template, i) => (
            <div key={i} className="flex flex-col gap-0.5">
              <p className="text-muted-foreground text-xs">
                {template.description}
              </p>
              <Code>{template.template}</Code>
            </div>
          ))}
        </div>
      </Section>
    </SectionGroup>
  );
}