{
  "id": "collect-logs",
  "title": "Collect logs",
  "url": "https://redis.io/docs/latest/operate/kubernetes/8.0.18/logs/collect-logs/",
  "summary": "Run the log collector script to package relevant logs into a tar.gz file to send to Redis Support for help troubleshooting your Kubernetes environment.",
  "content": "\nThe Redis Enterprise cluster (REC) log collector script ([`log_collector.py`](https://github.com/RedisLabs/redis-enterprise-k8s-docs/blob/master/log_collector/log_collector.py)) creates and fills a directory with the relevant logs for your environment. These logs will help the support team with troubleshooting.\n\nThe log collector tool has two modes:\n\n- **restricted** collects only resources and logs created by the operator and Redis Enterprise deployments\n- **all** collects everything from your environment\n\n This script requires Python 3.11 or later. \n\n## Prerequisites\n\nBefore running the log collector, ensure you have the appropriate RBAC permissions configured. See [Log collector RBAC examples](https://redis.io/docs/latest/operate/kubernetes/reference/yaml/log-collector-rbac) for detailed RBAC configuration instructions.\n\n## Collect logs\n\n1. Download the latest [`log_collector.py`](https://github.com/RedisLabs/redis-enterprise-k8s-docs/blob/master/log_collector/log_collector.py) file.\n\n1. Ensure your `kubectl` or `oc` CLI is configured to access the Kubernetes cluster you want to collect logs from.\n\n1. Have a K8s administrator run the script on the system that runs your `kubectl` or `oc` commands.\n\n    ```bash\n    python log_collector.py\n    ```\n\n## Options\n\nYou can run `log_collector.py` with the following options:\n\n| Option | Description |\n|--------|-------------|\n| `-n`, `--namespace` | Sets the namespace(s) to collect from. Can be set to a single namespace, or multiple namespaces (comma-separated). When left empty, will use the current context's namespace from kubeconfig. |\n| `-o`, `--output_dir` | Sets the output directory. Defaults to current working directory. |\n| `-a`, `--logs_from_all_pods` | Collect logs from all pods in the selected namespace(s), and otherwise collect only from the operator and pods run by the operator. |\n| `-t`, `--timeout` | Time to wait for external commands to finish execution (Linux only). Defaults to 180s. Specify 0 to disable timeout. |\n| `--k8s_cli` | The K8s cli client to use (kubectl/oc/auto-detect). Defaults to auto-detect (chooses between 'kubectl' and 'oc'). Full paths can also be used. |\n| `-m`, `--mode` | Controls which resources are collected. In 'restricted' mode, only resources associated with the operator and have the label 'app=redis-enterprise' are collected. In 'all' mode, all resources are collected. Defaults to 'restricted' mode. |\n| `--collect_istio` | Collect data from istio-system namespace to debug potential problems related to istio ingress method. |\n| `--collect_empty_files` | Collect empty log files for missing resources. |\n| `--helm_release_name` | Collect resources related to the given Helm release name. |\n| `--collect_rbac_resources` | Temporary development flag. Collect all role based access control related custom resources. |\n| `-h`, `--help` | Show help message and exit. |\n\n If you get an error because the yaml module is not found, install the pyYAML module with `pip install pyyaml`.\n\n\n1. Upload the resulting `tar.gz` file containing all the logs to [Redis Support](https://support.redislabs.com/).\n\n\n",
  "tags": ["docs","operate","kubernetes"],
  "last_updated": "2026-06-04T14:49:57+01:00"
}
