Merge branch 'master' into sql-proxy

This commit is contained in:
Torkel Ödegaard
2017-04-07 10:34:51 +02:00
48 changed files with 3422 additions and 32 deletions

View File

@@ -198,6 +198,9 @@ func LoadConfig() {
if DbCfg.Type == "sqlite3" {
UseSQLite3 = true
// only allow one connection as sqlite3 has multi threading issues that casue table locks
// DbCfg.MaxIdleConn = 1
// DbCfg.MaxOpenConn = 1
}
DbCfg.SslMode = sec.Key("ssl_mode").String()
DbCfg.CaCertPath = sec.Key("ca_cert_path").String()

View File

@@ -34,13 +34,18 @@ func (query *Query) Build(queryContext *tsdb.QueryContext) (string, error) {
return "", err
}
res = strings.Replace(res, "$timeFilter", query.renderTimeFilter(queryContext), 1)
res = strings.Replace(res, "$interval", interval.Text, 1)
res = strings.Replace(res, "$__interval_ms", strconv.FormatInt(interval.Value.Nanoseconds()/int64(time.Millisecond), 10), 1)
res = strings.Replace(res, "$__interval", interval.Text, 1)
res = replaceVariable(res, "$timeFilter", query.renderTimeFilter(queryContext))
res = replaceVariable(res, "$interval", interval.Text)
res = replaceVariable(res, "$__interval_ms", strconv.FormatInt(interval.Value.Nanoseconds()/int64(time.Millisecond), 10))
res = replaceVariable(res, "$__interval", interval.Text)
return res, nil
}
func replaceVariable(str string, variable string, value string) string {
count := strings.Count(str, variable)
return strings.Replace(str, variable, value, count)
}
func getDefinedInterval(query *Query, queryContext *tsdb.QueryContext) (*tsdb.Interval, error) {
defaultInterval := tsdb.CalculateInterval(queryContext.TimeRange)