@@ -32,6 +32,13 @@ const (
32
32
engineInnodbStatusQuery = `SHOW ENGINE INNODB STATUS`
33
33
)
34
34
35
+ var (
36
+ // 0 queries inside InnoDB, 0 queries in queue
37
+ // 0 read views open inside InnoDB
38
+ queriesRe = regexp .MustCompile (`(\d+) queries inside InnoDB, (\d+) queries in queue` )
39
+ viewsRe = regexp .MustCompile (`(\d+) read views open inside InnoDB` )
40
+ )
41
+
35
42
// ScrapeEngineInnodbStatus scrapes from `SHOW ENGINE INNODB STATUS`.
36
43
type ScrapeEngineInnodbStatus struct {}
37
44
@@ -67,13 +74,8 @@ func (ScrapeEngineInnodbStatus) Scrape(ctx context.Context, instance *instance,
67
74
}
68
75
}
69
76
70
- // 0 queries inside InnoDB, 0 queries in queue
71
- // 0 read views open inside InnoDB
72
- rQueries , _ := regexp .Compile (`(\d+) queries inside InnoDB, (\d+) queries in queue` )
73
- rViews , _ := regexp .Compile (`(\d+) read views open inside InnoDB` )
74
-
75
77
for _ , line := range strings .Split (statusCol , "\n " ) {
76
- if data := rQueries .FindStringSubmatch (line ); data != nil {
78
+ if data := queriesRe .FindStringSubmatch (line ); data != nil {
77
79
value , _ := strconv .ParseFloat (data [1 ], 64 )
78
80
ch <- prometheus .MustNewConstMetric (
79
81
newDesc (innodb , "queries_inside_innodb" , "Queries inside InnoDB." ),
@@ -86,7 +88,7 @@ func (ScrapeEngineInnodbStatus) Scrape(ctx context.Context, instance *instance,
86
88
prometheus .GaugeValue ,
87
89
value ,
88
90
)
89
- } else if data := rViews .FindStringSubmatch (line ); data != nil {
91
+ } else if data := viewsRe .FindStringSubmatch (line ); data != nil {
90
92
value , _ := strconv .ParseFloat (data [1 ], 64 )
91
93
ch <- prometheus .MustNewConstMetric (
92
94
newDesc (innodb , "read_views_open_inside_innodb" , "Read views open inside InnoDB." ),
0 commit comments