Skip to content

Commit a0e6b16

Browse files
[docs] Migrate docs from AsciiDoc to Markdown (#27)
Co-authored-by: Mike Birnstiehl <[email protected]>
1 parent c0dc589 commit a0e6b16

File tree

7 files changed

+663
-99
lines changed

7 files changed

+663
-99
lines changed

docs/docset.yml

Lines changed: 487 additions & 0 deletions
Large diffs are not rendered by default.

docs/index.asciidoc

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

docs/introduction.asciidoc

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

docs/reference/index.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
mapped_pages:
3+
- https://www.elastic.co/guide/en/ecs-logging/go-zerolog/current/intro.html
4+
- https://www.elastic.co/guide/en/ecs-logging/go-zerolog/current/index.html
5+
---
6+
7+
# ECS Logging Go (Zerolog) [intro]
8+
9+
ECS loggers are formatter/encoder plugins for your favorite logging libraries. They make it easy to format your logs into ECS-compatible JSON.
10+
11+
The encoder logs in JSON format and handles the logging of error fields in [ECS error format](ecs://docs/reference/ecs-error.md).
12+
13+
By default, the following fields are added:
14+
15+
```json
16+
{
17+
"log.level": "info",
18+
"@timestamp": "2020-09-13T10:48:03.000Z",
19+
"message":" some logging info",
20+
"ecs.version": "1.6.0"
21+
}
22+
```
23+
24+
::::{tip}
25+
Want to learn more about ECS, ECS logging, and other available language plugins? See the [ECS logging guide](ecs-logging://docs/reference/intro.md).
26+
::::
27+
28+
29+
Ready to jump into `ecszerolog`? [Get started](/reference/setup.md).
30+

docs/reference/setup.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
---
2+
mapped_pages:
3+
- https://www.elastic.co/guide/en/ecs-logging/go-zerolog/current/setup.html
4+
navigation_title: Get started
5+
---
6+
7+
# Get started with ECS Logging Go (Zerolog) [setup]
8+
9+
10+
## Step 1: Install [setup-step-1]
11+
12+
Add the package to your `go.mod` file:
13+
14+
```go
15+
require go.elastic.co/ecszerolog main
16+
```
17+
18+
19+
## Step 2: Configure [setup-step-2]
20+
21+
Set up a default logger. For example:
22+
23+
```go
24+
logger := ecszerolog.New(os.Stdout)
25+
log.Logger = logger
26+
```
27+
28+
29+
## Examples [examples]
30+
31+
32+
### Use structured logging [use-structured-logging]
33+
34+
```go
35+
// Add custom fields.
36+
log.Info().Msg("hello world").Str("custom", "foo")
37+
```
38+
39+
The example above produces the following log output:
40+
41+
```json
42+
{
43+
"@timestamp": "2021-01-20T11:12:43.061+0800",
44+
"custom":"foo",
45+
"ecs.version": "1.6.0",
46+
"log.level": "info",
47+
"message":"hello world"
48+
}
49+
```
50+
51+
52+
## Step 3: Configure Filebeat [setup-step-3]
53+
54+
:::::::{tab-set}
55+
56+
::::::{tab-item} Log file
57+
1. Follow the [Filebeat quick start](beats://docs/reference/filebeat/filebeat-installation-configuration.md)
58+
2. Add the following configuration to your `filebeat.yaml` file.
59+
60+
For Filebeat 7.16+
61+
62+
```yaml
63+
filebeat.inputs:
64+
- type: filestream <1>
65+
paths: /path/to/logs.json
66+
parsers:
67+
- ndjson:
68+
overwrite_keys: true <2>
69+
add_error_key: true <3>
70+
expand_keys: true <4>
71+
72+
processors: <5>
73+
- add_host_metadata: ~
74+
- add_cloud_metadata: ~
75+
- add_docker_metadata: ~
76+
- add_kubernetes_metadata: ~
77+
```
78+
79+
1. Use the filestream input to read lines from active log files.
80+
2. Values from the decoded JSON object overwrite the fields that {{filebeat}} normally adds (type, source, offset, etc.) in case of conflicts.
81+
3. {{filebeat}} adds an "error.message" and "error.type: json" key in case of JSON unmarshalling errors.
82+
4. {{filebeat}} will recursively de-dot keys in the decoded JSON, and expand them into a hierarchical object structure.
83+
5. Processors enhance your data. See [processors](beats://docs/reference/filebeat/filtering-enhancing-data.md) to learn more.
84+
85+
86+
For Filebeat < 7.16
87+
88+
```yaml
89+
filebeat.inputs:
90+
- type: log
91+
paths: /path/to/logs.json
92+
json.keys_under_root: true
93+
json.overwrite_keys: true
94+
json.add_error_key: true
95+
json.expand_keys: true
96+
97+
processors:
98+
- add_host_metadata: ~
99+
- add_cloud_metadata: ~
100+
- add_docker_metadata: ~
101+
- add_kubernetes_metadata: ~
102+
```
103+
::::::
104+
105+
::::::{tab-item} Kubernetes
106+
1. Make sure your application logs to stdout/stderr.
107+
2. Follow the [Run Filebeat on Kubernetes](beats://docs/reference/filebeat/running-on-kubernetes.md) guide.
108+
3. Enable [hints-based autodiscover](beats://docs/reference/filebeat/configuration-autodiscover-hints.md) (uncomment the corresponding section in `filebeat-kubernetes.yaml`).
109+
4. Add these annotations to your pods that log using ECS loggers. This will make sure the logs are parsed appropriately.
110+
111+
```yaml
112+
annotations:
113+
co.elastic.logs/json.overwrite_keys: true <1>
114+
co.elastic.logs/json.add_error_key: true <2>
115+
co.elastic.logs/json.expand_keys: true <3>
116+
```
117+
118+
1. Values from the decoded JSON object overwrite the fields that {{filebeat}} normally adds (type, source, offset, etc.) in case of conflicts.
119+
2. {{filebeat}} adds an "error.message" and "error.type: json" key in case of JSON unmarshalling errors.
120+
3. {{filebeat}} will recursively de-dot keys in the decoded JSON, and expand them into a hierarchical object structure.
121+
::::::
122+
123+
::::::{tab-item} Docker
124+
1. Make sure your application logs to stdout/stderr.
125+
2. Follow the [Run Filebeat on Docker](beats://docs/reference/filebeat/running-on-docker.md) guide.
126+
3. Enable [hints-based autodiscover](beats://docs/reference/filebeat/configuration-autodiscover-hints.md).
127+
4. Add these labels to your containers that log using ECS loggers. This will make sure the logs are parsed appropriately.
128+
129+
```yaml
130+
labels:
131+
co.elastic.logs/json.overwrite_keys: true <1>
132+
co.elastic.logs/json.add_error_key: true <2>
133+
co.elastic.logs/json.expand_keys: true <3>
134+
```
135+
136+
1. Values from the decoded JSON object overwrite the fields that {{filebeat}} normally adds (type, source, offset, etc.) in case of conflicts.
137+
2. {{filebeat}} adds an "error.message" and "error.type: json" key in case of JSON unmarshalling errors.
138+
3. {{filebeat}} will recursively de-dot keys in the decoded JSON, and expand them into a hierarchical object structure.
139+
::::::
140+
141+
:::::::
142+
For more information, see the [Filebeat reference](beats://docs/reference/filebeat/configuring-howto-filebeat.md).
143+

docs/reference/toc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
toc:
2+
- file: index.md
3+
- file: setup.md

docs/setup.asciidoc

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

0 commit comments

Comments
 (0)