Back to Redis

Collect Logs

content/operate/kubernetes/7.22/logs/collect-logs.md

latest3.1 KB
Original Source

The Redis Enterprise cluster (REC) log collector script (log_collector.py) creates and fills a directory with the relevant logs for your environment. These logs will help the support team with troubleshooting.

The log collector tool has two modes:

  • restricted collects only resources and logs created by the operator and Redis Enterprise deployments
  • all collects everything from your environment

{{<note>}} This script requires Python 3.6 or later. {{</note>}}

Prerequisites

Before running the log collector, ensure you have the appropriate RBAC permissions configured. See [Log collector RBAC examples]({{< relref "/operate/kubernetes/7.22/reference/yaml/log-collector-rbac" >}}) for detailed RBAC configuration instructions.

Collect logs

  1. Download the latest log_collector.py file.

  2. Ensure your kubectl or oc CLI is configured to access the Kubernetes cluster you want to collect logs from.

  3. Have a K8s administrator run the script on the system that runs your kubectl or oc commands.

    bash
    python log_collector.py
    

Options

You can run log_collector.py with the following options:

OptionDescription
-n, --namespaceSets 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.
-o, --output_dirSets the output directory. Defaults to current working directory.
-a, --logs_from_all_podsCollect logs from all pods in the selected namespace(s), and otherwise collect only from the operator and pods run by the operator.
-t, --timeoutTime to wait for external commands to finish execution (Linux only). Defaults to 180s. Specify 0 to disable timeout.
--k8s_cliThe K8s cli client to use (kubectl/oc/auto-detect). Defaults to auto-detect (chooses between 'kubectl' and 'oc'). Full paths can also be used.
-m, --modeControls 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.
--collect_istioCollect data from istio-system namespace to debug potential problems related to istio ingress method.
--collect_empty_filesCollect empty log files for missing resources.
--helm_release_nameCollect resources related to the given Helm release name.
--collect_rbac_resourcesTemporary development flag. Collect all role based access control related custom resources.
-h, --helpShow help message and exit.

{{< note >}} If you get an error because the yaml module is not found, install the pyYAML module with pip install pyyaml. {{< /note >}}

  1. Upload the resulting tar.gz file containing all the logs to Redis Support.