Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions cli/attaching-git-metadata.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: 'Attaching Git metadata'
sidebarTitle: 'Attaching Git metadata'
---

import CliEnvVars from "/snippets/cli-env-vars.mdx"

The CLI can attach git metadata like `branch`, `commit sha`, `owner` and more when executing the `test --record` and `deploy` commands. This way you can keep track of
your test sessions and deployed resources in the UI and cross-reference them with any updates to your code.

For example, in the screenshot below we ran a **test session** from our CI server after the project was deployed to our
Staging environment with the `npx checkly test --record` command.

![test session with git info](/images/docs/images/cli/test_session_git_data.png)

After the test succeeds, we **deploy** this check so it runs as a monitor with `npx checkly deploy`.

![browser check with git info](/images/docs/images/cli/browser_check_git_data.png)


## Environment variables

The CLI will attempt to auto-detect and parse git specific information from your local machine or CI environment, but you
can also set these data items specifically by using environment variables.

<CliEnvVars />

For example, if you want to specifically set the Environment you invoke:

```bash Terminal
CHECKLY_TEST_ENVIRONMENT=Production npx checkly test --record
```

Or, if you want to set repo URL you invoke:

```bash Terminal
CHECKLY_REPO_URL="https://my.git.solution/project/" npx checkly test --record
```
82 changes: 31 additions & 51 deletions cli/authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,52 @@ title: Authentication
description: 'How to authenticate with the Checkly CLI'
sidebarTitle: 'Authentication'
---
Before you can use the Checkly CLI, you need to authenticate with your Checkly account.
Before you can use the Checkly CLI, you need to authenticate with your Checkly account. There are different ways to authenticate depending on the environment where you are running the CLI from.

## Login
## Interactive

The primary way to authenticate is using the interactive login command:
When **running the CLI interactively** from your dev environment, just use the built-in `login` command. If you have multiple
Checkly accounts, it will prompt which account you want to target.

```bash Terminal
npx checkly login
```

This command will:
- Open your default browser to the Checkly authentication page
- Prompt you to log in to your Checkly account
- Generate an API key that the CLI will use for authentication
- Store the credentials securely on your local machine
Once authenticated, you can switch between accounts using:

## Log Out
```bash Terminal
npx checkly switch
```

To log out and clear your stored credentials:
... or quickly find out which account you are currently targeting with:

```bash Terminal
npx checkly logout
npx checkly whoami
```

This will remove the stored API key from your local machine.
To log out and clear your stored credentials:

## Other Authentication Options
```bash Terminal
npx checkly logout
```

### Environment Variables
## From CI

You can also authenticate using environment variables, which is useful for CI/CD pipelines and automated environments:
You can also authenticate using environment variables, which is useful for CI/CD pipelines and automated environments.

To get your API key:
You will need to export two environment variables in the shell:
- `CHECKLY_API_KEY`
- `CHECKLY_ACCOUNT_ID`

1. Log in to your Checkly dashboard
2. Navigate to **Account Settings** → **API Keys**
3. Create a new API key
4. Use the key in your environment variables or CLI configuration
To get your API key, go to your Settings page in Checkly and grab a API key from [the API keys tab](https://app.checklyhq.com/settings/user/api-keys) and your Account ID from the [Account settings tab](https://app.checklyhq.com/settings/account/general).

Set the account id and API key as follows:
Set the account ID and API key as follows:

```bash Terminal
# Set your Checkly API key
export CHECKLY_API_KEY=your_api_key_here

# Set your Checkly account ID (optional, CLI will detect automatically)
# Set your Checkly account ID
export CHECKLY_ACCOUNT_ID=your_account_id_here
```

Expand All @@ -60,36 +60,16 @@ npx checkly whoami

This will display your account information and confirm your authentication status.

## Multiple Accounts

If you work with multiple Checkly accounts, you can switch between them:

```bash Terminal
# Switch to a different account using interactive prompt
npx checkly switch

# Switch to a different account using the account id
npx checkly switch --account-id your_account_id

# View current account
npx checkly whoami
```

## Security Best Practices

- **Never commit API keys** to version control
- **Use environment variables** in production environments
- **Rotate API keys** regularly for security

## Troubleshooting

### Common Issues
<AccordionGroup>
<Accordion title="`npx checkly login` doesn't open a browser window">
If `npx checkly login` doesn't automatically open a browser window to authenticate, you can generate a direct link instead.

When prompted with:

**"Authentication failed" error:**
- Verify your API key is correct
- Check that your account ID is correct (if specified)
- Ensure your API key hasn't expired
> Do you want to open a browser window to continue with login? (Y/n)

**"Browser didn't open" error:**
- Decline to open the browser automatically and navigate to the authentication URL shown in the terminal
- Copy and paste the URL into your browser
Enter "n". The CLI will provide a link that you can copy and paste into your browser to authenticate.
</Accordion>
</AccordionGroup>
132 changes: 0 additions & 132 deletions cli/basic-workflow.mdx

This file was deleted.

10 changes: 2 additions & 8 deletions cli/checkly-deploy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ sidebarTitle: 'checkly deploy'
---

import CliCommandPrerequisites from '/snippets/cli-command-prerequisites.mdx';
import CliEnvVars from "/snippets/cli-env-vars.mdx"

The `checkly deploy` command deploys all your checks and associated resources like alert channels to your Checkly account. This command synchronizes your local monitoring-as-code configuration with your Checkly account.

Expand Down Expand Up @@ -175,14 +176,7 @@ When you deploy a project, you can attach Git-specific information so changes to

The Checkly CLI evaluates Git information from your local or CI environment on a best effort basis. Override any automatically detected values by setting the corresponding environment variables.

| item | auto | variable | description |
|--------------------|-------|--------------------------------------------------------|---------------------------------------------|
| **Repository** | false | `repoUrl` in `checkly.config.ts` or `CHECKLY_REPO_URL` | The URL of your repo on GitHub, GitLab etc. |
| **Commit hash** | true | `CHECKLY_REPO_SHA` | The SHA of the commit. |
| **Branch** | true | `CHECKLY_REPO_BRANCH` | The branch name. |
| **Commit owner** | true | `CHECKLY_REPO_COMMIT_OWNER` | The committer's name or email. |
| **Commit message** | true | `CHECKLY_REPO_COMMIT_MESSAGE` | The commit message. |
| **Environment** | false | `CHECKLY_TEST_ENVIRONMENT` | The environment name, e.g. "staging". |
<CliEnvVars />

## Related Commands

Expand Down
55 changes: 55 additions & 0 deletions cli/cli-vs-terraform-pulumi.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: CLI vs. Terraform & Pulumi
description: 'Comparing your options for Monitoring as Code'
sidebarTitle: 'CLI vs Terraform & Pulumi'
---

Creating, debugging and managing E2E and synthetic monitoring at scale is best done "as code". Currently, Checkly supports
three tools you can use for your **monitoring as code** (MaC) workflow:

1. The Checkly CLI.
2. Terraform (through our [Terraform provider](/integrations/iac/terraform/overview/))
3. Pulumi (through our [Pulumi provider](/integrations/iac/pulumi/overview/))

In most cases, the choice depends on what your goals are and how your organization is set up.

We believe the **Checkly CLI delivers the best-of-breed workflow**. However, there are always trade-offs. Let's list some
pros and cons based on our own experience and user feedback.

## Terraform vs. Checkly CLI

If you are a Terraform shop, you can use Checkly to its full capacity. The Checkly CLI adds core capabilities like TS/JS coding, simple Git integration and test execution.

**Pros**

`+` Terraform integrates very well with Checkly. We have a well maintained Terraform provider.

`+` Terraform is comfortable for many Devops engineers used to writing HCL scripts.

`+` Checkly can be configured almost completely through Terraform resources.

**Cons**

`-` Terraform does not allow you to test checks or use TS/JS programming.

`-` Terraform and its HCL syntax is hard to learn for many app developers.

`-` Using Terraform with Git is non-trivial.

## Pulumi vs. Checkly CLI

**Pros**

`+` Pulumi integrates well with Checkly. We have a maintained Pulumi provider.

`+` Pulumi is comfortable with app developers across many languages.

`+` Checkly can be configured almost completely through Pulumi resources.

**Cons**

`-` Pulumi does not really work without signing up for a Pulumi account.

`-` Pulumi does not allow you to run and debug checks from your local dev environment.

`-` Pulumi is not optimized for testing and monitoring use cases.
Loading