Skip to content

Commit

Permalink
Stanza library update (#2281)
Browse files Browse the repository at this point in the history
Addresses issue #2273 
Also relevant to roadmap defined on #2264
  • Loading branch information
djaglowski authored Feb 3, 2021
1 parent 9677f5b commit 017fca0
Show file tree
Hide file tree
Showing 19 changed files with 53 additions and 45 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/wavefrontreceiver v0.0.0-00010101000000-000000000000
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver v0.0.0-00010101000000-000000000000
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zookeeperreceiver v0.0.0-00010101000000-000000000000
github.com/open-telemetry/opentelemetry-log-collection v0.14.0 // indirect
github.com/sirupsen/logrus v1.7.0 // indirect
github.com/stretchr/testify v1.7.0
go.opentelemetry.io/collector v0.19.1-0.20210127225953-68c5961f7bc2
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -979,10 +979,10 @@ github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/observiq/ctimefmt v1.0.0 h1:r7vTJ+Slkrt9fZ67mkf+mA6zAdR5nGIJRMTzkUyvilk=
github.com/observiq/ctimefmt v1.0.0/go.mod h1:mxi62//WbSpG/roCO1c6MqZ7zQTvjVtYheqHN3eOjvc=
github.com/observiq/go-syslog/v3 v3.0.2/go.mod h1:9abcumkQwDUY0VgWdH6CaaJ3Ks39A7NvIelMlavPru0=
github.com/observiq/nanojack v0.0.0-20200910202758-a0af1c611319/go.mod h1:f+QQxL9zFpO5q44o7rf+TOEtEmlMQUI9snW9ZADIku0=
github.com/observiq/nanojack v0.0.0-20201106172433-343928847ebc h1:49ewVBwLcy+eYqI4R0ICilCI4dPjddpFXWv3liXzUxM=
github.com/observiq/nanojack v0.0.0-20201106172433-343928847ebc/go.mod h1:WXIHwGy+c7/IK2PiJ4oxuTHkpnkSut7TNFpKnI5llPU=
github.com/observiq/stanza v0.13.12 h1:o4LHbaa0mk/aU+iPFRtQuFEVsoLxmIAH3ytZ/NSq9po=
github.com/observiq/stanza v0.13.12/go.mod h1:LJfJG+RiDGdUOyukMbdUJR0OVU+5Bnbwh7GP4QTZyMI=
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU=
Expand Down Expand Up @@ -1014,6 +1014,8 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
github.com/onsi/gomega v1.10.2 h1:aY/nuoWlKJud2J6U0E3NWsjlg+0GtwXxgEqthRdzlcs=
github.com/onsi/gomega v1.10.2/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
github.com/open-telemetry/opentelemetry-log-collection v0.14.0 h1:hnf4rn2NxvlXKdTCXeq7zV0Jdx2mIlX2aUMTViq6+ks=
github.com/open-telemetry/opentelemetry-log-collection v0.14.0/go.mod h1:DwA3MWfRL0iRdhnjn+c/Ihhr+6Fu11K+8C7NYQmEL/w=
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
Expand Down
18 changes: 9 additions & 9 deletions receiver/stanzareceiver/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Stanza Receiver

Tails and parses logs from a wide variety of sources using the [stanza](https://github.com/observIQ/stanza/tree/master/docs) log processor.
Tails and parses logs from a wide variety of sources using the [opentelemetry-log-collection](https://github.com/open-telemetry/opentelemetry-log-collection) library.

Supported pipeline types: metrics
Supported pipeline types: logs

> :construction: This receiver is in alpha and configuration fields are subject to change.
Expand All @@ -14,11 +14,11 @@ It can also be easily configured to tail and parse any structured or unstructure

## Required Parameters

- `operators` is an array of [operators](https://github.com/observIQ/stanza/blob/master/docs/README.md#what-operators-are-available). Each operator performs a simple responsibility, such as reading from a file, or parsing JSON. Chain together operators to process logs into a desired format.
- `operators` is an array of [operators](https://github.com/open-telemetry/opentelemetry-log-collection/blob/main/docs/operators/README.md#what-operators-are-available). Each operator performs a simple responsibility, such as reading from a file, or parsing JSON. Chain together operators to process logs into a desired format.

## Optional Parameters

- `plugin_dir` is the path to a directory which contains `stanza` [plugins](https://github.com/observIQ/stanza/blob/master/docs/plugins.md). Plugins are parameterized pipelines that are designed for specific use cases.
- `plugin_dir` is the path to a directory which contains `stanza` [plugins](https://github.com/open-telemetry/opentelemetry-log-collection/blob/main/docs/plugins.md#using-plugins). Plugins are parameterized pipelines that are designed for specific use cases.
- `offsets_file` is the path to a file that `stanza` will use to remember where it left off when reading from files or other persistent input sources. If specified, `stanza` will create and manage this file.

## Operator Basics
Expand All @@ -29,11 +29,11 @@ It can also be easily configured to tail and parse any structured or unstructure

## Additional Terminology and Features

- An [entry](https://github.com/observIQ/stanza/blob/master/docs/types/entry.md) is the base representation of log data as it moves through a pipeline. All operators either create, modify, or consume entries.
- A [field](https://github.com/observIQ/stanza/blob/master/docs/types/field.md) is used to reference values in an entry.
- A common [expression](https://github.com/observIQ/stanza/blob/master/docs/types/expression.md) syntax is used in several operators. For example, expressions can be used to [filter](https://github.com/observIQ/stanza/blob/master/docs/operators/filter.md) or [route](https://github.com/observIQ/stanza/blob/master/docs/operators/router.md) entries.
- [timestamp](https://github.com/observIQ/stanza/blob/master/docs/types/timestamp.md) parsing is available as a block within all parser operators, and also as a standalone operator. Many common timestamp layouts are supported.
- [severity](https://github.com/observIQ/stanza/blob/master/docs/types/severity.md) parsing is available as a block within all parser operators, and also as a standalone operator. Stanza uses a flexible severity representation which is automatically interpreted by the stanza receiver.
- An [entry](https://github.com/open-telemetry/opentelemetry-log-collection/blob/main/docs/types/entry.md) is the base representation of log data as it moves through a pipeline. All operators either create, modify, or consume entries.
- A [field](https://github.com/open-telemetry/opentelemetry-log-collection/blob/main/docs/types/field.md) is used to reference values in an entry.
- A common [expression](https://github.com/open-telemetry/opentelemetry-log-collection/blob/main/docs/types/expression.md) syntax is used in several operators. For example, expressions can be used to [filter](https://github.com/open-telemetry/opentelemetry-log-collection/blob/main/docs/operators/filter.md) or [route](https://github.com/open-telemetry/opentelemetry-log-collection/blob/main/docs/operators/router.md) entries.
- [timestamp](https://github.com/open-telemetry/opentelemetry-log-collection/blob/main/docs/types/timestamp.md) parsing is available as a block within all parser operators, and also as a standalone operator. Many common timestamp layouts are supported.
- [severity](https://github.com/open-telemetry/opentelemetry-log-collection/blob/main/docs/types/severity.md) parsing is available as a block within all parser operators, and also as a standalone operator. Stanza uses a flexible severity representation which is automatically interpreted by the stanza receiver.


## Example - Tailing a simple json file
Expand Down
4 changes: 2 additions & 2 deletions receiver/stanzareceiver/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019, OpenTelemetry Authors
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,7 +15,7 @@
package stanzareceiver

import (
"github.com/observiq/stanza/pipeline"
"github.com/open-telemetry/opentelemetry-log-collection/pipeline"
"go.opentelemetry.io/collector/config/configmodels"
"gopkg.in/yaml.v2"
)
Expand Down
2 changes: 1 addition & 1 deletion receiver/stanzareceiver/config_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020, OpenTelemetry Authors
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions receiver/stanzareceiver/converter.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019, OpenTelemetry Authors
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,7 @@ package stanzareceiver
import (
"fmt"

"github.com/observiq/stanza/entry"
"github.com/open-telemetry/opentelemetry-log-collection/entry"
"go.opentelemetry.io/collector/consumer/pdata"
)

Expand Down
4 changes: 2 additions & 2 deletions receiver/stanzareceiver/converter_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019, OpenTelemetry Authors
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,7 @@ import (
"testing"
"time"

"github.com/observiq/stanza/entry"
"github.com/open-telemetry/opentelemetry-log-collection/entry"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/consumer/pdata"
)
Expand Down
2 changes: 1 addition & 1 deletion receiver/stanzareceiver/doc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019, OpenTelemetry Authors
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion receiver/stanzareceiver/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"time"

"github.com/observiq/nanojack"
"github.com/observiq/stanza/entry"
"github.com/open-telemetry/opentelemetry-log-collection/entry"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer/consumertest"
Expand Down
6 changes: 3 additions & 3 deletions receiver/stanzareceiver/emitter.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package stanzareceiver

// Copyright 2019, OpenTelemetry Authors
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -18,8 +18,8 @@ import (
"context"
"sync"

"github.com/observiq/stanza/entry"
"github.com/observiq/stanza/operator/helper"
"github.com/open-telemetry/opentelemetry-log-collection/entry"
"github.com/open-telemetry/opentelemetry-log-collection/operator/helper"
"go.uber.org/zap"
)

Expand Down
4 changes: 2 additions & 2 deletions receiver/stanzareceiver/emitter_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019, OpenTelemetry Authors
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,7 @@ import (
"testing"
"time"

"github.com/observiq/stanza/entry"
"github.com/open-telemetry/opentelemetry-log-collection/entry"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest"
)
Expand Down
4 changes: 2 additions & 2 deletions receiver/stanzareceiver/factory.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019, OpenTelemetry Authors
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,7 @@ package stanzareceiver
import (
"context"

stanza "github.com/observiq/stanza/agent"
stanza "github.com/open-telemetry/opentelemetry-log-collection/agent"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configmodels"
"go.opentelemetry.io/collector/consumer"
Expand Down
2 changes: 1 addition & 1 deletion receiver/stanzareceiver/factory_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019, OpenTelemetry Authors
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion receiver/stanzareceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.14

require (
github.com/observiq/nanojack v0.0.0-20201106172433-343928847ebc
github.com/observiq/stanza v0.13.12
github.com/open-telemetry/opentelemetry-log-collection v0.14.0
github.com/stretchr/testify v1.7.0
go.opentelemetry.io/collector v0.19.1-0.20210127225953-68c5961f7bc2
go.uber.org/zap v1.16.0
Expand Down
7 changes: 5 additions & 2 deletions receiver/stanzareceiver/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -714,10 +714,10 @@ github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/observiq/ctimefmt v1.0.0 h1:r7vTJ+Slkrt9fZ67mkf+mA6zAdR5nGIJRMTzkUyvilk=
github.com/observiq/ctimefmt v1.0.0/go.mod h1:mxi62//WbSpG/roCO1c6MqZ7zQTvjVtYheqHN3eOjvc=
github.com/observiq/go-syslog/v3 v3.0.2 h1:vaeINFErM/E3cKE2Ot1FAhhGq5mv7uGBOzjnGL3qhbY=
github.com/observiq/go-syslog/v3 v3.0.2/go.mod h1:9abcumkQwDUY0VgWdH6CaaJ3Ks39A7NvIelMlavPru0=
github.com/observiq/nanojack v0.0.0-20201106172433-343928847ebc h1:49ewVBwLcy+eYqI4R0ICilCI4dPjddpFXWv3liXzUxM=
github.com/observiq/nanojack v0.0.0-20201106172433-343928847ebc/go.mod h1:WXIHwGy+c7/IK2PiJ4oxuTHkpnkSut7TNFpKnI5llPU=
github.com/observiq/stanza v0.13.12 h1:o4LHbaa0mk/aU+iPFRtQuFEVsoLxmIAH3ytZ/NSq9po=
github.com/observiq/stanza v0.13.12/go.mod h1:LJfJG+RiDGdUOyukMbdUJR0OVU+5Bnbwh7GP4QTZyMI=
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU=
Expand All @@ -742,6 +742,9 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
github.com/onsi/gomega v1.10.2 h1:aY/nuoWlKJud2J6U0E3NWsjlg+0GtwXxgEqthRdzlcs=
github.com/onsi/gomega v1.10.2/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
github.com/open-telemetry/opentelemetry-collector-contrib v0.19.0 h1:GWyywESsBy7rl19eSBQM4wIJYNCTdllyclxAPbDzjRQ=
github.com/open-telemetry/opentelemetry-log-collection v0.14.0 h1:hnf4rn2NxvlXKdTCXeq7zV0Jdx2mIlX2aUMTViq6+ks=
github.com/open-telemetry/opentelemetry-log-collection v0.14.0/go.mod h1:DwA3MWfRL0iRdhnjn+c/Ihhr+6Fu11K+8C7NYQmEL/w=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI=
Expand Down
8 changes: 4 additions & 4 deletions receiver/stanzareceiver/mocks_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package stanzareceiver

// Copyright 2019, OpenTelemetry Authors
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -18,9 +18,9 @@ import (
"context"
"fmt"

"github.com/observiq/stanza/entry"
"github.com/observiq/stanza/operator"
"github.com/observiq/stanza/operator/helper"
"github.com/open-telemetry/opentelemetry-log-collection/entry"
"github.com/open-telemetry/opentelemetry-log-collection/operator"
"github.com/open-telemetry/opentelemetry-log-collection/operator/helper"
"go.opentelemetry.io/collector/consumer/pdata"
)

Expand Down
4 changes: 2 additions & 2 deletions receiver/stanzareceiver/receiver.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019, OpenTelemetry Authors
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,7 @@ import (
"fmt"
"sync"

stanza "github.com/observiq/stanza/agent"
stanza "github.com/open-telemetry/opentelemetry-log-collection/agent"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenterror"
"go.opentelemetry.io/collector/consumer"
Expand Down
8 changes: 4 additions & 4 deletions receiver/stanzareceiver/receiver_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019, OpenTelemetry Authors
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -22,9 +22,9 @@ import (
"path/filepath"
"testing"

"github.com/observiq/stanza/entry"
"github.com/observiq/stanza/pipeline"
"github.com/observiq/stanza/testutil"
"github.com/open-telemetry/opentelemetry-log-collection/entry"
"github.com/open-telemetry/opentelemetry-log-collection/pipeline"
"github.com/open-telemetry/opentelemetry-log-collection/testutil"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenttest"
Expand Down
10 changes: 6 additions & 4 deletions receiver/stanzareceiver/register.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019, OpenTelemetry Authors
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,9 @@ package stanzareceiver

import (
// Register operators for stanza
_ "github.com/observiq/stanza/operator/builtin/input/file"
_ "github.com/observiq/stanza/operator/builtin/parser/json"
_ "github.com/observiq/stanza/operator/builtin/parser/regex"
_ "github.com/open-telemetry/opentelemetry-log-collection/operator/builtin/input/file"
_ "github.com/open-telemetry/opentelemetry-log-collection/operator/builtin/parser/json"
_ "github.com/open-telemetry/opentelemetry-log-collection/operator/builtin/parser/regex"
_ "github.com/open-telemetry/opentelemetry-log-collection/operator/builtin/parser/severity"
_ "github.com/open-telemetry/opentelemetry-log-collection/operator/builtin/parser/time"
)

0 comments on commit 017fca0

Please sign in to comment.