Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
telegraf-nftables
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Due to inactivity, this project is scheduled to be deleted on 2035-04-24.
Why is this scheduled?
Show more breadcrumbs
vqgroup
telegraf-nftables
Commits
78f544c0
Commit
78f544c0
authored
8 years ago
by
Cameron Sparr
Browse files
Options
Downloads
Patches
Plain Diff
Support --aggregator-filter & --processor-filter
parent
2175a72f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/telegraf/telegraf.go
+28
-4
28 additions, 4 deletions
cmd/telegraf/telegraf.go
internal/config/config.go
+24
-11
24 additions, 11 deletions
internal/config/config.go
with
52 additions
and
15 deletions
cmd/telegraf/telegraf.go
+
28
−
4
View file @
78f544c0
...
...
@@ -42,6 +42,10 @@ var fOutputFilters = flag.String("output-filter", "",
"filter the outputs to enable, separator is :"
)
var
fOutputList
=
flag
.
Bool
(
"output-list"
,
false
,
"print available output plugins."
)
var
fAggregatorFilters
=
flag
.
String
(
"aggregator-filter"
,
""
,
"filter the aggregators to enable, separator is :"
)
var
fProcessorFilters
=
flag
.
String
(
"processor-filter"
,
""
,
"filter the processors to enable, separator is :"
)
var
fUsage
=
flag
.
String
(
"usage"
,
""
,
"print usage for a plugin, ie, 'telegraf -usage mysql'"
)
var
fService
=
flag
.
String
(
"service"
,
""
,
...
...
@@ -78,9 +82,9 @@ The flags are:
-sample-config print out full sample configuration to stdout
-config-directory directory containing additional *.conf files
-input-filter filter the input plugins to enable, separator is :
-input-list print all the plugins inputs
-output-filter filter the output plugins to enable, separator is :
-output-list print all the available outputs
-aggregator-filter filter the aggregator plugins to enable, separator is :
-processor-filter filter the processor plugins to enable, separator is :
-usage print usage for a plugin, ie, 'telegraf -usage mysql'
-debug print metrics as they're generated to stdout
-quiet run in quiet mode
...
...
@@ -143,6 +147,16 @@ func reloadLoop(stop chan struct{}, s service.Service) {
outputFilter
:=
strings
.
TrimSpace
(
*
fOutputFilters
)
outputFilters
=
strings
.
Split
(
":"
+
outputFilter
+
":"
,
":"
)
}
var
aggregatorFilters
[]
string
if
*
fAggregatorFilters
!=
""
{
aggregatorFilter
:=
strings
.
TrimSpace
(
*
fAggregatorFilters
)
aggregatorFilters
=
strings
.
Split
(
":"
+
aggregatorFilter
+
":"
,
":"
)
}
var
processorFilters
[]
string
if
*
fProcessorFilters
!=
""
{
processorFilter
:=
strings
.
TrimSpace
(
*
fProcessorFilters
)
processorFilters
=
strings
.
Split
(
":"
+
processorFilter
+
":"
,
":"
)
}
if
len
(
args
)
>
0
{
switch
args
[
0
]
{
...
...
@@ -150,7 +164,12 @@ func reloadLoop(stop chan struct{}, s service.Service) {
fmt
.
Printf
(
"Telegraf v%s (git: %s %s)
\n
"
,
version
,
branch
,
commit
)
return
case
"config"
:
config
.
PrintSampleConfig
(
inputFilters
,
outputFilters
)
config
.
PrintSampleConfig
(
inputFilters
,
outputFilters
,
aggregatorFilters
,
processorFilters
,
)
return
}
}
...
...
@@ -173,7 +192,12 @@ func reloadLoop(stop chan struct{}, s service.Service) {
fmt
.
Printf
(
"Telegraf v%s (git: %s %s)
\n
"
,
version
,
branch
,
commit
)
return
case
*
fSampleConfig
:
config
.
PrintSampleConfig
(
inputFilters
,
outputFilters
)
config
.
PrintSampleConfig
(
inputFilters
,
outputFilters
,
aggregatorFilters
,
processorFilters
,
)
return
case
*
fUsage
!=
""
:
if
err
:=
config
.
PrintInputConfig
(
*
fUsage
);
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
internal/config/config.go
+
24
−
11
View file @
78f544c0
...
...
@@ -284,7 +284,12 @@ var serviceInputHeader = `
`
// PrintSampleConfig prints the sample config
func
PrintSampleConfig
(
inputFilters
[]
string
,
outputFilters
[]
string
)
{
func
PrintSampleConfig
(
inputFilters
[]
string
,
outputFilters
[]
string
,
aggregatorFilters
[]
string
,
processorFilters
[]
string
,
)
{
fmt
.
Printf
(
header
)
// print output plugins
...
...
@@ -305,21 +310,29 @@ func PrintSampleConfig(inputFilters []string, outputFilters []string) {
// print processor plugins
fmt
.
Printf
(
processorHeader
)
pnames
:=
[]
string
{}
for
pname
:=
range
processors
.
Processors
{
pnames
=
append
(
pnames
,
pname
)
if
len
(
processorFilters
)
!=
0
{
printFilteredProcessors
(
processorFilters
,
false
)
}
else
{
pnames
:=
[]
string
{}
for
pname
:=
range
processors
.
Processors
{
pnames
=
append
(
pnames
,
pname
)
}
sort
.
Strings
(
pnames
)
printFilteredProcessors
(
pnames
,
true
)
}
sort
.
Strings
(
pnames
)
printFilteredProcessors
(
pnames
,
true
)
// pring aggregator plugins
fmt
.
Printf
(
aggregatorHeader
)
pnames
=
[]
string
{}
for
pname
:=
range
aggregators
.
Aggregators
{
pnames
=
append
(
pnames
,
pname
)
if
len
(
aggregatorFilters
)
!=
0
{
printFilteredAggregators
(
aggregatorFilters
,
false
)
}
else
{
pnames
:=
[]
string
{}
for
pname
:=
range
aggregators
.
Aggregators
{
pnames
=
append
(
pnames
,
pname
)
}
sort
.
Strings
(
pnames
)
printFilteredAggregators
(
pnames
,
true
)
}
sort
.
Strings
(
pnames
)
printFilteredAggregators
(
pnames
,
true
)
// print input plugins
fmt
.
Printf
(
inputHeader
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment