Set content-type for mixed-in Prometheus results

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis
2017-10-29 08:59:52 +00:00
parent 85d3e2ba87
commit 8363532751
4 changed files with 109 additions and 6 deletions

View File

@ -14,6 +14,10 @@ type PrometheusQuery struct {
Client *http.Client
}
type PrometheusQueryFetcher interface {
Fetch(query string) (*VectorQueryResponse, error)
}
// NewPrometheusQuery create a NewPrometheusQuery
func NewPrometheusQuery(host string, port int, client *http.Client) PrometheusQuery {
return PrometheusQuery{
@ -24,7 +28,7 @@ func NewPrometheusQuery(host string, port int, client *http.Client) PrometheusQu
}
// Fetch queries aggregated stats
func (q *PrometheusQuery) Fetch(query string) (*VectorQueryResponse, error) {
func (q PrometheusQuery) Fetch(query string) (*VectorQueryResponse, error) {
req, reqErr := http.NewRequest("GET", fmt.Sprintf("http://%s:%d/api/v1/query/?query=%s", q.Host, q.Port, query), nil)
if reqErr != nil {