Skip to content

Commit

Permalink
[automated commit] Bump docs to version 1.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
leorossi authored and github-actions[bot] committed Nov 3, 2023
1 parent 6a3b2b4 commit 8b58c8c
Show file tree
Hide file tree
Showing 145 changed files with 165 additions and 4 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 104 additions & 0 deletions versioned_docs/version-1.8.0/guides/logging-to-elasticsearch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Logging to ElasticSearch (or any other destination)

This guide shows how to configure a Platformatic application to
deliver logs to [ElasticSearch](https://www.elastic.co/elasticsearch/)
or via any other supported [transports](https://getpino.io/#/docs/transports).
The logs will then be visualized via [Kibana](https://www.elastic.co/kibana).

## Create a platformatic application

Create a platformatic application using `npx create-platformatic@latest`.

## Setup ElasticSearch and Kibana

If you are logging to ElasticSearch and visualizing with Kibana,
you might want to set it up using [Docker Compose](https://docs.docker.com/compose/)
for local testing.

Write the following as `docker-compose.yml`:

```yaml
---
version: '3.8'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.3.3
environment:
- discovery.type=single-node
# Elasticsearch 8.x has HTTPS and auth on by default. This option is
# needed to use HTTP and no auth (as used in the tests).
- xpack.security.enabled=false
container_name: elasticsearch
ports: ['9200:9200']

kibana:
image: docker.elastic.co/kibana/kibana:8.3.3
container_name: kibana
ports: ['5601:5601']
depends_on: ['elasticsearch']
```
Then, start ElasticSearch and Kibana with `docker-compose -f docker-compose.yml up`.

## Install transport

```bash
npm i pino-elasticsearch
```

## Configure Logger Transport

Configuring your platformatic application to log to ElasticSearch is straighforward,
you just have to configure it like the following:

```json
{
...
"server": {
"hostname": "{PLT_SERVER_HOSTNAME}",
"port": "{PORT}",
"logger": {
"level": "{PLT_SERVER_LOGGER_LEVEL}",
"transport": {
"targets": [{
"target": "pino-elasticsearch",
"options": {
"node": "http://127.0.0.1:9200"
}
}, {
"target": "pino-pretty"
}]
}
}
}
}
```

This snippet can be applied either to the `platformatic.runtime.json` config
for Platformatic Runtime applications, or as part of the applicaiton configuration
for any other application.

This setup will allow you to log both to the terminal (TTY)
and to ElasticSearch at the same time.

Start your server with `platformatic start`, and navigate across
its API.

## Configure Kibana

1. Open `http://localhost:5601` in your browser
2. Click on the hamburger menu on top left, and then "Discover"

![Kibana start page](./images/kibana-1.png)

3. Click on the "Create Data View"

![Create a Data View](./images/kibana-2.png)

4. Write `pino*` as `name` and select `time` as timestamp field

![Select an index](./images/kibana-3.png)

5. Enjoy your logs

![Browse logs](./images/kibana-4.png)
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Welcome to Platformatic. Available commands are:
* `deploy` - deploy a Platformatic application to the cloud.
* `runtime` - start Platformatic Runtime; type `platformatic runtime help` to know more.
* `start` - start a Platformatic application.
* `login` - generate a Platformatic login api key.


#### compile
Expand Down Expand Up @@ -131,6 +132,47 @@ Options:
> :information_source:
>
> When deploying an application to a ***dynamic workspace***, specify the deploy `--label` option. You can find it on your cloud dashboard or you can specify a new one.
>
> If you do not specify an environment file to use with the `-e` flag, **ensure that a default environment file named `.env` exists**.
Deploy a **static** Platformatic Cloud application.

```bash
platformatic deploy \
-t static \
-c platformatic.db.json \
-e .env.prototype \
--workspace-id=00000000-0000-0000-0000-000000000000 \
--workspace-key=11111111111111111111111111111111
```

Deploy a **static** Platformatic Cloud application with a workspace keys file. The keys file can be downloaded from the Platformatic Console when generating a new API key.

```bash
platformatic deploy \
-t static \
-c platformatic.db.json \
-k foo.plt.txt
```

The `foo.plt.txt` must contain two variables for the workspace id and workspace API key.

```
# Contents of foo.plt.txt
PLATFORMATIC_STATIC_WORKSPACE_ID=00000000-0000-0000-0000-000000000000
PLATFORMATIC_STATIC_WORKSPACE_API_KEY=11111111111111111111111111111111
```

Deploy a **dynamic** Platformatic Cloud application.

```bash
platformatic deploy \
-t dynamic \
-c platformatic.db.json \
-l dev \
--workspace-id=00000000-0000-0000-0000-000000000000 \
--workspace-key=11111111111111111111111111111111
```


#### gh
Expand Down Expand Up @@ -163,6 +205,20 @@ You can find more details about the configuration format here:



#### login

Generate a Platformatic login api key.

``` bash
$ platformatic deploy
```

Options:

* `-c, --config FILE` - Specify a path to a global platformatic config file. Defaults to `~/.platformatic/config.json`.
* `--browser` - Automatically open default browser. If process stdout is a TTY, the default is `true`. Otherwise, the default is `false`.


#### start

Start a Platformatic application with the following command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ The *typescript* implementation will look like this

```ts
import type { Api } from './api-types'
import * as Types from './api-types'
import type * as Types from './api-types'

let baseUrl = ''
export const setBaseUrl = (newUrl: string) : void => { baseUrl = newUrl }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"guides/applications-with-stackables",
"guides/telemetry",
"guides/dockerize-platformatic-app",
"guides/build-modular-monolith"
"guides/build-modular-monolith",
"guides/logging-to-elasticsearch"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
"1.8.0",
"1.7.1",
"1.7.0",
"1.6.1",
"1.6.0",
"1.5.2"
"1.6.0"
]

0 comments on commit 8b58c8c

Please sign in to comment.