Skip to content

Commit 0031547

Browse files
authored
Merge pull request #134 from checkly/guolau/restore-cli-missing-pages
Restore missing CLI pages (and other misc improvements)
2 parents 3204261 + ecd6ee5 commit 0031547

19 files changed

Lines changed: 601 additions & 373 deletions

cli/attaching-git-metadata.mdx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: 'Attaching Git metadata'
3+
sidebarTitle: 'Attaching Git Metadata'
4+
---
5+
6+
import CliEnvVars from "/snippets/cli-env-vars.mdx"
7+
8+
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
9+
your test sessions and deployed resources in the UI and cross-reference them with any updates to your code.
10+
11+
For example, in the screenshot below we ran a **test session** from our CI server after the project was deployed to our
12+
Staging environment with the `npx checkly test --record` command.
13+
14+
![test session with git info](/images/docs/images/cli/test_session_git_data.png)
15+
16+
After the test succeeds, we **deploy** this check so it runs as a monitor with `npx checkly deploy`.
17+
18+
![browser check with git info](/images/docs/images/cli/browser_check_git_data.png)
19+
20+
21+
## Environment variables
22+
23+
The CLI will attempt to auto-detect and parse git specific information from your local machine or CI environment, but you
24+
can also set these data items specifically by using environment variables.
25+
26+
<CliEnvVars />
27+
28+
For example, if you want to specifically set the Environment you invoke:
29+
30+
```bash Terminal
31+
CHECKLY_TEST_ENVIRONMENT=Production npx checkly test --record
32+
```
33+
34+
Or, if you want to set repo URL you invoke:
35+
36+
```bash Terminal
37+
CHECKLY_REPO_URL="https://my.git.solution/project/" npx checkly test --record
38+
```

cli/authentication.mdx

Lines changed: 31 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,52 @@ title: Authentication
33
description: 'How to authenticate with the Checkly CLI'
44
sidebarTitle: 'Authentication'
55
---
6-
Before you can use the Checkly CLI, you need to authenticate with your Checkly account.
6+
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.
77

8-
## Login
8+
## Interactive
99

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

1213
```bash Terminal
1314
npx checkly login
1415
```
1516

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

22-
## Log Out
19+
```bash Terminal
20+
npx checkly switch
21+
```
2322

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

2625
```bash Terminal
27-
npx checkly logout
26+
npx checkly whoami
2827
```
2928

30-
This will remove the stored API key from your local machine.
29+
To log out and clear your stored credentials:
3130

32-
## Other Authentication Options
31+
```bash Terminal
32+
npx checkly logout
33+
```
3334

34-
### Environment Variables
35+
## From CI
3536

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

38-
To get your API key:
39+
You will need to export two environment variables in the shell:
40+
- `CHECKLY_API_KEY`
41+
- `CHECKLY_ACCOUNT_ID`
3942

40-
1. Log in to your Checkly dashboard
41-
2. Navigate to **Account Settings****API Keys**
42-
3. Create a new API key
43-
4. Use the key in your environment variables or CLI configuration
43+
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).
4444

45-
Set the account id and API key as follows:
45+
Set the account ID and API key as follows:
4646

4747
```bash Terminal
4848
# Set your Checkly API key
4949
export CHECKLY_API_KEY=your_api_key_here
5050

51-
# Set your Checkly account ID (optional, CLI will detect automatically)
51+
# Set your Checkly account ID
5252
export CHECKLY_ACCOUNT_ID=your_account_id_here
5353
```
5454

@@ -60,36 +60,16 @@ npx checkly whoami
6060

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

63-
## Multiple Accounts
64-
65-
If you work with multiple Checkly accounts, you can switch between them:
66-
67-
```bash Terminal
68-
# Switch to a different account using interactive prompt
69-
npx checkly switch
70-
71-
# Switch to a different account using the account id
72-
npx checkly switch --account-id your_account_id
73-
74-
# View current account
75-
npx checkly whoami
76-
```
77-
78-
## Security Best Practices
79-
80-
- **Never commit API keys** to version control
81-
- **Use environment variables** in production environments
82-
- **Rotate API keys** regularly for security
83-
8463
## Troubleshooting
8564

86-
### Common Issues
65+
<AccordionGroup>
66+
<Accordion title="`npx checkly login` doesn't open a browser window">
67+
If `npx checkly login` doesn't automatically open a browser window to authenticate, you can generate a direct link instead.
68+
69+
When prompted with:
8770

88-
**"Authentication failed" error:**
89-
- Verify your API key is correct
90-
- Check that your account ID is correct (if specified)
91-
- Ensure your API key hasn't expired
71+
> Do you want to open a browser window to continue with login? (Y/n)
9272
93-
**"Browser didn't open" error:**
94-
- Decline to open the browser automatically and navigate to the authentication URL shown in the terminal
95-
- Copy and paste the URL into your browser
73+
Enter "n". The CLI will provide a link that you can copy and paste into your browser to authenticate.
74+
</Accordion>
75+
</AccordionGroup>

cli/basic-workflow.mdx

Lines changed: 0 additions & 132 deletions
This file was deleted.

cli/checkly-deploy.mdx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ sidebarTitle: 'checkly deploy'
55
---
66

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

910
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.
1011

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

176177
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.
177178

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

187181
## Related Commands
188182

cli/cli-vs-terraform-pulumi.mdx

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: CLI vs. Terraform & Pulumi
3+
description: 'Comparing your options for Monitoring as Code'
4+
sidebarTitle: 'CLI vs Terraform & Pulumi'
5+
---
6+
7+
Creating, debugging and managing E2E and synthetic monitoring at scale is best done "as code". Currently, Checkly supports
8+
three tools you can use for your **monitoring as code** (MaC) workflow:
9+
10+
1. The Checkly CLI.
11+
2. Terraform (through our [Terraform provider](/integrations/iac/terraform/overview/))
12+
3. Pulumi (through our [Pulumi provider](/integrations/iac/pulumi/overview/))
13+
14+
In most cases, the choice depends on what your goals are and how your organization is set up.
15+
16+
We believe the **Checkly CLI delivers the best-of-breed workflow**. However, there are always trade-offs. Let's list some
17+
pros and cons based on our own experience and user feedback.
18+
19+
## Terraform vs. Checkly CLI
20+
21+
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.
22+
23+
**Pros**
24+
25+
`+` Terraform integrates very well with Checkly. We have a well maintained Terraform provider.
26+
27+
`+` Terraform is comfortable for many Devops engineers used to writing HCL scripts.
28+
29+
`+` Checkly can be configured almost completely through Terraform resources.
30+
31+
**Cons**
32+
33+
`-` Terraform does not allow you to test checks or use TS/JS programming.
34+
35+
`-` Terraform and its HCL syntax is hard to learn for many app developers.
36+
37+
`-` Using Terraform with Git is non-trivial.
38+
39+
## Pulumi vs. Checkly CLI
40+
41+
**Pros**
42+
43+
`+` Pulumi integrates well with Checkly. We have a maintained Pulumi provider.
44+
45+
`+` Pulumi is comfortable with app developers across many languages.
46+
47+
`+` Checkly can be configured almost completely through Pulumi resources.
48+
49+
**Cons**
50+
51+
`-` Pulumi does not really work without signing up for a Pulumi account.
52+
53+
`-` Pulumi does not allow you to run and debug checks from your local dev environment.
54+
55+
`-` Pulumi is not optimized for testing and monitoring use cases.

0 commit comments

Comments
 (0)