Closed MrMMorris closed 9 years ago
:blue_car: :fire_engine: Good suggestion, a docker image would definitely be useful, let me look into that!
Pushed up the Dockerfile, you can also pull the docker image from here: https://registry.hub.docker.com/u/21zoo/redis_exporter/
@MrMMorris - let me know if it works for you!
Sorry for the slow response! Works perfectly, thanks :smile_cat:
Hmmm, maybe not.
telnet 0.0.0.0 6379
Trying 0.0.0.0...
Connected to 0.0.0.0.
Escape character is '^]'.
INFO
$2042
# Server
redis_version:3.0.1
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:e08b304d5ca699bf
redis_mode:standalone
os:Linux 3.19.0-18-generic x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.7.2
process_id:1
run_id:13dd0aee82facc0c6f26a85363c11917d8203174
tcp_port:6379
uptime_in_seconds:2757
uptime_in_days:0
hz:10
lru_clock:10752321
config_file:
# Clients
connected_clients:5
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
# Memory
used_memory:899352
used_memory_human:878.27K
used_memory_rss:9256960
used_memory_peak:915328
used_memory_peak_human:893.88K
used_memory_lua:35840
mem_fragmentation_ratio:10.29
mem_allocator:jemalloc-3.6.0
# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1436812924
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
aof_enabled:1
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_current_size:0
aof_base_size:0
aof_pending_rewrite:0
aof_buffer_length:0
aof_rewrite_buffer_length:0
aof_pending_bio_fsync:0
aof_delayed_fsync:0
# Stats
total_connections_received:7
total_commands_processed:5
instantaneous_ops_per_sec:0
total_net_input_bytes:80
total_net_output_bytes:10253
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
migrate_cached_sockets:0
# Replication
role:master
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
# CPU
used_cpu_sys:0.63
used_cpu_user:0.96
used_cpu_sys_children:0.00
used_cpu_user_children:0.00
# Cluster
cluster_enabled:0
# Keyspace
QUIT
+OK
Connection closed by foreign host.
And yet:
docker run -d -e SERVICE_NAME=monitoring -e SERVICE_TAGS=redis --name monitoring-redis -P 21zoo/redis_exporter:latest -redis.addr=0.0.0.0:6379
Results in this error:
2015/07/13 19:29:06 redis err: dial tcp 0.0.0.0:6379: connection refused
Not sure why it can't connect.
0.0.0.0:6379
is not the correct address of the redis instance.
either use the public IP or link the containers and use the docker ENV variables to access port and ip address.
@oliver006 fair enough. Is there a reason I can't use the internal IP? I can use it with redis-cli
Seems like redis-cli is treating 0.0.0.0
the same as localhost
or 127.0.0.1
.
Anyway, it's not a IP you shoud connect to so try using the actual IP of your host.
@oliver006 but it has to be public? redis-cli
works with the private AWS IP but the exporter doesn't seem to. I would rather not have to open a port for it..
Are you running both, redis & exporter container on the same host? If yes, link them and make the exporter access the redis container directly.
@oliver006 yea I guess that's what I'll have to do. I was just trying to avoid that as my containers are either dynamically named or not named at all.
One more question haha. If I have a redis cluster, would an exporter give me the same data no matter what instance it was connected to?
Ha, excellent question, haven't used redis cluster myself, maybe I should try that some time.
@oliver006 I would imagine it probably would be the same data similar to the mongo exporter. If I get a chance to try, I'll let you know. Thanks for your help!
Actually, you can try one one more thing to avoid naming containers, etc.
Try passing the IP of the docker interface, eg. 172.17.42.1
That might work as it would then route the traffic via the docker iptables setup and docker-proxy to the redis container.
yea, I'm not sure why I can't get it to work.
-redis.addr='redis-production:6379'
redis err: dial tcp: unknown port tcp/6379
$ cat /etc/hosts
172.17.6.41 9f79051307c5
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
172.17.5.239 redis-production 89b991734286
I get the same error with -redis.addr='REDIS_PRODUCTION_PORT_6379_TCP_ADDR:6379'
As for the docker0
interface, I do use that for my consul
exporter, but with the redis
exporter, I just get the same error redis err: dial tcp: unknown port tcp/6379
Here is my redis container config (Ansible YML):
- name: run redis container
docker:
name: "redis-{{ item }}"
image: redis:3.0.1
command: redis-server --appendonly yes
env:
SERVICE_NAME: csm-tv-redis
SERVICE_TAGS: "{{ item }}"
ports:
- "6379:6379"
publish_all_ports: True
restart_policy: always
Just got around to trying this locally and it worked. Redis container was brought up via
docker run -d -name redis -p 6379:6379 redis
and redis_exporter via
docker run -d -p 9121:9121 -e SERVICE_NAME=monitoring -e SERVICE_TAGS=redis --name monitoring-redis -P 21zoo/redis_exporter:latest -redis.addr=172.17.42.1:6379
yep, that seems to work for me too. I will see if I can find what's wrong with mine. Thanks!
there we go. I think it was because I had single quotes around the ip/port. Probably some stupid yaml quirk :facepunch:
Thanks for putting up with me!
No worries, good to hear you got it to work.
Dockerfile would probably look similar to https://github.com/discordianfish/nginx_exporter/blob/master/Dockerfile