Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exec input with Graphite protocol support #637

Closed
wants to merge 11 commits into from

Conversation

henrypfhu
Copy link
Contributor

According to @sparrc suggestion, I combined the graphite feature into the exec plugin, and refactor the parser module into internal/encoding directory.

I open this new PR for exec plugin.

Old PR please refer to #627

@henrypfhu henrypfhu changed the title Add graphite protocol support to exec plugin, and refactor the telegraf mertic paser to the internal/encoding direcotry. exec input with Graphite protocol support Feb 3, 2016
@henrypfhu henrypfhu changed the title exec input with Graphite protocol support Exec input with Graphite protocol supportE Feb 3, 2016
@henrypfhu henrypfhu changed the title Exec input with Graphite protocol supportE Exec input with Graphite protocol support Feb 3, 2016
# the command to run
command = "/usr/bin/mycollector --foo=bar"
# Shell/commands array
commands = ["/tmp/test.sh","/tmp/test2.sh"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change. You'll need to change unit tests for this. Also exec should continue to support users that have the command = specified for backwards compatibility.

func (e *Exec) SampleConfig() string {
return sampleConfig
}

func (e *Exec) Description() string {
return "Read flattened metrics from one or more commands that output JSON to stdout"
return "Read metrics from one or more commands that output graphite line protocol to stdout"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also mention JSON, influx

return &Parser{graphiteParser: parser}
}

func (p *Parser) Parse(dataFormat string, out []byte, acc telegraf.Accumulator) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parse functions should not be specific to any plugin, just make two functions here with signatures:

func (p *Parser) Parse(dataFormat string, buf []byte) ([]telegraf.Metric, error)
func (p *Parser) ParseLine(dataFormat, line string) (telegraf.Metric, error)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and they should both support JSON, influx, and graphite

@sparrc
Copy link
Contributor

sparrc commented Feb 4, 2016

@henrypfhu This is looking very good so far, I like the structure I just have a few comments on the generic parser 👍

Since the graphite template parser was mostly taken from the influxdb repo, can you also add the unit tests from that repo? (you might need to remove a few of them because of the tags removal)

@@ -158,7 +158,9 @@ Currently implemented sources:
* disque
* docker
* elasticsearch
* exec (generic JSON-emitting executable plugin)
* exec (generic line-protocol-emitting executable plugin, support JSON, influx and graphite)
* socket (generic line protocol listen input service, support influx and graphite)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this PR doesn't include socket or tail

@henrypfhu
Copy link
Contributor Author

Hi @sparrc, from tomorrow I will be in vacation fro Chinese Spring Festival, these days I will be offline. Unit test cases will be postponed. Actually, I already tested all scenarios manually. So far I fixed all bugs I could found. Thx...

sparrc pushed a commit that referenced this pull request Feb 6, 2016
@sparrc
Copy link
Contributor

sparrc commented Feb 6, 2016

Thanks for the heads-up on your holiday time @henrypfhu, hope you enjoy it :-)

I squashed your commits into one and am now working on a new branch based off your changes (see #655). I'm going to close this PR because I have some ideas and changes that I would like to make on how the generic parsers feature is going to look, and it's also very relevant to an MQTT consumer plugin that I was coincidentally working on at the same time.

Thanks for your great work getting this started!

@sparrc sparrc closed this Feb 6, 2016
sparrc pushed a commit that referenced this pull request Feb 9, 2016
geodimm pushed a commit to miketonks/telegraf that referenced this pull request Mar 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants