Skip to content

Commit

Permalink
Merge in master
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrod1598 committed May 7, 2021
2 parents f33bd1b + 37ab164 commit 9fbaace
Show file tree
Hide file tree
Showing 38 changed files with 2,804 additions and 706 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.13.20] - Unrealeased
## [0.13.22] - Unrealeased

### Added
- Added doublestar support

## [0.13.21] - 2021-05-07

### Changed
- Renamed Azure Event Hub event_data field to message [PR297](https://github.com/observIQ/stanza/pull/297)

## [0.13.20] - 2021-05-06

### Added
- Added flatten Operator [PR 286](https://github.com/observIQ/stanza/pull/286)
- Added Azure Event Hub Operator [PR 287](https://github.com/observIQ/stanza/pull/287)
- Added Azure Log Analytics Operator [PR 287](https://github.com/observIQ/stanza/pull/287)

## [0.13.19] - 2021-04-15

### Added
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2020 Blue Medora, Inc.
Copyright Blue Medora, Inc., 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 cmd/stanza/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.14

require (
github.com/kardianos/service v1.2.0
github.com/observiq/stanza v0.13.18
github.com/observiq/stanza v0.13.21
github.com/observiq/stanza/operator/builtin/input/k8sevent v0.1.0
github.com/observiq/stanza/operator/builtin/input/windows v0.1.1
github.com/observiq/stanza/operator/builtin/output/elastic v0.1.0
Expand Down
119 changes: 59 additions & 60 deletions cmd/stanza/go.sum

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions cmd/stanza/init_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package main

import (
// Load packages when importing input operators
_ "github.com/observiq/stanza/operator/builtin/input/azure/eventhub"
_ "github.com/observiq/stanza/operator/builtin/input/azure/loganalytics"
_ "github.com/observiq/stanza/operator/builtin/input/file"
_ "github.com/observiq/stanza/operator/builtin/input/forward"
_ "github.com/observiq/stanza/operator/builtin/input/generate"
Expand All @@ -11,7 +13,7 @@ import (
_ "github.com/observiq/stanza/operator/builtin/input/tcp"
_ "github.com/observiq/stanza/operator/builtin/input/udp"

_ "github.com/observiq/stanza/operator/builtin/parser/csv"
_ "github.com/observiq/stanza/operator/builtin/parser/csv"
_ "github.com/observiq/stanza/operator/builtin/parser/json"
_ "github.com/observiq/stanza/operator/builtin/parser/regex"
_ "github.com/observiq/stanza/operator/builtin/parser/severity"
Expand All @@ -20,12 +22,12 @@ import (
_ "github.com/observiq/stanza/operator/builtin/parser/uri"

_ "github.com/observiq/stanza/operator/builtin/transformer/filter"
_ "github.com/observiq/stanza/operator/builtin/transformer/recombine"
_ "github.com/observiq/stanza/operator/builtin/transformer/hostmetadata"
_ "github.com/observiq/stanza/operator/builtin/transformer/k8smetadata"
_ "github.com/observiq/stanza/operator/builtin/transformer/metadata"
_ "github.com/observiq/stanza/operator/builtin/transformer/noop"
_ "github.com/observiq/stanza/operator/builtin/transformer/ratelimit"
_ "github.com/observiq/stanza/operator/builtin/transformer/recombine"
_ "github.com/observiq/stanza/operator/builtin/transformer/restructure"
_ "github.com/observiq/stanza/operator/builtin/transformer/router"

Expand Down
1 change: 1 addition & 0 deletions docs/operators/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Outputs:
- [Elasticsearch](/docs/operators/elastic_output.md)
- [Stdout](/docs/operators/stdout.md)
- [File](docs/operators/file_output.md)
- [OTLP](docs/operators/otlp_output.md)

General purpose:
- [Rate Limit](/docs/operators/rate_limit.md)
Expand Down
55 changes: 55 additions & 0 deletions docs/operators/azure_event_hub_input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
## `azure_event_hub_input` operator

The `azure_event_hub_input` operator reads logs from Azure Event Hub using [Azure's SDK](https://github.com/Azure/azure-event-hubs-go)

The `azure_event_hub_input` operator will use the `EnqueuedTime` field of the event as the parsed entry's timestamp. If `EnqueuedTime` is not set, `azure_event_hub_input` will use `IoTHubEnqueuedTime` if it is set. All other fields are added to the entry's record.

### Configuration Fields

| Field | Default | Description |
| --- | --- | --- |
| `id` | `azure_event_hub_input` | A unique identifier for the operator |
| `output` | Next in pipeline | The connected operator(s) that will receive all outbound entries |
| `namespace` | required | The Event Hub Namespace |
| `name` | required | The Event Hub Name |
| `group` | required | The Event Hub Consumer Group |
| `connection_string` | required | The Event Hub [connection string](https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-get-connection-string) |
| `prefetch_count` | `1000` | Desired number of events to read at one time |
| `start_at` | `end` | At startup, where to start reading events. Options are `beginning` or `end` |

### Example Configurations

#### Simple Azure Event Hub input

Configuration:
```yaml
pipeline:
- type: azure_event_hub_input
namespace: stanza
name: devel
group: Default
connection_string: 'Endpoint=sb://stanza.servicebus.windows.net/;SharedAccessKeyName=dev;SharedAccessKey=supersecretkey;EntityPath=devel'
start_at: end
```
### Example Output
A list of potential keys and their purpose can be found [here](https://github.com/Azure/azure-event-hubs-go/blob/master/event.go). Event Hub `system_properties` documentation can be found [here](https://docs.microsoft.com/en-us/azure/data-explorer/ingest-data-event-hub-overview#event-system-properties-mapping)

```json
{
"timestamp": "2021-04-19T18:44:34.619Z",
"severity": 0,
"resource": {
"event_id": "fea3c182-00a6-4951-8f6f-9331031f978f"
},
"record": {
"message": "hello, world!",
"system_properties": {
"x-opt-enqueued-time": "2021-04-19T18:44:34.619Z",
"x-opt-offset": 6120,
"x-opt-sequence-number": 51
}
}
}
```
68 changes: 68 additions & 0 deletions docs/operators/azure_log_analytics_input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
## `azure_log_analytics_input` operator

The `azure_log_analytics_input` operator reads Azure Log Analytics logs from Azure Event Hub using.

The `azure_log_analytics_input` operator will use the `timegenerated` field as the parsed entry's timestamp. The label `azure_log_analytics_table` is derived from the log's `type` field.

## Prerequisites

You must define a Log Analytics Export Rule using Azure CLI. Microsoft has documentation [here](https://docs.microsoft.com/en-us/azure/azure-monitor/logs/logs-data-export?tabs=portal)

### Configuration Fields

| Field | Default | Description |
| --- | --- | --- |
| `id` | `azure_log_analytics_input` | A unique identifier for the operator |
| `output` | Next in pipeline | The connected operator(s) that will receive all outbound entries |
| `namespace` | required | The Event Hub Namespace |
| `name` | required | The Event Hub Name |
| `group` | required | The Event Hub Consumer Group |
| `connection_string` | required | The Event Hub [connection string](https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-get-connection-string) |
| `prefetch_count` | `1000` | Desired number of events to read at one time |
| `start_at` | `end` | At startup, where to start reading events. Options are `beginning` or `end` |

### Example Configurations

#### Simple Azure Event Hub input

Configuration:
```yaml
pipeline:
- type: azure_log_analytics_input
namespace: stanza
name: devel
group: Default
connection_string: 'Endpoint=sb://stanza.servicebus.windows.net/;SharedAccessKeyName=dev;SharedAccessKey=supersecretkey;EntityPath=devel'
start_at: end
```
### Example Output
A list of potential fields for each Azure Log Analytics table can be found [here](https://docs.microsoft.com/en-us/azure/azure-monitor/reference/tables/tables-category).
```json
{
"timestamp": "2021-05-07T14:01:26.105Z",
"severity": 0,
"record": {
"containerlog": {
"_internal_workspaceresourceid": "/subscriptions/000-000/resourcegroups/integration/providers/microsoft.operationalinsights/workspaces/stanza",
"_resourceid": "/subscriptions/0000-000/resourceGroups/devops/providers/Microsoft.ContainerService/managedClusters/log-analytics",
"computer": "aks-agentpool-39365618-vmss000001",
"containerid": "f5376c6972ac19630113736e7d3bf359fe67065fde3831b0502cfee33470e68f",
"logentry": "request to api failed"
"logentrysource": "stdout",
"mg": "00000000-0000-0000-0000-000000000002",
"sourcesystem": "Containers",
"tenantid": "ae0db88b-40bb-40b7-b056-57980214436c",
"timegenerated": "2021-05-07T14:01:26.1050000Z",
"timeofcommand": "2021-05-07T14:01:29.0000000Z"
},
"system_properties": {
"x-opt-enqueued-time": "2021-05-07T14:01:37.789Z",
"x-opt-offset": 150347296000,
"x-opt-sequence-number": 125576
}
}
}
```
116 changes: 116 additions & 0 deletions docs/operators/flatten.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
## `flatten` operator

The `flatten` operator flattens a field by moving its children up to the same level as the field.
The operator only flattens a single level deep.

### Configuration Fields

| Field | Default | Description |
| --- | --- | --- |
| `id` | `flatten` | A unique identifier for the operator |
| `output` | Next in pipeline | The connected operator(s) that will receive all outbound entries |
| `field` | required | The [field](/docs/types/field.md) to be flattened. |
| `on_error` | `send` | The behavior of the operator if it encounters an error. See [on_error](/docs/types/on_error.md) |
| `if` | | An [expression](/docs/types/expression.md) that, when set, will be evaluated to determine whether this operator should be used for the given entry. This allows you to do easy conditional parsing without branching logic with routers. |

Example usage:

<hr>
Flatten an object to the base of the record
<br>
<br>

```yaml
- type: flatten
field: key1
```
<table>
<tr><td> Input Entry </td> <td> Output Entry </td></tr>
<tr>
<td>
```json
{
"resource": { },
"labels": { },
"record": {
"key1": {
"nested1": "nestedval1",
"nested2": "nestedval2"
},
"key2": "val2"
}
}
```

</td>
<td>

```json
{
"resource": { },
"labels": { },
"record": {
"nested1": "nestedval1",
"nested2": "nestedval2",
"key2": "val2"
}
}
```

</td>
</tr>
</table>

<hr>
Flatten an object within another object
<br>
<br>

```yaml
- type: flatten
field: wrapper.key1
```
<table>
<tr><td> Input Entry </td> <td> Output Entry </td></tr>
<tr>
<td>
```json
{
"resource": { },
"labels": { },
"record": {
"wrapper": {
"key1": {
"nested1": "nestedval1",
"nested2": "nestedval2"
},
"key2": "val2"
}
}
}
```

</td>
<td>

```json
{
"resource": { },
"labels": { },
"record": {
"wrapper": {
"nested1": "nestedval1",
"nested2": "nestedval2",
"key2": "val2"
}
}
}
```

</td>
</tr>
</table>
35 changes: 19 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
module github.com/observiq/stanza

go 1.14
go 1.14

require (
github.com/antonmedv/expr v1.8.9
github.com/Azure/azure-event-hubs-go/v3 v3.3.7
github.com/antonmedv/expr v1.8.2
github.com/bmatcuk/doublestar/v2 v2.0.4
github.com/cenkalti/backoff/v4 v4.1.0
github.com/cenkalti/backoff/v4 v4.0.2
github.com/json-iterator/go v1.1.10
github.com/kr/text v0.2.0 // indirect
github.com/mitchellh/mapstructure v1.4.1
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/observiq/ctimefmt v1.0.0
github.com/observiq/nanojack v0.0.0-20201106172433-343928847ebc
github.com/stretchr/objx v0.3.0 // indirect
github.com/stretchr/testify v1.7.0
go.etcd.io/bbolt v1.3.5
go.uber.org/zap v1.16.0
golang.org/x/exp v0.0.0-20210417010653-0739314eea07 // indirect
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20210423082822-04245dca01da // indirect
golang.org/x/text v0.3.6
gonum.org/v1/gonum v0.9.1
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v2 v2.4.0
honnef.co/go/tools v0.1.3 // indirect
github.com/stretchr/testify v1.6.1
go.etcd.io/bbolt v1.3.4
go.uber.org/zap v1.15.0
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6 // indirect
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211 // indirect
golang.org/x/text v0.3.3
golang.org/x/tools v0.0.0-20200904185747-39188db58858 // indirect
gonum.org/v1/gonum v0.6.2
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/yaml.v2 v2.3.0
honnef.co/go/tools v0.0.1-2020.1.5 // indirect
)
Loading

0 comments on commit 9fbaace

Please sign in to comment.