You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
+

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

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
Copy file name to clipboardExpand all lines: cli/authentication.mdx
+31-51Lines changed: 31 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,52 +3,52 @@ title: Authentication
3
3
description: 'How to authenticate with the Checkly CLI'
4
4
sidebarTitle: 'Authentication'
5
5
---
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.
7
7
8
-
## Login
8
+
## Interactive
9
9
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.
11
12
12
13
```bash Terminal
13
14
npx checkly login
14
15
```
15
16
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:
21
18
22
-
## Log Out
19
+
```bash Terminal
20
+
npx checkly switch
21
+
```
23
22
24
-
To log out and clear your stored credentials:
23
+
... or quickly find out which account you are currently targeting with:
25
24
26
25
```bash Terminal
27
-
npx checkly logout
26
+
npx checkly whoami
28
27
```
29
28
30
-
This will remove the stored API key from your local machine.
29
+
To log out and clear your stored credentials:
31
30
32
-
## Other Authentication Options
31
+
```bash Terminal
32
+
npx checkly logout
33
+
```
33
34
34
-
### Environment Variables
35
+
##From CI
35
36
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.
37
38
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`
39
42
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).
44
44
45
-
Set the account id and API key as follows:
45
+
Set the account ID and API key as follows:
46
46
47
47
```bash Terminal
48
48
# Set your Checkly API key
49
49
export CHECKLY_API_KEY=your_api_key_here
50
50
51
-
# Set your Checkly account ID (optional, CLI will detect automatically)
51
+
# Set your Checkly account ID
52
52
export CHECKLY_ACCOUNT_ID=your_account_id_here
53
53
```
54
54
@@ -60,36 +60,16 @@ npx checkly whoami
60
60
61
61
This will display your account information and confirm your authentication status.
62
62
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
-
84
63
## Troubleshooting
85
64
86
-
### Common Issues
65
+
<AccordionGroup>
66
+
<Accordiontitle="`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:
87
70
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)
92
72
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.
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.
10
11
@@ -175,14 +176,7 @@ When you deploy a project, you can attach Git-specific information so changes to
175
176
176
177
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.
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