This commit is contained in:
Ali Alrahahleh 2016-05-24 15:53:46 -07:00
parent 6f7dac6023
commit c35ab80893
2 changed files with 18 additions and 20 deletions

View File

@ -1,18 +1,18 @@
package graylog
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"strconv"
"bytes"
"regexp"
"io/ioutil"
"net/http"
"net/url"
"regexp"
"strconv"
"strings"
"sync"
"time"
"encoding/json"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal"
@ -222,7 +222,7 @@ func (h *GrayLog) gatherServer(
for k, v := range metric.Fields() {
re, _ := regexp.Compile(`metrics_([0-9]+)`)
match := re.FindAllStringSubmatch(k, -1)
if(match != nil) {
if match != nil {
i, _ := strconv.Atoi(match[0][1])
fields[name_list[i]] = v
}

View File

@ -244,15 +244,13 @@ func (h *HttpJson) sendRequest(serverURL string) (string, float64, error) {
}
}
// Create + send request
body := data.Encode()
body_attr := data.Get('__body')
body_attr := data.Get("__body")
http_body := data.Encode()
if body_attr != "" {
list := strings.Split(data.Encode(), '=')
body = list[1]
http_body = body_attr
}
req, err := http.NewRequest(h.Method, requestURL.String(),
strings.NewReader(body))
strings.NewReader(http_body))
if err != nil {
return "", -1, err
}