add lost tags

This commit is contained in:
Ulric Qin 2022-04-26 17:15:58 +08:00
parent 3ca8f7d5ab
commit 358a03807a
2 changed files with 7 additions and 4 deletions

View File

@ -8,6 +8,7 @@ import (
"strings" "strings"
"flashcat.cloud/categraf/inputs" "flashcat.cloud/categraf/inputs"
"flashcat.cloud/categraf/pkg/tagx"
"github.com/toolkits/pkg/container/list" "github.com/toolkits/pkg/container/list"
) )
@ -29,6 +30,8 @@ func (m *MySQL) gatherEngineInnodbStatus(slist *list.SafeList, ins *Instance, db
} }
} }
tags := tagx.Copy(globalTags)
// 0 queries inside InnoDB, 0 queries in queue // 0 queries inside InnoDB, 0 queries in queue
// 0 read views open inside InnoDB // 0 read views open inside InnoDB
rQueries, _ := regexp.Compile(`(\d+) queries inside InnoDB, (\d+) queries in queue`) rQueries, _ := regexp.Compile(`(\d+) queries inside InnoDB, (\d+) queries in queue`)
@ -40,19 +43,19 @@ func (m *MySQL) gatherEngineInnodbStatus(slist *list.SafeList, ins *Instance, db
if err != nil { if err != nil {
continue continue
} }
slist.PushFront(inputs.NewSample("engine_innodb_queries_inside_innodb", value)) slist.PushFront(inputs.NewSample("engine_innodb_queries_inside_innodb", value, tags))
value, err = strconv.ParseFloat(data[2], 64) value, err = strconv.ParseFloat(data[2], 64)
if err != nil { if err != nil {
continue continue
} }
slist.PushFront(inputs.NewSample("engine_innodb_queries_in_queue", value)) slist.PushFront(inputs.NewSample("engine_innodb_queries_in_queue", value, tags))
} else if data := rViews.FindStringSubmatch(line); data != nil { } else if data := rViews.FindStringSubmatch(line); data != nil {
value, err := strconv.ParseFloat(data[1], 64) value, err := strconv.ParseFloat(data[1], 64)
if err != nil { if err != nil {
continue continue
} }
slist.PushFront(inputs.NewSample("engine_innodb_read_views_open_inside_innodb", value)) slist.PushFront(inputs.NewSample("engine_innodb_read_views_open_inside_innodb", value, tags))
} }
} }
} }

View File

@ -133,7 +133,7 @@ func (m *MySQL) gatherGlobalStatus(slist *list.SafeList, ins *Instance, db *sql.
if evsParsingSuccess { if evsParsingSuccess {
for _, v := range evsMap { for _, v := range evsMap {
slist.PushFront(inputs.NewSample("galera_evs_repl_latency_"+v.name, v.value)) slist.PushFront(inputs.NewSample("galera_evs_repl_latency_"+v.name, v.value, tags))
} }
} }
} }