Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's the best way to enable logging of GET/SET? #6

Open
nrvnrvn opened this issue Jun 15, 2022 · 0 comments
Open

What's the best way to enable logging of GET/SET? #6

nrvnrvn opened this issue Jun 15, 2022 · 0 comments

Comments

@nrvnrvn
Copy link
Owner

nrvnrvn commented Jun 15, 2022

From amaizfinance/redis-operator#32:
Hi @nrvnrvn ,

I would like to have your thoughts so in development environment I can debug all GET/SET from the Redis cluster through the operator.

This one can be done by running a command redis-cli monitor (https://redis.io/commands/MONITOR) that watches all events and logs them (can be written to a file if wanted). But I don't know what would be the best practice to make it "embedded" with the operator.

Should the operator launch another container just doing sleep X && redis-cli monitor (the sleep would be to wait for the other container Redis server to be ready)? Or do you see something better? Maybe I should create this deployment on my own without relying on the operator?

In both cases, should my redis-cli monitor watches all the cluster, or just the master?

Thank you,
@sneko

For now I'm using a "homemade" solution (another pod):

apiVersion: v1
kind: Pod
metadata:
  name: redis-logger
spec:
  containers:
  - name: redis-logger
    image: redis:5-alpine
    imagePullPolicy: Always
    # Note: exclude all "ping" logs that are just noise
    # [WORKAROUND] For whatever reason even if the "grep" example is the best one it won't work within "command/args" on Kubernetes. Like if "grep -v XXX" was always considered as looking for "-v XXX" instead of excluding "XXX"
    # I did multiple attempts by quotes, using "command" array, "args" array... none worked whereas directly on the pod it works as expected. Anyway found a less precise but working filter with "awk" instead :)
    # command: ["/bin/sh", "-c", "/usr/local/bin/redis-cli -h $(REDIS_MASTER_HOST) -p $(REDIS_MASTER_PORT) MONITOR | grep -v \"] \\\"ping\\\"\""]
    command: ["/bin/sh", "-c", "/usr/local/bin/redis-cli -h $(REDIS_MASTER_HOST) -p $(REDIS_MASTER_PORT) MONITOR | awk !/\"ping\"/"]
    env:
    - name: REDIS_MASTER_HOST
      valueFrom:
        configMapKeyRef:
          name: XXXXXX
          key: redis.master.host
    - name: REDIS_MASTER_PORT
      valueFrom:
        configMapKeyRef:
          name: XXXXXX
          key: redis.master.port

Hope it can help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant