probePod

read_pod_logs

Fetch logs for all the pods matching a name or label selector

Activity as code

Below are the details and signature of the activity Python module.

Typeprobe
Modulechaosk8s.pod.probes
Nameread_pod_logs
Returnmapping

Usage

JSON

{
  "name": "read-pod-logs",
  "type": "probe",
  "provider": {
    "type": "python",
    "module": "chaosk8s.pod.probes",
    "func": "read_pod_logs"
  }
}

YAML

name: read-pod-logs
provider:
  func: read_pod_logs
  module: chaosk8s.pod.probes
  type: python
type: probe

Arguments

NameTypeDefaultRequiredTitleDescription
nsstring“default”YesNamespace
label_selectorstringYesLabel selectorSelectors to target the appropriate pods
lastobjectnullNoPeriodEither a number of seconds to read back or a string representing a period such 10 minutes
from_previousbooleanfalseNoRead from Previous PodRead the logs from the previous incarnation of the pod
container_namestringnullNoName of the ContainerWhen a pod is made of several containers, specify the name of the container to read from

Fetch logs for all the pods with the label "name" set to name and return a dictionary with the keys being the pod’s name and the values the logs of said pod. If name is not provided, use only the label_selector instead.

When your pod has several containers, you should also set container_name to clarify which container you want to read logs from.

If you provide last, this returns the logs of the last N seconds until now. This can be set to a fluent delta such as 10 minutes.

You may also set from_previous to True to capture the logs of a previous pod’s incarnation, if any.

Signature

def read_pod_logs(name: str = None,
                  last: Union[str, NoneType] = None,
                  ns: str = 'default',
                  from_previous: bool = False,
                  label_selector: str = 'name in ({name})',
                  container_name: str = None,
                  secrets: Dict[str, Dict[str, str]] = None) -> Dict[str, str]:
    pass