generated from shuding/nextra-docs-template
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy: Add logging and remote session pages
Part of #6
- Loading branch information
Showing
5 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Logging on Wasmer Edge | ||
|
||
Identifying issues in deployed applications often requires log output. | ||
|
||
To make the experience as frictionless as possible, Wasmer Edge automatically | ||
collects logs from your Webassembly instances and makes them available to you | ||
through the web interface and the CLI. | ||
|
||
## Producing Logs | ||
|
||
To produce logs, all you need to do is to emit log output from your application | ||
to standard output streams. | ||
|
||
This means you can use any logging library of your choice in the language you use. | ||
In Rust [tracing](https://github.com/tokio-rs/tracing) is a popular option. | ||
|
||
## Configuring Log Capture | ||
|
||
For [proxy - TODO insert proxy deployment link](./) apps, both `stdout` and | ||
`stderr` are captured by default. | ||
|
||
For [WCGI - TODO insert WCGI deployment link](./) apps, only `stderr` is captured, | ||
because `stdout` is used for transferring the HTTP response. | ||
|
||
You will be able to further customize log capturing in the future through the | ||
app config, to turn off logs or limit them to a specific stream. | ||
|
||
This configuration is not available just yet though, so be mindful of which log | ||
ouput you produce to avoid leaking information. | ||
|
||
## Accessing Logs | ||
|
||
There are two methods for accessing your logs. | ||
|
||
### CLI | ||
|
||
The `wasmer app logs` command can retrieve log output. | ||
|
||
Some example commands, which assume that your application is called `webserver`: | ||
|
||
* Retrieve logs for the last ten minutes: | ||
|
||
```bash | ||
wasmer app logs webserver | ||
``` | ||
|
||
* Retrieve logs for a specific time range: | ||
|
||
Note the `--max XXX` entry to limit the amount of retrieved log lines. | ||
|
||
```bash | ||
wasmer app logs --max 1000 --from 2023-06-10 --until 2023-06-10T10:00:00 | ||
``` | ||
|
||
* Retrieve logs in JSON format for further processing: | ||
|
||
```bash | ||
wasmer app logs -f json | ||
``` | ||
|
||
### Web Interface | ||
|
||
You can access logs through the Wasmer dashboard as well. | ||
|
||
Just open the apps dashboard on [wasmer.io/apps](https://wasmer.io/apps) and | ||
select your app. | ||
|
||
![app logs in the Wasmer Dashboard](./logging_webui.png) | ||
|
||
## Log Retention and Limits | ||
|
||
During the early testing period log retention and log volume limits are subject | ||
to change. | ||
|
||
Different billing tiers will be introduced in the future to allow upgrading to | ||
longer retention periods and higher log volume limits. | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"remote_sessions": "Remote Sessions" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# Remote Sessions | ||
|
||
You can start interactive remote sessions on the Wasmer Edge. | ||
|
||
A session opens an interactive bash shell, which allows you to run any package | ||
from the Wasmer registry. | ||
|
||
You can even forward ports from the session to your local machine, allowing you | ||
access to servers running inside the session! | ||
|
||
Note that at the moment sessions do not persist after the connection is closed. | ||
In the future persistent sessions will be introduced. | ||
This means you will be able to close the connection and then re-connect to your | ||
session later on, giving you a persistent remote environment. | ||
|
||
While this isn't available quite yet, sessions are already useful to explore the | ||
ecosystem and to test out the behaviour of your own apps. | ||
|
||
## Usage | ||
|
||
To start a session: | ||
* Install the `wasmer` CLI and log in to Wasmer | ||
See the [Quickstart](../quickstart/http-server.mdx) for a guide. | ||
* Make sure the `ssh` command is installed. | ||
|
||
Once that is done, you can simply run: | ||
|
||
```bash | ||
wasmer ssh | ||
```` | ||
|
||
This will drop you right into a interactive bash session. | ||
You can now use standard Linux commands like `cd`, `ls`, `mkdir`, ... | ||
|
||
You also have access to the `wasmer run` command, so you can run arbitrary | ||
packages from the Wasmer registry. | ||
|
||
For example: | ||
```bash | ||
wasmer run john-sharratt/catsay meow | ||
``` | ||
|
||
To forward a port, run: | ||
|
||
```bash | ||
wasmer ssh --map-port 9000 | ||
``` | ||
|
||
This will forward your local port 9000 to port 9000 in the remote instance, | ||
allowing you to access remotely running servers. | ||
|
||
### Example: Local Access to a Remote Server | ||
|
||
We can now combine all these features to run a static web server inside a remote | ||
session, and access the server locally through a forwarded port. | ||
|
||
The below will first start a session with port 9000 mapped. | ||
We then create a `public` directory and a stub `index.html` file, and start a | ||
static web server on port 9000. | ||
|
||
```bash | ||
wasmer ssh --map-port 9000 | ||
> mkdir public | ||
> echo HELLO > public/index.html | ||
> wasmer run wasmer/static-web-server -- -p 9000 | ||
``` | ||
|
||
You will now be able to access the remote server! | ||
|
||
Run this on your local machine in a new terminal window: | ||
|
||
```bash | ||
curl localhost:9000 | ||
> HELLO | ||
```` | ||
## How It Works | ||
`wasmer ssh` simply connects to a server in the Wasmer Edge network through a | ||
standard SSH connection. | ||
The server then runs a command (bash by default), and connects `stdin`, `stdout` | ||
and `stderr` of the running workload with the SSH session, forwarding all input | ||
and output. | ||
Port forwarding is also achieved through SSH. | ||
In fact, you could simply replace `wasmer ssh` with `ssh token@WASMER-SERVER-IP`. | ||
The only thing special about `wasmer ssh` is that it will automatically provision | ||
a token for your user that will be recognized by the Edge servers. | ||
## Billing | ||
Remote sessions will count toward your resource usage on Wasmer, and will be | ||
included in your invoice. |