-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce datasources in package to configure inputs and streams (#212)
In elastic/beats#15940 datasources, inputs and streams are introduced into the agent config. To make it possible to configure these in the UI and through the API, some changes to the manifest definitions of a package and datasets are needed. **Package manifest** Each package must specify the datasources it supports with the supported inputs inside. So far all the packages only support one datasource but I want to keep the door open for this to potentially change in the future. It also makes it possible to have the manifest config of a datasource be identical to the config which ends up in the agent config. The package manifest datasource definition looks as following (nginx example): ``` datasources: - # Do we need a name for the data source? name: nginx # List of inputs this datasource supports inputs: - # An id can be given, in case the type used here is not unique # This is for selection in the stream # id: nginx type: metrics/nginx # Common configuration options for this input vars: - name: hosts description: Nginx hosts default: ["http://127.0.0.1"] # All the config options that are required should be shown in the UI required: true - name: period description: "Collection period. Valid values: 10s, 5m, 2h" default: "10s" - name: username type: text - name: password # This is the html input type? type: password - type: logs # Common configuration options for this input vars: - type: syslog # Common configuration options for this input vars: ``` Inside the datasource, the supported inputs are specified with the common variables across all streams which use a certain input. In the UI I expect that we show the `required` configs by default and all the others are under "Advanced" or similar. **Dataset manifest** With the datasources and inputs defined on the package level, each dataset can specify which inputs it supports. Most datasets will only support one input for now. For the nginx metrics this looks as following: ``` inputs: - type: "metric/nginx" # Only the variables have to be repeated that are not specified as part of the input vars: # All variables are specified in the input already ``` As an example with supporting multiple inputs, we have the nginx error logs: ``` inputs: - type: log vars: - name: paths required: true default: - /var/log/nginx/error.log* os.darwin: - /usr/local/var/log/nginx/error.log* os.windows: - c:/programdata/nginx/logs/error.log* - type: syslog vars: # Are udp and tcp syslog input two different inputs? - name: protocol.udp.host required: true default: - "localhost:9000" ``` The log and syslog input are supported (not the case today, just an example). One the dataset level also all additional variables for this dataset are specified. The ones already specified on the input level in the package don't have to be specified again. **Stream definition** Now that the dataset has its supported inputs and variables defined, the stream can be defined. The stream defines which input it uses from the dataset and its configuration variables. Here an example for nginx metrics: ``` input: metrics/nginx metricsets: ["stubstatus"] period: {{period}} enabled: true hosts: {{hosts}} {{#if username}} username: "{{username}}" {{/if}} {{#if password}} password: "{{password}}" {{/if}} ``` During creation time of the stream config the variables from the datasource inputs and local variables from the dataset are filled in. A stream definition could also support multiple inputs as seen in the following example: ``` {{#if input == log}} input: log {{#each paths}} paths: "{{this}}" {{/each}} exclude_files: [".gz$"] processors: - add_locale: ~ {{/if}} {{#if input == syslog}} input: syslog {{/if}} ``` **Further changes** * Rename `agent/input` to `agent/stream` as a stream is configured there.
- Loading branch information
Showing
18 changed files
with
157 additions
and
64 deletions.
There are no files selected for viewing
12 changes: 0 additions & 12 deletions
12
dev/package-examples/nginx-1.2.0/dataset/access/agent/input/input.yml
This file was deleted.
Oops, something went wrong.
8 changes: 5 additions & 3 deletions
8
....2.0/dataset/error/agent/config/input.yml → ....0/dataset/access/agent/stream/stream.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
dev/package-examples/nginx-1.2.0/dataset/error/agent/stream/stream.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
# The selected input has to be passed to the stream config when processed. | ||
|
||
{{#if input == log}} | ||
input: log | ||
|
||
{{#each paths}} | ||
paths: "{{this}}" | ||
{{/each}} | ||
exclude_files: [".gz$"] | ||
|
||
processors: | ||
- add_locale: ~ | ||
{{/if}} | ||
|
||
|
||
# This is an example stream config on how multiple inputs could be supported | ||
|
||
{{#if input == syslog}} | ||
input: syslog | ||
|
||
# TODO: would need some more config options | ||
{{/if}} |
34 changes: 26 additions & 8 deletions
34
dev/package-examples/nginx-1.2.0/dataset/error/manifest.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,29 @@ | ||
title: Nginx Error Logs | ||
type: logs | ||
ingest_pipeline: pipeline | ||
vars: | ||
- name: paths | ||
default: | ||
- /var/log/nginx/error.log* | ||
os.darwin: | ||
- /usr/local/var/log/nginx/error.log* | ||
os.windows: | ||
- c:/programdata/nginx/logs/error.log* | ||
|
||
|
||
# This is an example that multiple inputs are supported by one dataset | ||
inputs: | ||
- type: log | ||
vars: | ||
- name: paths | ||
required: true | ||
default: | ||
- /var/log/nginx/error.log* | ||
|
||
# TODO: The exact definition of os specific paths still needs to be defined | ||
os.darwin: | ||
- /usr/local/var/log/nginx/error.log* | ||
os.windows: | ||
- c:/programdata/nginx/logs/error.log* | ||
|
||
- type: syslog | ||
vars: | ||
# Are udp and tcp syslog input two different inputs? | ||
- name: protocol.udp.host | ||
required: true | ||
default: | ||
- "localhost:9000" | ||
|
||
|
3 changes: 2 additions & 1 deletion
3
.../dataset/stubstatus/agent/input/input.yml → ...ataset/stubstatus/agent/stream/stream.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
dev/package-examples/system-0.9.0/dataset/cpu/agent/input/input.yml
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
dev/package-examples/system-0.9.0/dataset/cpu/agent/stream/stream.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
input: metrics/system | ||
enabled: false # default true | ||
metricset: cpu | ||
period: 10s | ||
dataset: system.cpu | ||
metrics: ["percentages", "normalized_percentages"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ release: beta | |
# Needs to describe the type of this input | ||
type: metrics | ||
|
||
|
||
inputs: | ||
- type: metrics/system |
4 changes: 0 additions & 4 deletions
4
dev/package-examples/system-0.9.0/dataset/load/agent/input/input.yml
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
dev/package-examples/system-0.9.0/dataset/load/agent/stream/stream.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
inputy: metric/system | ||
enabled: true | ||
metricsets: | ||
- load |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ release: beta | |
# Needs to describe the type of this input | ||
type: metrics | ||
|
||
|
||
inputs: | ||
- type: system/metrics |
4 changes: 0 additions & 4 deletions
4
dev/package-examples/system-0.9.0/dataset/memory/agent/input/input.yml
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
dev/package-examples/system-0.9.0/dataset/memory/agent/stream.yml/stream.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
input: metric/system | ||
enabled: true | ||
metricsets: | ||
- memory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,6 @@ release: beta | |
# Needs to describe the type of this input | ||
type: metrics | ||
|
||
inputs: | ||
- type: system/metrics | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters