add fillmode "last" to sql datasource

This adds a new fill mode last (last observation carried forward) for grafana
to the sql datasources. This fill mode will fill in the last seen value in a
series when a timepoint is missing or NULL if no value for that series has
been seen yet.
This commit is contained in:
Sven Klemm
2018-07-30 11:04:04 +02:00
parent 72af8a7044
commit bfc66a7ed0
13 changed files with 136 additions and 20 deletions

View File

@ -116,9 +116,13 @@ func (m *postgresMacroEngine) evaluateMacro(name string, args []string) (string,
if len(args) == 3 {
m.query.Model.Set("fill", true)
m.query.Model.Set("fillInterval", interval.Seconds())
if args[2] == "NULL" {
m.query.Model.Set("fillNull", true)
} else {
switch args[2] {
case "NULL":
m.query.Model.Set("fillMode", "null")
case "last":
m.query.Model.Set("fillMode", "last")
default:
m.query.Model.Set("fillMode", "value")
floatVal, err := strconv.ParseFloat(args[2], 64)
if err != nil {
return "", fmt.Errorf("error parsing fill value %v", args[2])