MCPcopy Index your code
hub / github.com/c1982/redis-traffic-stats

github.com/c1982/redis-traffic-stats @v1.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.1.0 ↗ · + Follow
24 symbols 65 edges 7 files 8 documented · 33%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

redis-traffic-stats

redis-traffic-stats is a live monitor and analyze RESP packets in your server. This tool does not touch Redis Server. Just monitors redis client request and response on the real time.

All redis stats exported as prometheus metrics so you can visualize analytics data on your favorite dashboard (like grafana).

Features:

  • Live Monitoring
  • Low CPU utilization
  • Prometheus Exporter
  • Basic-Auth protection
  • Top commands of count
  • Top command and keys count
  • No dependencies
  • No Redis performance degradation

Tasks:

  • [x] Count commands and arguments
  • [ ] Count network traffic of command
  • [x] Monitor Slow commands
  • [x] Monitor big response

Installation

Usage

./redis-traffic-stats --interface=ens5 --addr=:9200 \
--password=pass \
--debug=false \
-s=: \
-r="[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}" \
--redisport=6379 \
--max=150 \
--slow-response-threshold=20ms
--snaplen=50000
Flag Default Usage
debug false Enable debug logs
interface empty Ethernet infreface name. eth0, ens5
redisport 6379 Redis server port number
addr :9200 http listener port for prometheus metrics
username admin Prometheus metrics username
password **** Prometheus metrics password
s empty Separator of keys (for split). If it empty does not split keys.
r empty Regex pattern of keys (for clean)
max 150 Maximum lookup size of key. If value -1 unlimited lookup.
slow-response-threshold 500 threshold for recording slow response. Millisecond
big-response-threshold 1500 threshold for recording slow response. Bytes
snap 2048 the maximum size to read for each packet (snaplen)

Grafana Dashboard

This easy way for dasboarding. You can upload to grafana this file.

Run test environment

docker-compose up

garafana:

http://localhost:3000/

prometheus:

http://localhost:9090/

Static Compilation

This tool require libpcap library (https://www.tcpdump.org/). You can embed dependencies on the compilation process. This helps for portability. Check the build command below

LDFLAGS='-l/usr/lib/libpcap.a' CGO_ENABLED=1 go build -ldflags '-linkmode external -extldflags -static' .

Troubleshooting

If you get an error about libpcap like below

./redis-traffic-stats: error while loading shared libraries: libpcap.so.0.8: cannot open shared object file: No such file or directory

install libpcap

for centos

yum install libpcap-devel

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Oğuzhan YILMAZ - @c1982 - aspsrc@gmail.com

Core symbols most depended-on inside this repo

Command
called by 7
resp_parser.go
Args
called by 6
resp_parser.go
NewRespReader
called by 4
resp_parser.go
Set
called by 2
durations.go
cleanMatched
called by 2
resp_parser.go
exportPrometheusMetrics
called by 1
promet_stats.go
monitorRespPackets
called by 1
monitor_resp.go
parseRespPacket
called by 1
monitor_resp.go

Shape

Function 11
Method 10
Struct 3

Languages

Go100%

Modules by API surface

resp_parser.go9 symbols
durations.go6 symbols
resp_parser_test.go4 symbols
monitor_resp.go2 symbols
promet_stats.go1 symbols
monitor_packet.go1 symbols
main.go1 symbols

For agents

$ claude mcp add redis-traffic-stats \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page