Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c039921e1 | ||
|
|
0ffa24c4b3 | ||
|
|
1734e97d58 | ||
|
|
6332ede542 | ||
|
|
2a9198cea6 | ||
|
|
1e95f9785c |
@@ -105,6 +105,7 @@
|
||||
- [#3648](https://github.com/influxdata/telegraf/issues/3648): Fix InfluxDB output not able to reconnect when server address changes.
|
||||
- [#3957](https://github.com/influxdata/telegraf/issues/3957): Fix parsing of dos line endings in the smart input.
|
||||
- [#3754](https://github.com/influxdata/telegraf/issues/3754): Fix precision truncation when no timestamp included.
|
||||
- [#3655](https://github.com/influxdata/telegraf/issues/3655): Fix SNMPv3 connection with Cisco ASA 5515 in snmp input.
|
||||
|
||||
## v1.5.3 [2018-03-14]
|
||||
|
||||
|
||||
2
Godeps
2
Godeps
@@ -70,7 +70,7 @@ github.com/shirou/gopsutil fc04d2dd9a512906a2604242b35275179e250eda
|
||||
github.com/shirou/w32 3c9377fc6748f222729a8270fe2775d149a249ad
|
||||
github.com/Shopify/sarama 3b1b38866a79f06deddf0487d5c27ba0697ccd65
|
||||
github.com/Sirupsen/logrus 61e43dc76f7ee59a82bdf3d71033dc12bea4c77d
|
||||
github.com/soniah/gosnmp 5ad50dc75ab389f8a1c9f8a67d3a1cd85f67ed15
|
||||
github.com/soniah/gosnmp f15472a4cd6f6ea7929e4c7d9f163c49f059924f
|
||||
github.com/StackExchange/wmi f3e2bae1e0cb5aef83e319133eabfee30013a4a5
|
||||
github.com/streadway/amqp 63795daa9a446c920826655f26ba31c81c860fd6
|
||||
github.com/stretchr/objx facf9a85c22f48d2f52f2380e4efce1768749a89
|
||||
|
||||
@@ -159,12 +159,18 @@ func NewHTTPClient(config *HTTPConfig) (*httpClient, error) {
|
||||
serializer = influx.NewSerializer()
|
||||
}
|
||||
|
||||
writeURL := makeWriteURL(
|
||||
writeURL, err := makeWriteURL(
|
||||
config.URL,
|
||||
database,
|
||||
config.RetentionPolicy,
|
||||
config.Consistency)
|
||||
queryURL := makeQueryURL(config.URL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
queryURL, err := makeQueryURL(config.URL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var transport *http.Transport
|
||||
switch config.URL.Scheme {
|
||||
@@ -399,7 +405,7 @@ func (c *httpClient) addHeaders(req *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
func makeWriteURL(loc *url.URL, db, rp, consistency string) string {
|
||||
func makeWriteURL(loc *url.URL, db, rp, consistency string) (string, error) {
|
||||
params := url.Values{}
|
||||
params.Set("db", db)
|
||||
|
||||
@@ -417,22 +423,26 @@ func makeWriteURL(loc *url.URL, db, rp, consistency string) string {
|
||||
u.Scheme = "http"
|
||||
u.Host = "127.0.0.1"
|
||||
u.Path = "/write"
|
||||
case "http":
|
||||
case "http", "https":
|
||||
u.Path = path.Join(u.Path, "write")
|
||||
default:
|
||||
return "", fmt.Errorf("unsupported scheme: %q", loc.Scheme)
|
||||
}
|
||||
u.RawQuery = params.Encode()
|
||||
return u.String()
|
||||
return u.String(), nil
|
||||
}
|
||||
|
||||
func makeQueryURL(loc *url.URL) string {
|
||||
func makeQueryURL(loc *url.URL) (string, error) {
|
||||
u := *loc
|
||||
switch u.Scheme {
|
||||
case "unix":
|
||||
u.Scheme = "http"
|
||||
u.Host = "127.0.0.1"
|
||||
u.Path = "/query"
|
||||
case "http":
|
||||
case "http", "https":
|
||||
u.Path = path.Join(u.Path, "query")
|
||||
default:
|
||||
return "", fmt.Errorf("unsupported scheme: %q", loc.Scheme)
|
||||
}
|
||||
return u.String()
|
||||
return u.String(), nil
|
||||
}
|
||||
|
||||
@@ -46,6 +46,17 @@ func TestHTTP_MinimalConfig(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestHTTP_UnsupportedScheme(t *testing.T) {
|
||||
config := &influxdb.HTTPConfig{
|
||||
URL: &url.URL{
|
||||
Scheme: "foo",
|
||||
Host: "localhost",
|
||||
},
|
||||
}
|
||||
_, err := influxdb.NewHTTPClient(config)
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
func TestHTTP_CreateDatabase(t *testing.T) {
|
||||
ts := httptest.NewServer(http.NotFoundHandler())
|
||||
defer ts.Close()
|
||||
@@ -576,9 +587,6 @@ func TestHTTP_UnixSocket(t *testing.T) {
|
||||
ts.Start()
|
||||
defer ts.Close()
|
||||
|
||||
x, _ := url.Parse("unix://" + sock)
|
||||
fmt.Println(x)
|
||||
|
||||
successResponse := []byte(`{"results": [{"statement_id": 0}]}`)
|
||||
|
||||
tests := []struct {
|
||||
|
||||
@@ -210,7 +210,7 @@ func (i *InfluxDB) Write(metrics []telegraf.Metric) error {
|
||||
}
|
||||
|
||||
switch apiError := err.(type) {
|
||||
case APIError:
|
||||
case *APIError:
|
||||
if !i.SkipDatabaseCreation {
|
||||
if apiError.Type == DatabaseNotFound {
|
||||
err := client.CreateDatabase(ctx)
|
||||
|
||||
@@ -2,11 +2,13 @@ package influxdb_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/internal"
|
||||
"github.com/influxdata/telegraf/metric"
|
||||
"github.com/influxdata/telegraf/plugins/outputs/influxdb"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -37,7 +39,7 @@ func (c *MockClient) CreateDatabase(ctx context.Context) error {
|
||||
func TestDeprecatedURLSupport(t *testing.T) {
|
||||
var actual *influxdb.UDPConfig
|
||||
output := influxdb.InfluxDB{
|
||||
URL: "udp://localhost:8086",
|
||||
URL: "udp://localhost:8089",
|
||||
|
||||
CreateUDPClientF: func(config *influxdb.UDPConfig) (influxdb.Client, error) {
|
||||
actual = config
|
||||
@@ -46,7 +48,7 @@ func TestDeprecatedURLSupport(t *testing.T) {
|
||||
}
|
||||
err := output.Connect()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "udp://localhost:8086", actual.URL.String())
|
||||
require.Equal(t, "udp://localhost:8089", actual.URL.String())
|
||||
}
|
||||
|
||||
func TestDefaultURL(t *testing.T) {
|
||||
@@ -70,7 +72,7 @@ func TestConnectUDPConfig(t *testing.T) {
|
||||
var actual *influxdb.UDPConfig
|
||||
|
||||
output := influxdb.InfluxDB{
|
||||
URLs: []string{"udp://localhost:8086"},
|
||||
URLs: []string{"udp://localhost:8089"},
|
||||
UDPPayload: 42,
|
||||
|
||||
CreateUDPClientF: func(config *influxdb.UDPConfig) (influxdb.Client, error) {
|
||||
@@ -81,7 +83,7 @@ func TestConnectUDPConfig(t *testing.T) {
|
||||
err := output.Connect()
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, "udp://localhost:8086", actual.URL.String())
|
||||
require.Equal(t, "udp://localhost:8089", actual.URL.String())
|
||||
require.Equal(t, 42, actual.MaxPayloadSize)
|
||||
require.NotNil(t, actual.Serializer)
|
||||
}
|
||||
@@ -90,7 +92,7 @@ func TestConnectHTTPConfig(t *testing.T) {
|
||||
var actual *influxdb.HTTPConfig
|
||||
|
||||
output := influxdb.InfluxDB{
|
||||
URLs: []string{"http://localhost:8089"},
|
||||
URLs: []string{"http://localhost:8086"},
|
||||
Database: "telegraf",
|
||||
RetentionPolicy: "default",
|
||||
WriteConsistency: "any",
|
||||
@@ -98,7 +100,7 @@ func TestConnectHTTPConfig(t *testing.T) {
|
||||
Username: "guy",
|
||||
Password: "smiley",
|
||||
UserAgent: "telegraf",
|
||||
HTTPProxy: "http://localhost:8089",
|
||||
HTTPProxy: "http://localhost:8086",
|
||||
HTTPHeaders: map[string]string{
|
||||
"x": "y",
|
||||
},
|
||||
@@ -133,3 +135,51 @@ func TestConnectHTTPConfig(t *testing.T) {
|
||||
|
||||
require.Equal(t, output.Database, actual.Database)
|
||||
}
|
||||
|
||||
func TestWriteRecreateDatabaseIfDatabaseNotFound(t *testing.T) {
|
||||
var createDatabaseCalled bool
|
||||
|
||||
output := influxdb.InfluxDB{
|
||||
URLs: []string{"http://localhost:8086"},
|
||||
|
||||
CreateHTTPClientF: func(config *influxdb.HTTPConfig) (influxdb.Client, error) {
|
||||
return &MockClient{
|
||||
CreateDatabaseF: func(ctx context.Context) error {
|
||||
createDatabaseCalled = true
|
||||
return nil
|
||||
},
|
||||
WriteF: func(ctx context.Context, metrics []telegraf.Metric) error {
|
||||
return &influxdb.APIError{
|
||||
StatusCode: http.StatusNotFound,
|
||||
Title: "404 Not Found",
|
||||
Description: `database not found "telegraf"`,
|
||||
Type: influxdb.DatabaseNotFound,
|
||||
}
|
||||
},
|
||||
URLF: func() string {
|
||||
return "http://localhost:8086"
|
||||
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
}
|
||||
|
||||
err := output.Connect()
|
||||
require.NoError(t, err)
|
||||
|
||||
m, err := metric.New(
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
"value": 42.0,
|
||||
},
|
||||
time.Unix(0, 0),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
metrics := []telegraf.Metric{m}
|
||||
|
||||
createDatabaseCalled = false
|
||||
err = output.Write(metrics)
|
||||
// We only have one URL, so we expect an error
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ supported_packages = {
|
||||
"freebsd": [ "tar" ]
|
||||
}
|
||||
|
||||
next_version = '1.5.0'
|
||||
next_version = '1.6.0'
|
||||
|
||||
################
|
||||
#### Telegraf Functions
|
||||
|
||||
Reference in New Issue
Block a user