| 1 | package exporterscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/ |
| 2 | |
| 3 | import ( |
| 4 | "strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/" |
| 5 | "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/" |
| 6 | |
| 7 | "github.com/gomodule/redigo/redisscip-go gomod github.com/gomodule/redigo v1.9.3 `github.com/gomodule/redigo/redis`/" |
| 8 | "github.com/prometheus/client_golang/prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/" |
| 9 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/ "github.com/sirupsen/logrusscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/" |
| 10 | ) |
| 11 | |
| 12 | // All fields of the streamInfo struct must be exported |
| 13 | // because of redis.ScanStruct (reflect) limitations |
| 14 | type streamInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo# struct { |
| 15 | Lengthscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#Length. int64 `redis:"length"` |
| 16 | RadixTreeKeysscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#RadixTreeKeys. int64 `redis:"radix-tree-keys"` |
| 17 | RadixTreeNodesscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#RadixTreeNodes. int64 `redis:"radix-tree-nodes"` |
| 18 | LastGeneratedIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#LastGeneratedId. string `redis:"last-generated-id"` |
| 19 | Groupsscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#Groups. int64 `redis:"groups"` |
| 20 | MaxDeletedEntryIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#MaxDeletedEntryId. string `redis:"max-deleted-entry-id"` |
| 21 | FirstEntryIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#FirstEntryId. string |
| 22 | LastEntryIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#LastEntryId. string |
| 23 | StreamGroupsInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#StreamGroupsInfo. []streamGroupsInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo# |
| 24 | } |
| 25 | |
| 26 | type streamGroupsInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo# struct { |
| 27 | Namescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#Name. string `redis:"name"` |
| 28 | Consumersscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#Consumers. int64 `redis:"consumers"` |
| 29 | Pendingscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#Pending. int64 `redis:"pending"` |
| 30 | LastDeliveredIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#LastDeliveredId. string `redis:"last-delivered-id"` |
| 31 | EntriesReadscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#EntriesRead. int64 `redis:"entries-read"` |
| 32 | Lagscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#Lag. int64 `redis:"lag"` |
| 33 | StreamGroupConsumersInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#StreamGroupConsumersInfo. []streamGroupConsumersInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupConsumersInfo# |
| 34 | } |
| 35 | |
| 36 | type streamGroupConsumersInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupConsumersInfo# struct { |
| 37 | Namescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupConsumersInfo#Name. string `redis:"name"` |
| 38 | Pendingscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupConsumersInfo#Pending. int64 `redis:"pending"` |
| 39 | Idlescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupConsumersInfo#Idle. int64 `redis:"idle"` |
| 40 | } |
| 41 | |
| 42 | func getStreamInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/getStreamInfo().(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#, key string) (*streamInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#, error) { |
| 43 | 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, "XINFO", "STREAM", key)) |
| 44 | if err != nil { |
| 45 | return nil, err |
| 46 | } |
| 47 | |
| 48 | // Scan slice to struct |
| 49 | var stream streamInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo# |
| 50 | if err := redisscip-go gomod github.com/gomodule/redigo v1.9.3 `github.com/gomodule/redigo/redis`/.ScanStructscip-go gomod github.com/gomodule/redigo v1.9.3 `github.com/gomodule/redigo/redis`/ScanStruct().(values, &stream); err != nil { |
| 51 | return nil, err |
| 52 | } |
| 53 | |
| 54 | // Extract first and last id from slice |
| 55 | for idx, v := range values { |
| 56 | vbytes, ok := v.([]byte) |
| 57 | if !ok { |
| 58 | continue |
| 59 | } |
| 60 | if string(vbytes) == "first-entry" { |
| 61 | stream.FirstEntryIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#FirstEntryId. = getStreamEntryIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/getStreamEntryId().(values, idx+1) |
| 62 | } |
| 63 | if string(vbytes) == "last-entry" { |
| 64 | stream.LastEntryIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#LastEntryId. = getStreamEntryIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/getStreamEntryId().(values, idx+1) |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | stream.StreamGroupsInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#StreamGroupsInfo., err = scanStreamGroupsscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/scanStreamGroups().(c, key) |
| 69 | if err != nil { |
| 70 | return nil, err |
| 71 | } |
| 72 | |
| 73 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Debugfscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Debugf().("getStreamInfo() stream: %#v", &stream) |
| 74 | return &stream, nil |
| 75 | } |
| 76 | |
| 77 | func getStreamEntryIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/getStreamEntryId().(redisValue []any, index int) string { |
| 78 | if index >= len(redisValue) || redisValue[index] == nil { |
| 79 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Debugfscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Debugf().("Failed to parse StreamEntryId") |
| 80 | return "" |
| 81 | } |
| 82 | |
| 83 | values, ok := redisValue[index].([]any) |
| 84 | if !ok || len(values) < 1 { |
| 85 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Debugfscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Debugf().("Failed to parse StreamEntryId") |
| 86 | return "" |
| 87 | } |
| 88 | |
| 89 | entryId, ok := values[0].([]byte) |
| 90 | if !ok { |
| 91 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Debugfscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Debugf().("Failed to parse StreamEntryId") |
| 92 | return "" |
| 93 | } |
| 94 | return string(entryId) |
| 95 | } |
| 96 | |
| 97 | func scanStreamGroupsscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/scanStreamGroups().(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#, stream string) ([]streamGroupsInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#, error) { |
| 98 | groups, 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, "XINFO", "GROUPS", stream)) |
| 99 | if err != nil { |
| 100 | return nil, err |
| 101 | } |
| 102 | |
| 103 | var result []streamGroupsInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo# |
| 104 | for _, g := range groups { |
| 105 | v, 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().(g, nil) |
| 106 | if err != nil { |
| 107 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Errorfscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Errorf().("Couldn't convert group values for stream '%s': %s", stream, err) |
| 108 | continue |
| 109 | } |
| 110 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Debugfscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Debugf().("streamGroupsInfo value: %#v", v) |
| 111 | |
| 112 | var group streamGroupsInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo# |
| 113 | if err := redisscip-go gomod github.com/gomodule/redigo v1.9.3 `github.com/gomodule/redigo/redis`/.ScanStructscip-go gomod github.com/gomodule/redigo v1.9.3 `github.com/gomodule/redigo/redis`/ScanStruct().(v, &group); err != nil { |
| 114 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Errorfscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Errorf().("Couldn't scan group in stream '%s': %s", stream, err) |
| 115 | continue |
| 116 | } |
| 117 | |
| 118 | group.StreamGroupConsumersInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#StreamGroupConsumersInfo., err = scanStreamGroupConsumersscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/scanStreamGroupConsumers().(c, stream, group.Namescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#Name.) |
| 119 | if err != nil { |
| 120 | return nil, err |
| 121 | } |
| 122 | |
| 123 | result = append(result, group) |
| 124 | } |
| 125 | |
| 126 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Debugfscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Debugf().("groups: %v", result) |
| 127 | return result, nil |
| 128 | } |
| 129 | |
| 130 | func scanStreamGroupConsumersscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/scanStreamGroupConsumers().(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#, stream string, group string) ([]streamGroupConsumersInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupConsumersInfo#, error) { |
| 131 | consumers, 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, "XINFO", "CONSUMERS", stream, group)) |
| 132 | if err != nil { |
| 133 | return nil, err |
| 134 | } |
| 135 | |
| 136 | var result []streamGroupConsumersInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupConsumersInfo# |
| 137 | for _, c := range consumers { |
| 138 | |
| 139 | v, 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().(c, nil) |
| 140 | if err != nil { |
| 141 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Errorfscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Errorf().("Couldn't convert consumer values for group '%s' in stream '%s': %s", group, stream, err) |
| 142 | continue |
| 143 | } |
| 144 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Debugfscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Debugf().("streamGroupConsumersInfo value: %#v", v) |
| 145 | |
| 146 | var consumer streamGroupConsumersInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupConsumersInfo# |
| 147 | if err := redisscip-go gomod github.com/gomodule/redigo v1.9.3 `github.com/gomodule/redigo/redis`/.ScanStructscip-go gomod github.com/gomodule/redigo v1.9.3 `github.com/gomodule/redigo/redis`/ScanStruct().(v, &consumer); err != nil { |
| 148 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Errorfscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Errorf().("Couldn't scan consumers for group '%s' in stream '%s': %s", group, stream, err) |
| 149 | continue |
| 150 | } |
| 151 | |
| 152 | result = append(result, consumer) |
| 153 | } |
| 154 | |
| 155 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Debugfscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Debugf().("consumers: %v", result) |
| 156 | return result, nil |
| 157 | } |
| 158 | |
| 159 | func parseStreamItemIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/parseStreamItemId().(id string) float64 { |
| 160 | if stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.TrimSpacescip-go gomod github.com/golang/go/src go1.25.0 strings/TrimSpace().(id) == "" { |
| 161 | return 0 |
| 162 | } |
| 163 | frags := stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Splitscip-go gomod github.com/golang/go/src go1.25.0 strings/Split().(id, "-") |
| 164 | if len(frags) == 0 { |
| 165 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Errorfscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Errorf().("Couldn't parse StreamItemId: %s", id) |
| 166 | return 0 |
| 167 | } |
| 168 | parsedId, err := strconvscip-go gomod github.com/golang/go/src go1.25.0 strconv/.ParseFloatscip-go gomod github.com/golang/go/src go1.25.0 strconv/ParseFloat().(stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Splitscip-go gomod github.com/golang/go/src go1.25.0 strings/Split().(id, "-")[0], 64) |
| 169 | if err != nil { |
| 170 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Errorfscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Errorf().("Couldn't parse given StreamItemId: [%s] err: %s", id, err) |
| 171 | } |
| 172 | return parsedId |
| 173 | } |
| 174 | |
| 175 | func (e *Exporterscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#) extractStreamMetricsscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#extractStreamMetrics().(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#) { |
| 176 | streams, err := parseKeyArgscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/parseKeyArg().(e.optionsscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#options..CheckStreamsscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Options#CheckStreams.) |
| 177 | if err != nil { |
| 178 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Errorfscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Errorf().("Couldn't parse given stream keys: %s", err) |
| 179 | return |
| 180 | } |
| 181 | |
| 182 | singleStreams, err := parseKeyArgscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/parseKeyArg().(e.optionsscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#options..CheckSingleStreamsscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Options#CheckSingleStreams.) |
| 183 | if err != nil { |
| 184 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Errorfscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Errorf().("Couldn't parse check-single-streams: %s", err) |
| 185 | return |
| 186 | } |
| 187 | allStreams := append([]dbKeyPairscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#{}, singleStreams...) |
| 188 | |
| 189 | scannedStreams, err := getKeysFromPatternsscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/getKeysFromPatterns().(c, streams, e.optionsscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#options..CheckKeysBatchSizescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Options#CheckKeysBatchSize.) |
| 190 | if err != nil { |
| 191 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Errorfscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Errorf().("Error expanding key patterns: %s", err) |
| 192 | } else { |
| 193 | allStreams = append(allStreams, scannedStreams...) |
| 194 | } |
| 195 | |
| 196 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Debugfscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Debugf().("allStreams: %#v", allStreams) |
| 197 | for _, k := range allStreams { |
| 198 | if _, err := doRedisCmdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/doRedisCmd().(c, "SELECT", k.dbscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#db.); err != nil { |
| 199 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Debugfscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Debugf().("Couldn't select database '%s' when getting stream info", k.dbscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#db.) |
| 200 | continue |
| 201 | } |
| 202 | info, err := getStreamInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/getStreamInfo().(c, k.keyscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#key.) |
| 203 | if err != nil { |
| 204 | logscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/.Errorfscip-go gomod github.com/sirupsen/logrus v1.9.4 `github.com/sirupsen/logrus`/Errorf().("couldn't get info for stream '%s', err: %s", k.keyscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#key., err) |
| 205 | continue |
| 206 | } |
| 207 | dbLabel := "db" + k.dbscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#db. |
| 208 | |
| 209 | e.registerConstMetricGaugescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#registerConstMetricGauge().(ch, "stream_length", float64(info.Lengthscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#Length.), dbLabel, k.keyscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#key.) |
| 210 | e.registerConstMetricGaugescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#registerConstMetricGauge().(ch, "stream_radix_tree_keys", float64(info.RadixTreeKeysscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#RadixTreeKeys.), dbLabel, k.keyscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#key.) |
| 211 | e.registerConstMetricGaugescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#registerConstMetricGauge().(ch, "stream_radix_tree_nodes", float64(info.RadixTreeNodesscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#RadixTreeNodes.), dbLabel, k.keyscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#key.) |
| 212 | e.registerConstMetricGaugescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#registerConstMetricGauge().(ch, "stream_last_generated_id", parseStreamItemIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/parseStreamItemId().(info.LastGeneratedIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#LastGeneratedId.), dbLabel, k.keyscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#key.) |
| 213 | e.registerConstMetricGaugescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#registerConstMetricGauge().(ch, "stream_groups", float64(info.Groupsscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#Groups.), dbLabel, k.keyscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#key.) |
| 214 | e.registerConstMetricGaugescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#registerConstMetricGauge().(ch, "stream_max_deleted_entry_id", parseStreamItemIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/parseStreamItemId().(info.MaxDeletedEntryIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#MaxDeletedEntryId.), dbLabel, k.keyscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#key.) |
| 215 | e.registerConstMetricGaugescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#registerConstMetricGauge().(ch, "stream_first_entry_id", parseStreamItemIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/parseStreamItemId().(info.FirstEntryIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#FirstEntryId.), dbLabel, k.keyscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#key.) |
| 216 | e.registerConstMetricGaugescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#registerConstMetricGauge().(ch, "stream_last_entry_id", parseStreamItemIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/parseStreamItemId().(info.LastEntryIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#LastEntryId.), dbLabel, k.keyscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#key.) |
| 217 | |
| 218 | for _, g := range info.StreamGroupsInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamInfo#StreamGroupsInfo. { |
| 219 | e.registerConstMetricGaugescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#registerConstMetricGauge().(ch, "stream_group_consumers", float64(g.Consumersscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#Consumers.), dbLabel, k.keyscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#key., g.Namescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#Name.) |
| 220 | e.registerConstMetricGaugescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#registerConstMetricGauge().(ch, "stream_group_messages_pending", float64(g.Pendingscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#Pending.), dbLabel, k.keyscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#key., g.Namescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#Name.) |
| 221 | e.registerConstMetricGaugescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#registerConstMetricGauge().(ch, "stream_group_last_delivered_id", parseStreamItemIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/parseStreamItemId().(g.LastDeliveredIdscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#LastDeliveredId.), dbLabel, k.keyscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#key., g.Namescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#Name.) |
| 222 | e.registerConstMetricGaugescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#registerConstMetricGauge().(ch, "stream_group_entries_read", float64(g.EntriesReadscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#EntriesRead.), dbLabel, k.keyscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#key., g.Namescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#Name.) |
| 223 | e.registerConstMetricGaugescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#registerConstMetricGauge().(ch, "stream_group_lag", float64(g.Lagscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#Lag.), dbLabel, k.keyscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#key., g.Namescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#Name.) |
| 224 | if !e.optionsscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#options..StreamsExcludeConsumerMetricsscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Options#StreamsExcludeConsumerMetrics. { |
| 225 | for _, c := range g.StreamGroupConsumersInfoscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#StreamGroupConsumersInfo. { |
| 226 | e.registerConstMetricGaugescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#registerConstMetricGauge().(ch, "stream_group_consumer_messages_pending", float64(c.Pendingscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupConsumersInfo#Pending.), dbLabel, k.keyscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#key., g.Namescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#Name., c.Namescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupConsumersInfo#Name.) |
| 227 | e.registerConstMetricGaugescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/Exporter#registerConstMetricGauge().(ch, "stream_group_consumer_idle_seconds", float64(c.Idlescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupConsumersInfo#Idle.)/1e3, dbLabel, k.keyscip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/dbKeyPair#key., g.Namescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupsInfo#Name., c.Namescip-go gomod github.com/oliver006/redis_exporter . `github.com/oliver006/redis_exporter/exporter`/streamGroupConsumersInfo#Name.) |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | } |
| 232 | } |