Document and add support to input plugins for logging alias (#6357)

This commit is contained in:
Greg
2019-09-23 16:39:50 -06:00
committed by Daniel Nelson
parent e42d2e39c6
commit 817c9a69a9
111 changed files with 961 additions and 659 deletions

View File

@@ -6,7 +6,6 @@ import (
"encoding/base64"
"encoding/json"
"io/ioutil"
"log"
"net"
"net/http"
"sync"
@@ -33,6 +32,7 @@ type PubSubPush struct {
WriteTimeout internal.Duration
MaxBodySize internal.Size
AddMeta bool
Log telegraf.Logger
MaxUndeliveredMessages int `toml:"max_undelivered_messages"`
@@ -227,21 +227,21 @@ func (p *PubSubPush) serveWrite(res http.ResponseWriter, req *http.Request) {
var payload Payload
if err = json.Unmarshal(bytes, &payload); err != nil {
log.Printf("E! [inputs.cloud_pubsub_push] Error decoding payload %s", err.Error())
p.Log.Errorf("Error decoding payload %s", err.Error())
res.WriteHeader(http.StatusBadRequest)
return
}
sDec, err := base64.StdEncoding.DecodeString(payload.Msg.Data)
if err != nil {
log.Printf("E! [inputs.cloud_pubsub_push] Base64-Decode Failed %s", err.Error())
p.Log.Errorf("Base64-decode failed %s", err.Error())
res.WriteHeader(http.StatusBadRequest)
return
}
metrics, err := p.Parse(sDec)
if err != nil {
log.Println("D! [inputs.cloud_pubsub_push] " + err.Error())
p.Log.Debug(err.Error())
res.WriteHeader(http.StatusBadRequest)
return
}
@@ -295,7 +295,7 @@ func (p *PubSubPush) receiveDelivered() {
ch <- true
} else {
ch <- false
log.Println("D! [inputs.cloud_pubsub_push] Metric group failed to process")
p.Log.Debug("Metric group failed to process")
}
}
}

View File

@@ -18,6 +18,7 @@ import (
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/internal/models"
"github.com/influxdata/telegraf/plugins/parsers"
"github.com/influxdata/telegraf/testutil"
)
func TestServeHTTP(t *testing.T) {
@@ -118,6 +119,7 @@ func TestServeHTTP(t *testing.T) {
rr := httptest.NewRecorder()
pubPush := &PubSubPush{
Log: testutil.Logger{},
Path: "/",
MaxBodySize: internal.Size{
Size: test.maxsize,