Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Commit

Permalink
Added datasource prometheus values for json data (#23)
Browse files Browse the repository at this point in the history
* add missing fields for datasources

* remove EsVersion

* added test and corrected json syntax

* Update datasource_test.go
  • Loading branch information
kalinon authored and mlclmj committed Oct 10, 2019
1 parent 9cc848d commit 75c91ff
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ _testmain.go

# vim swap files
.*.sw?
.idea
3 changes: 3 additions & 0 deletions datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ type JSONData struct {
CustomMetricsNamespaces string `json:"customMetricsNamespaces,omitempty"`
DefaultRegion string `json:"defaultRegion,omitempty"`
TlsSkipVerify bool `json:"tlsSkipVerify,omitempty"`
HttpMethod string `json:"httpMethod,omitempty"`
QueryTimeout string `json:"queryTimeout,omitempty"`
TimeInterval string `json:"timeInterval,omitempty"`
}

// SecureJSONData is a representation of the datasource `secureJsonData` property
Expand Down
29 changes: 29 additions & 0 deletions datasource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,32 @@ func TestNewDataSource(t *testing.T) {
t.Error("datasource creation response should return the created datasource ID")
}
}

func TestNewPrometheusDataSource(t *testing.T) {
server, client := gapiTestTools(200, createdDataSourceJSON)
defer server.Close()

ds := &DataSource{
Name: "foo_prometheus",
Type: "prometheus",
URL: "http://some-url.com",
Access: "access",
IsDefault: true,
JSONData: JSONData{
HttpMethod: "POST",
QueryTimeout: "60s",
TimeInterval: "1m",
},
}

created, err := client.NewDataSource(ds)
if err != nil {
t.Error(err)
}

t.Log(pretty.PrettyFormat(created))

if created != 1 {
t.Error("datasource creation response should return the created datasource ID")
}
}

0 comments on commit 75c91ff

Please sign in to comment.