feat(alerting): make it possible to skip ssl verification for alerting https requests

This commit is contained in:
bergquist 2016-09-08 16:29:31 +02:00
parent 7b9099ef93
commit aa80b52c07
4 changed files with 23 additions and 6 deletions

View File

@ -387,6 +387,9 @@ global_session = -1
[alerting]
enabled = true
# Skip ssl validation for queries sent to the timeserie database.
skip_ssl_validation = false
#################################### Internal Grafana Metrics ##########################
# Metrics available at HTTP API Url /api/metrics
[metrics]

View File

@ -333,6 +333,9 @@ check_for_updates = true
[alerting]
;enabled = false
# Skip ssl validation for queries sent to the timeserie database.
;skip_ssl_validation = false
#################################### Internal Grafana Metrics ##########################
# Metrics available at HTTP API Url /api/metrics
[metrics]

View File

@ -141,7 +141,8 @@ var (
Quota QuotaSettings
// Alerting
AlertingEnabled bool
AlertingEnabled bool
AlertingSkipSSLValidation bool
// logger
logger log.Logger
@ -546,6 +547,7 @@ func NewConfigContext(args *CommandLineArgs) error {
alerting := Cfg.Section("alerting")
AlertingEnabled = alerting.Key("enabled").MustBool(false)
AlertingSkipSSLValidation = alerting.Key("skip_ssl_validation").MustBool(false)
readSessionConfig()
readSmtpSettings()

View File

@ -1,6 +1,7 @@
package graphite
import (
"crypto/tls"
"encoding/json"
"fmt"
"io/ioutil"
@ -15,10 +16,6 @@ import (
"github.com/grafana/grafana/pkg/tsdb"
)
var (
HttpClient = http.Client{Timeout: time.Duration(10 * time.Second)}
)
type GraphiteExecutor struct {
*tsdb.DataSourceInfo
}
@ -27,11 +24,23 @@ func NewGraphiteExecutor(dsInfo *tsdb.DataSourceInfo) tsdb.Executor {
return &GraphiteExecutor{dsInfo}
}
var glog log.Logger
var (
glog log.Logger
HttpClient http.Client
)
func init() {
glog = log.New("tsdb.graphite")
tsdb.RegisterExecutor("graphite", NewGraphiteExecutor)
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: setting.AlertingSkipSSLValidation},
}
HttpClient = http.Client{
Timeout: time.Duration(10 * time.Second),
Transport: tr,
}
}
func (e *GraphiteExecutor) Execute(queries tsdb.QuerySlice, context *tsdb.QueryContext) *tsdb.BatchResult {