Outputs enhancement to require Description and SampleConfig functions

Closes #142
This commit is contained in:
Cameron Sparr
2015-08-25 17:59:12 -06:00
parent ab4344a781
commit 8afbad93c6
5 changed files with 97 additions and 47 deletions

View File

@@ -21,6 +21,14 @@ type Datadog struct {
client *http.Client
}
var sampleConfig = `
# Datadog API key
apikey = "my-secret-key" # required.
# Connection timeout.
# timeout = "5s"
`
type TimeSeries struct {
Series []*Metric `json:"series"`
}
@@ -91,6 +99,14 @@ func (d *Datadog) Write(bp client.BatchPoints) error {
return nil
}
func (d *Datadog) SampleConfig() string {
return sampleConfig
}
func (d *Datadog) Description() string {
return "Configuration for DataDog API to send metrics to."
}
func (d *Datadog) authenticatedUrl() string {
q := url.Values{
"api_key": []string{d.Apikey},

View File

@@ -22,6 +22,25 @@ type InfluxDB struct {
conn *client.Client
}
var sampleConfig = `
# The full HTTP endpoint URL for your InfluxDB instance
url = "http://localhost:8086" # required.
# The target database for metrics. This database must already exist
database = "telegraf" # required.
# Connection timeout (for the connection with InfluxDB), formatted as a string.
# Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
# If not provided, will default to 0 (no timeout)
# timeout = "5s"
# username = "telegraf"
# password = "metricsmetricsmetricsmetrics"
# Set the user agent for the POSTs (can be useful for log differentiation)
# user_agent = "telegraf"
`
func (i *InfluxDB) Connect() error {
u, err := url.Parse(i.URL)
if err != nil {
@@ -57,6 +76,14 @@ func (i *InfluxDB) Close() error {
return nil
}
func (i *InfluxDB) SampleConfig() string {
return sampleConfig
}
func (i *InfluxDB) Description() string {
return "Configuration for influxdb server to send metrics to"
}
func (i *InfluxDB) Write(bp client.BatchPoints) error {
bp.Database = i.Database
if _, err := i.conn.Write(bp); err != nil {

View File

@@ -7,6 +7,8 @@ import (
type Output interface {
Connect() error
Close() error
Description() string
SampleConfig() string
Write(client.BatchPoints) error
}