Skip to content

Commit 75c91ff

Browse files
kalinonmlclmj
authored andcommitted
Added datasource prometheus values for json data (grafana#23)
* add missing fields for datasources * remove EsVersion * added test and corrected json syntax * Update datasource_test.go
1 parent 9cc848d commit 75c91ff

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ _testmain.go
2525

2626
# vim swap files
2727
.*.sw?
28+
.idea

datasource.go

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ type JSONData struct {
3737
CustomMetricsNamespaces string `json:"customMetricsNamespaces,omitempty"`
3838
DefaultRegion string `json:"defaultRegion,omitempty"`
3939
TlsSkipVerify bool `json:"tlsSkipVerify,omitempty"`
40+
HttpMethod string `json:"httpMethod,omitempty"`
41+
QueryTimeout string `json:"queryTimeout,omitempty"`
42+
TimeInterval string `json:"timeInterval,omitempty"`
4043
}
4144

4245
// SecureJSONData is a representation of the datasource `secureJsonData` property

datasource_test.go

+29
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,32 @@ func TestNewDataSource(t *testing.T) {
7373
t.Error("datasource creation response should return the created datasource ID")
7474
}
7575
}
76+
77+
func TestNewPrometheusDataSource(t *testing.T) {
78+
server, client := gapiTestTools(200, createdDataSourceJSON)
79+
defer server.Close()
80+
81+
ds := &DataSource{
82+
Name: "foo_prometheus",
83+
Type: "prometheus",
84+
URL: "http://some-url.com",
85+
Access: "access",
86+
IsDefault: true,
87+
JSONData: JSONData{
88+
HttpMethod: "POST",
89+
QueryTimeout: "60s",
90+
TimeInterval: "1m",
91+
},
92+
}
93+
94+
created, err := client.NewDataSource(ds)
95+
if err != nil {
96+
t.Error(err)
97+
}
98+
99+
t.Log(pretty.PrettyFormat(created))
100+
101+
if created != 1 {
102+
t.Error("datasource creation response should return the created datasource ID")
103+
}
104+
}

0 commit comments

Comments
 (0)