| 1 | package exporter |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | |
| 6 | "github.com/gomodule/redigo/redis" |
| 7 | "github.com/prometheus/client_golang/prometheus" |
| 8 | log "github.com/sirupsen/logrus" |
| 9 | ) |
| 10 | |
| 11 | func (e *Exporter) extractTile38Metrics(ch chan<- prometheus.Metric, c redis.Conn) { |
| 12 | info, err := redis.Strings(doRedisCmd(c, "SERVER", "EXT")) |
| 13 | if err != nil { |
| 14 | log.Errorf("extractTile38Metrics() err: %s", err) |
| 15 | return |
| 16 | } |
| 17 | |
| 18 | for i := 0; i+1 < len(info); i += 2 { |
| 19 | fieldKey := info[i] |
| 20 | if !strings.HasPrefix(fieldKey, "tile38_") { |
| 21 | fieldKey = "tile38_" + fieldKey |
| 22 | } |
| 23 | |
| 24 | fieldValue := info[i+1] |
| 25 | log.Debugf("tile38 key:%s val:%s", fieldKey, fieldValue) |
| 26 | |
| 27 | if !e.includeMetric(fieldKey) { |
| 28 | continue |
| 29 | } |
| 30 | |
| 31 | e.parseAndRegisterConstMetric(ch, fieldKey, fieldValue) |
| 32 | } |
| 33 | } |