Skip to content

Commit bdc3eed

Browse files
author
Hiro
committed
update
1 parent 3ea3f7f commit bdc3eed

File tree

2 files changed

+109
-1
lines changed

2 files changed

+109
-1
lines changed

readme.md

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Redis Streams Exporter
2+
3+
Prometheus exporter for Redis Streams by the redis command `xinfo`.
4+
5+
And this project is written by rust, it provide a painless, standalone, economical, simple monitor for the poor men who choice the lightweight queues by redis like me.
6+
7+
## Installation and Usage
8+
9+
### Binary
10+
11+
[Download from github](https://github.com/cnzx219/redis-streams-expoter/releases)
12+
13+
Then in terminal:
14+
15+
```bash
16+
./redis-streams-exporter '--key=test-streams1;test-streams2;test-streams3' --redis=redis://127.0.0.1/0 --bind=127.0.0.1:9219
17+
```
18+
19+
Or simplify:
20+
21+
```bash
22+
./redis-streams-exporter --key=test-streams1
23+
```
24+
25+
### Docker
26+
27+
Coming soon.
28+
29+
### From Source
30+
31+
```bash
32+
cargo build --release
33+
```
34+
35+
## Configuration
36+
37+
All configuration is handled via command arguments.
38+
39+
| Environment Variable | Required | Description |
40+
|----------------------|---------------------------------------|--------------------------------------------------------------------------------------------------------------------------|
41+
| `key` | Yes | The name of the Stream(s) to monitor. Can specify multiple keys by delimiting with a semi-colon, e.g. `key-one;key-two`. |
42+
| `redis` | No, defaults to "redis://127.0.0.1/0" | Redis Url |
43+
| `bind` | No, defaults to "127.0.0.1:9219" | The ip and port is binded by this exporter. |
44+
| `calc-idle` | No, defaults to "false" | The time (secounds) since the last message. |
45+
46+
## Metrics
47+
48+
Metrics will be exported at varying levels of granularity.
49+
50+
### Stream
51+
52+
```
53+
# HELP redis_stream_length Number of messages in the stream
54+
# TYPE redis_stream_length gauge
55+
redis_stream_length{stream="my-stream-key"} 24601
56+
57+
# HELP redis_stream_earliest_id The epoch timestamp of the earliest message on the stream
58+
# TYPE redis_stream_earliest_id gauge
59+
redis_stream_earliest_id{stream="my-stream-key"} 1597104418874
60+
61+
# HELP redis_stream_latest_id The epoch timestamp of the latest message on the stream
62+
# TYPE redis_stream_latest_id gauge
63+
redis_stream_latest_id{stream="my-stream-key"} 1597152683722
64+
65+
# HELP redis_stream_consumer_groups_total Number of consumer groups for the stream
66+
# TYPE redis_stream_consumer_groups_total gauge
67+
redis_stream_consumer_groups_total{stream="my-stream-key"} 3
68+
```
69+
70+
### Consumer Group
71+
```
72+
# HELP redis_stream_consumer_group_last_delivered_id The epoch timestamp of the last delivered message
73+
# TYPE redis_stream_consumer_group_last_delivered_id gauge
74+
redis_stream_consumer_group_last_delivered_id{stream="my-stream-key",group="group-a"} 1597152683722
75+
redis_stream_consumer_group_last_delivered_id{stream="my-stream-key",group="group-b"} 1597152683722
76+
redis_stream_consumer_group_last_delivered_id{stream="my-stream-key",group="group-c"} 1597152683722
77+
78+
# HELP redis_stream_consumer_group_pending_messages_total Number of pending messages for the group
79+
# TYPE redis_stream_consumer_group_pending_messages_total gauge
80+
redis_stream_consumer_group_pending_messages_total{stream="my-stream-key",group="group-a"} 0
81+
redis_stream_consumer_group_pending_messages_total{stream="my-stream-key",group="group-b"} 0
82+
redis_stream_consumer_group_pending_messages_total{stream="my-stream-key",group="group-c"} 0
83+
84+
# HELP redis_stream_consumer_group_consumers_total Number of consumers in the group
85+
# TYPE redis_stream_consumer_group_consumers_total gauge
86+
redis_stream_consumer_group_consumers_total{stream="my-stream-key",group="group-a"} 1
87+
redis_stream_consumer_group_consumers_total{stream="my-stream-key",group="group-b"} 1
88+
redis_stream_consumer_group_consumers_total{stream="my-stream-key",group="group-c"} 1
89+
```
90+
91+
### Consumer
92+
```
93+
# HELP redis_stream_consumer_pending_messages_total Number of pending messages for the consumer
94+
# TYPE redis_stream_consumer_pending_messages_total gauge
95+
redis_stream_consumer_pending_messages_total{stream="my-stream-key",group="group-a",consumer="dhHXcC1E3"} 0
96+
redis_stream_consumer_pending_messages_total{stream="my-stream-key",group="group-b",consumer="UgfoRw0ew"} 0
97+
redis_stream_consumer_pending_messages_total{stream="my-stream-key",group="group-c",consumer="4gXR54IYg"} 0
98+
99+
# HELP redis_stream_consumer_idle_time_seconds The amount of time for which the consumer has been idle
100+
# TYPE redis_stream_consumer_idle_time_seconds gauge
101+
redis_stream_consumer_idle_time_seconds{stream="my-stream-key",group="group-a",consumer="dhHXcC1E3"} 77.063
102+
redis_stream_consumer_idle_time_seconds{stream="my-stream-key",group="group-b",consumer="UgfoRw0ew"} 77.064
103+
redis_stream_consumer_idle_time_seconds{stream="my-stream-key",group="group-c",consumer="4gXR54IYg"} 77.064
104+
```
105+
106+
## Refer to
107+
108+
https://github.com/chrnola/redis-streams-exporter

src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct Args {
2020
#[clap(short = 'k', long = "key", require_equals = true)]
2121
key: String,
2222

23-
#[clap(short = 'r', long = "redis", default_value = "redis://127.0.0.1/0")]
23+
#[clap(short = 'r', long = "redis", default_value = "redis://127.0.0.1:6379/0")]
2424
redis: String,
2525

2626
#[clap(short = 'b', long = "bind", default_value = "127.0.0.1:9219")]

0 commit comments

Comments
 (0)