forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from influxdata/bsmaldon-strings
Use processor conventions from influxdata#4616
- Loading branch information
Showing
4 changed files
with
568 additions
and
282 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,83 @@ | ||
# Strings Processor Plugin | ||
|
||
The `strings` plugin maps certain go string functions onto tag and field values. If `result_key` parameter is present, it can produce new tags and fields from existing ones. | ||
The `strings` plugin maps certain go string functions onto measurement, tag, and field values. Values can be modified in place or stored in another key. | ||
|
||
Implemented functions are: Lowercase, Uppercase, Trim, TrimPrefix, TrimSuffix, TrimRight, TrimLeft | ||
Implemented functions are: | ||
- lowercase | ||
- uppercase | ||
- trim | ||
- trim_left | ||
- trim_right | ||
- trim_prefix | ||
- trim_suffix | ||
|
||
Please note that in this implementation these are processed in the order that they appear above. | ||
|
||
Specify the `tag` or `field` that you want processed in each section and optionally a `result_key` if you want the result stored in a new tag or field. You can specify lots of transformations on data with a single strings processor. Certain functions require an `argument` field to specify how they should process their throughput. | ||
|
||
Functions that require an `argument` are: Trim, TrimPrefix, TrimSuffix, TrimRight, TrimLeft | ||
Specify the `measurement`, `tag` or `field` that you want processed in each section and optionally a `dest` if you want the result stored in a new tag or field. You can specify lots of transformations on data with a single strings processor. | ||
|
||
### Configuration: | ||
|
||
```toml | ||
[[processors.strings]] | ||
namepass = ["uri_stem"] | ||
# [[processors.strings.uppercase]] | ||
# tag = "method" | ||
|
||
# Tag and field conversions defined in a separate sub-tables | ||
[[processors.strings.lowercase]] | ||
## Tag to change | ||
tag = "uri_stem" | ||
# [[processors.strings.lowercase]] | ||
# field = "uri_stem" | ||
# dest = "uri_stem_normalised" | ||
|
||
[[processors.strings.lowercase]] | ||
## Multiple tags or fields may be defined | ||
tag = "method" | ||
## Convert a tag value to lowercase | ||
# [[processors.strings.trim]] | ||
# field = "message" | ||
|
||
[[processors.strings.uppercase]] | ||
key = "cs-host" | ||
result_key = "cs-host_normalised" | ||
# [[processors.strings.trim_left]] | ||
# field = "message" | ||
# cutset = "\t" | ||
|
||
# [[processors.strings.trim_right]] | ||
# field = "message" | ||
# cutset = "\r\n" | ||
|
||
[[processors.strings.trimprefix]] | ||
tag = "uri_stem" | ||
argument = "/api/" | ||
# [[processors.strings.trim_prefix]] | ||
# field = "my_value" | ||
# prefix = "my_" | ||
|
||
# [[processors.strings.trim_suffix]] | ||
# field = "read_count" | ||
# suffix = "_count" | ||
``` | ||
|
||
### Tags: | ||
#### Trim, TrimLeft, TrimRight | ||
|
||
The `trim`, `trim_left`, and `trim_right` functions take an optional parameter: `cutset`. This value is a string containing the characters to remove from the value. | ||
|
||
No tags are applied by this processor. | ||
#### TrimPrefix, TrimSuffix | ||
|
||
### Example Input: | ||
The `trim_prefix` and `trim_suffix` functions remote the given `prefix` or `suffix` | ||
respectively from the string. | ||
|
||
### Example | ||
**Config** | ||
```toml | ||
[[processors.strings]] | ||
[[processors.strings.lowercase]] | ||
field = "uri-stem" | ||
|
||
[[processors.strings.trim_prefix]] | ||
field = "uri_stem" | ||
prefix = "/api/" | ||
|
||
[[processors.strings.uppercase]] | ||
field = "cs-host" | ||
dest = "cs-host_normalised" | ||
``` | ||
|
||
**Input** | ||
``` | ||
iis_log,method=get,uri_stem=/API/HealthCheck cs-host="MIXEDCASE_host",referrer="-",ident="-",http_version=1.1,agent="UserAgent",resp_bytes=270i 1519652321000000000 | ||
``` | ||
### Example Output: | ||
|
||
**Output** | ||
``` | ||
iis_log,method=get,uri_stem=healthcheck cs-host="MIXEDCASE_host",cs-host_normalised="MIXEDCASE_HOST",referrer="-",ident="-",http_version=1.1,agent="UserAgent",resp_bytes=270i 1519652321000000000 | ||
``` |
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
Oops, something went wrong.