Skip to content

Commit 7ad6306

Browse files
authored
Forwarder (#214)
* Minimal working refactor * Replace flush func with a more flexible clearer * Move chunk size into buffer options * Fix formatting * Add docs for buffer configs * WIP * Add forward test and format * Add TLS listener test * Add details about cert generation * Add test for stanza forward output * Full build * Update changelog * Add docs * Add check for required address field * Compare timestamps by string to avoid locale issues * Use time.Equal to compare potentially different locales
1 parent a3c391f commit 7ad6306

File tree

22 files changed

+2273
-6
lines changed

22 files changed

+2273
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## Unreleased
8+
### Added
9+
- New operators `forward_output` and `forward_input` to easily send log entries between stanza instances.
10+
711
## [0.13.2] - 2020-11-17
812
### Added
913
- New parameter `if` to parser plugins to allow for easy conditional parsing without routers

cmd/stanza/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/observiq/stanza/cmd/stanza
33
go 1.14
44

55
require (
6-
github.com/kardianos/service v1.1.0
6+
github.com/kardianos/service v1.2.0
77
github.com/observiq/stanza v0.12.5
88
github.com/observiq/stanza/operator/builtin/input/k8sevent v0.1.0
99
github.com/observiq/stanza/operator/builtin/input/windows v0.1.1

cmd/stanza/go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,8 @@ github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E
628628
github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0=
629629
github.com/kardianos/service v1.1.0 h1:QV2SiEeWK42P0aEmGcsAgjApw/lRxkwopvT+Gu6t1/0=
630630
github.com/kardianos/service v1.1.0/go.mod h1:RrJI2xn5vve/r32U5suTbeaSGoMU6GbNPoj36CVYcHc=
631+
github.com/kardianos/service v1.2.0 h1:bGuZ/epo3vrt8IPC7mnKQolqFeYJb7Cs8Rk4PSOBB/g=
632+
github.com/kardianos/service v1.2.0/go.mod h1:CIMRFEJVL+0DS1a3Nx06NaMn4Dz63Ng6O7dl0qH0zVM=
631633
github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4=
632634
github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
633635
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
@@ -1295,6 +1297,8 @@ golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7w
12951297
golang.org/x/sys v0.0.0-20200821140526-fda516888d29/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12961298
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f h1:Fqb3ao1hUmOR3GkUOg/Y+BadLwykBIzs5q8Ez2SbHyc=
12971299
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1300+
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211 h1:9UQO31fZ+0aKQOFldThf7BKPMJTiBfWycGh/u3UoO88=
1301+
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12981302
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
12991303
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
13001304
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

cmd/stanza/init_common.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
// Load packages when importing input operators
55
_ "github.com/observiq/stanza/operator/builtin/input/file"
6+
_ "github.com/observiq/stanza/operator/builtin/input/forward"
67
_ "github.com/observiq/stanza/operator/builtin/input/generate"
78
_ "github.com/observiq/stanza/operator/builtin/input/k8sevent"
89
_ "github.com/observiq/stanza/operator/builtin/input/stanza"
@@ -28,6 +29,7 @@ import (
2829
_ "github.com/observiq/stanza/operator/builtin/output/drop"
2930
_ "github.com/observiq/stanza/operator/builtin/output/elastic"
3031
_ "github.com/observiq/stanza/operator/builtin/output/file"
32+
_ "github.com/observiq/stanza/operator/builtin/output/forward"
3133
_ "github.com/observiq/stanza/operator/builtin/output/googlecloud"
3234
_ "github.com/observiq/stanza/operator/builtin/output/newrelic"
3335
_ "github.com/observiq/stanza/operator/builtin/output/otlp"

docs/operators/forward_input.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## `foward_input` operator
2+
3+
The `foward_input` operator receives logs from another Stanza instance running `forward_output`.
4+
5+
### Configuration Fields
6+
7+
| Field | Default | Description |
8+
| --- | --- | --- |
9+
| `id` | `forward_output` | A unique identifier for the operator |
10+
| `listen_address` | `:80` | The IP address and port to listen on |
11+
| `tls` | | A block for configuring the server to listen with TLS |
12+
13+
#### TLS block configuration
14+
15+
| Field | Default | Description |
16+
| --- | --- | --- |
17+
| `cert_file` | | The location of the certificate file |
18+
| `key_file` | | The location of the key file |
19+
20+
21+
### Example Configurations
22+
23+
#### Simple configuration
24+
25+
Configuration:
26+
```yaml
27+
- type: forward_input
28+
listen_address: ":25535"
29+
```
30+
31+
#### TLS configuration
32+
33+
Configuration:
34+
```yaml
35+
- type: forward_input
36+
listen_address: ":25535"
37+
tls:
38+
cert_file: /tmp/public.crt
39+
key_file: /tmp/private.key
40+
```

docs/operators/forward_output.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## `forward_output` operator
2+
3+
The `forward_output` operator sends logs to another Stanza instance running `forward_input`.
4+
5+
### Configuration Fields
6+
7+
| Field | Default | Description |
8+
| --- | --- | --- |
9+
| `id` | `forward_output` | A unique identifier for the operator |
10+
| `address` | required | The address that the downstream Stanza instance is listening on |
11+
| `buffer` | | A [buffer](/docs/types/buffer.md) block indicating how to buffer entries before flushing |
12+
| `flusher` | | A [flusher](/docs/types/flusher.md) block configuring flushing behavior |
13+
14+
15+
### Example Configurations
16+
17+
#### Simple configuration
18+
19+
Configuration:
20+
```yaml
21+
- type: forward_output
22+
address: "http://downstream_server:25535"
23+
```

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,22 @@ require (
66
github.com/antonmedv/expr v1.8.2
77
github.com/cenkalti/backoff/v4 v4.0.2
88
github.com/json-iterator/go v1.1.10
9+
github.com/kardianos/service v1.2.0 // indirect
910
github.com/kr/text v0.2.0 // indirect
1011
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
1112
github.com/modern-go/reflect2 v1.0.1 // indirect
1213
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
1314
github.com/observiq/ctimefmt v1.0.0
1415
github.com/observiq/nanojack v0.0.0-20201106172433-343928847ebc
1516
github.com/pkg/errors v0.9.1 // indirect
17+
github.com/spf13/cobra v1.1.1 // indirect
1618
github.com/stretchr/objx v0.1.1 // indirect
1719
github.com/stretchr/testify v1.6.1
1820
go.etcd.io/bbolt v1.3.4
1921
go.uber.org/zap v1.15.0
2022
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6 // indirect
2123
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
2224
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
23-
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f // indirect
2425
golang.org/x/text v0.3.3
2526
golang.org/x/tools v0.0.0-20200904185747-39188db58858 // indirect
2627
gonum.org/v1/gonum v0.6.2

0 commit comments

Comments
 (0)