Skip to content

Commit 1e0fa78

Browse files
author
Joseph Sirianni
authored
resolve an issue where cmd/stanza package tests are pointing to an invalid examples directory (#538)
1 parent 7065476 commit 1e0fa78

File tree

6 files changed

+125
-4
lines changed

6 files changed

+125
-4
lines changed

cmd/stanza/example_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ func TestTomcatExample(t *testing.T) {
3535
if runtime.GOOS == "windows" {
3636
t.Skip("Skipping on windows because of service failures")
3737
}
38-
err := os.Chdir("../../examples/tomcat")
38+
err := os.Chdir("testdata/tomcat")
3939
require.NoError(t, err)
4040
defer func() {
41-
err := os.Chdir("../../cmd/stanza")
41+
err := os.Chdir("../../../../cmd/stanza")
4242
require.NoError(t, err)
4343
}()
4444

@@ -87,10 +87,10 @@ func TestSimplePluginsExample(t *testing.T) {
8787
if runtime.GOOS == "windows" {
8888
t.Skip("Skipping on windows because of service failures")
8989
}
90-
err := os.Chdir("../../examples/simple_plugins")
90+
err := os.Chdir("testdata/simple_plugins")
9191
require.NoError(t, err)
9292
defer func() {
93-
err := os.Chdir("../../cmd/stanza")
93+
err := os.Chdir("../../../../cmd/stanza")
9494
require.NoError(t, err)
9595
}()
9696

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This example configuration uses two plugins that are defined
2+
# in the ./plugins directory. See those files for details
3+
pipeline:
4+
# repeater is a plugin defined by ./plugins/repeater.yaml
5+
- type: repeater
6+
7+
# decorator is a plugin defined by ./plugins/decorator.yaml
8+
# It adds the label "decorated" to each entry that passes through
9+
# it with the value specified here
10+
- type: decorator
11+
value: my_decorated_value
12+
13+
- type: stdout
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: 0.0.0
2+
title: Decorator
3+
description: A decorator plugin
4+
parameters:
5+
- name: value
6+
label: Value
7+
description: A value to decorate the entries
8+
type: string
9+
required: true
10+
11+
# This plugin is registered as the type 'decorator'.
12+
# The type comes from the filename.
13+
# It take any entries sent to it, and add the label
14+
# 'decorated' to those entries with a value specified
15+
# by the argument 'value' in the top-level pipeline
16+
pipeline:
17+
# The input parameter is replaced with the ID of the
18+
# operator in the top-level config so that the plugin
19+
# graph can be connected properly.
20+
- id: {{ .input }}
21+
type: metadata
22+
labels:
23+
# The value parameter comes from the configuration
24+
# of the plugin in the top-level config
25+
decorated: {{ .value }}
26+
# The output is parameterized with go templates
27+
# so that it can use the output that is configured for the
28+
# plugin in the top-level pipeline
29+
output: {{ .output }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This plugin is registered as the type 'repeater'.
2+
# The type comes from the filename.
3+
# It will generate exactly 5 entries with the same
4+
# timestamp and the content "test record"
5+
pipeline:
6+
- type: generate_input
7+
static: true
8+
entry:
9+
timestamp: "2006-01-02T15:04:05Z"
10+
record: "test record"
11+
count: 5
12+
# The output is parameterized with go templates
13+
# so that it can use the output that is configured for the
14+
# plugin in the top-level pipeline
15+
output: {{ .output }}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
10.66.2.46 - - [13/Mar/2019:10:43:00 -0400] "GET / HTTP/1.1" 404 -
2+
10.66.2.46 - - [13/Mar/2019:10:43:01 -0400] "GET /favicon.ico HTTP/1.1" 404 -
3+
10.66.2.46 - - [13/Mar/2019:10:43:08 -0400] "GET /manager HTTP/1.1" 302 -
4+
10.66.2.46 - - [13/Mar/2019:10:43:08 -0400] "GET /manager/ HTTP/1.1" 403 3420
5+
10.66.2.46 - - [13/Mar/2019:11:00:26 -0400] "GET /manager/html HTTP/1.1" 401 2473
6+
10.66.2.46 - tomcat [13/Mar/2019:11:00:53 -0400] "GET /manager/html HTTP/1.1" 200 11936
7+
10.66.2.46 - - [13/Mar/2019:11:00:53 -0400] "GET /manager/images/asf-logo.svg HTTP/1.1" 200 19698
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
pipeline:
3+
4+
# Read lines from Apache Tomcat access logs
5+
# Example input line:
6+
# 10.66.2.46 - - [13/Mar/2019:10:43:00 -0400] "GET / HTTP/1.1" 404 -
7+
- type: file_input
8+
start_at: beginning
9+
include:
10+
- ./access.log
11+
labels:
12+
log_type: tomcat
13+
14+
# Parse the logs into labeled fields
15+
# Example input:
16+
# {
17+
# "timestamp": "2020-06-13T11:00:53-04:00",
18+
# "record": "10.66.2.46 - - [13/Mar/2019:10:43:00 -0400] "GET / HTTP/1.1" 404 -"
19+
# }
20+
- type: regex_parser
21+
regex: >-
22+
(?P<remote_host>[^\s]+)
23+
-
24+
(?P<remote_user>[^\s]+)
25+
\[(?P<timestamp>[^\]]+)\]
26+
"(?P<http_method>[A-Z]+)
27+
(?P<url_path>[^\s]+)[^"]*"
28+
(?P<http_status>\d+)
29+
(?P<bytes_sent>[\d-]+)
30+
timestamp:
31+
parse_from: timestamp
32+
layout: '%d/%b/%Y:%H:%M:%S %z'
33+
severity:
34+
parse_from: http_status
35+
preserve_to: http_status
36+
mapping:
37+
error: "4xx"
38+
info:
39+
- min: 300
40+
max: 399
41+
debug: 200
42+
43+
# Write the log to stdout
44+
# Example input:
45+
# {
46+
# "timestamp": "2019-03-13T11:00:53-04:00",
47+
# "severity": 60,
48+
# "record": {
49+
# "bytes_sent": "19698",
50+
# "http_method": "GET",
51+
# "http_status": "200",
52+
# "remote_host": "10.66.2.46",
53+
# "remote_user": "-",
54+
# "url_path": "/manager/images/asf-logo.svg"
55+
# }
56+
# }
57+
- type: stdout

0 commit comments

Comments
 (0)