| 1 | package exporterscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/ |
| 2 | |
| 3 | import ( |
| 4 | "github.com/gomodule/redigo/redisscip-go gomod github.com/gomodule/redigo v1.9.3 `github.com/gomodule/redigo/redis`/" |
| 5 | "github.com/prometheus/client_golang/prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/" |
| 6 | ) |
| 7 | |
| 8 | func (e *Exporterscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#) extractSlowLogMetricsscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#extractSlowLogMetrics().(ch chan<- prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.Metricscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/Metric#, c redisscip-go gomod github.com/gomodule/redigo v1.9.3 `github.com/gomodule/redigo/redis`/.Connscip-go gomod github.com/gomodule/redigo v1.9.3 `github.com/gomodule/redigo/redis`/Conn#) { |
| 9 | if reply, err := redisscip-go gomod github.com/gomodule/redigo v1.9.3 `github.com/gomodule/redigo/redis`/.Int64scip-go gomod github.com/gomodule/redigo v1.9.3 `github.com/gomodule/redigo/redis`/Int64().(doRedisCmdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/doRedisCmd().(c, "SLOWLOG", "LEN")); err == nil { |
| 10 | e.registerConstMetricGaugescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#registerConstMetricGauge().(ch, "slowlog_length", float64(reply)) |
| 11 | } |
| 12 | |
| 13 | values, err := redisscip-go gomod github.com/gomodule/redigo v1.9.3 `github.com/gomodule/redigo/redis`/.Valuesscip-go gomod github.com/gomodule/redigo v1.9.3 `github.com/gomodule/redigo/redis`/Values().(doRedisCmdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/doRedisCmd().(c, "SLOWLOG", "GET", "1")) |
| 14 | if err != nil { |
| 15 | return |
| 16 | } |
| 17 | |
| 18 | var slowlogLastID int64 |
| 19 | var lastSlowExecutionDurationSeconds float64 |
| 20 | |
| 21 | if len(values) > 0 { |
| 22 | if values, err = redisscip-go gomod github.com/gomodule/redigo v1.9.3 `github.com/gomodule/redigo/redis`/.Valuesscip-go gomod github.com/gomodule/redigo v1.9.3 `github.com/gomodule/redigo/redis`/Values().(values[0], err); err == nil && len(values) > 0 { |
| 23 | if id, ok := values[0].(int64); ok { |
| 24 | slowlogLastID = id |
| 25 | } |
| 26 | if len(values) > 2 { |
| 27 | if dur, ok := values[2].(int64); ok { |
| 28 | lastSlowExecutionDurationSeconds = float64(dur) / 1e6 |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | e.registerConstMetricGaugescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#registerConstMetricGauge().(ch, "slowlog_last_id", float64(slowlogLastID)) |
| 35 | e.registerConstMetricGaugescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#registerConstMetricGauge().(ch, "last_slow_execution_duration_seconds", lastSlowExecutionDurationSeconds) |
| 36 | } |