About log visualization

You can visualize your log data in the OKD web console, or the Kibana web console, depending on your deployed log storage solution. The Kibana console can be used with ElasticSearch log stores, and the OKD web console can be used with the ElasticSearch log store or the LokiStack.

The Kibana web console is now deprecated is planned to be removed in a future logging release.

Configuring the log visualizer

You can configure which log visualizer type your logging uses by modifying the ClusterLogging custom resource (CR).

Prerequisites

  • You have administrator permissions.

  • You have installed the OpenShift CLI (oc).

  • You have installed the Red Hat OpenShift Logging Operator.

  • You have created a ClusterLogging CR.

If you want to use the OKD web console for visualization, you must enable the logging Console Plugin. See the documentation about “Log visualization with the web console”.

Procedure

  1. Modify the ClusterLogging CR visualization spec:

    ClusterLogging CR example

    1. apiVersion: logging.openshift.io/v1
    2. kind: ClusterLogging
    3. metadata:
    4. # ...
    5. spec:
    6. # ...
    7. visualization:
    8. type: <visualizer_type> (1)
    9. kibana: (2)
    10. resources: {}
    11. nodeSelector: {}
    12. proxy: {}
    13. replicas: {}
    14. tolerations: {}
    15. ocpConsole: (3)
    16. logsLimit: {}
    17. timeout: {}
    18. # ...
    1The type of visualizer you want to use for your logging. This can be either kibana or ocp-console. The Kibana console is only compatible with deployments that use Elasticsearch log storage, while the OKD console is only compatible with LokiStack deployments.
    2Optional configurations for the Kibana console.
    3Optional configurations for the OKD web console.
  2. Apply the ClusterLogging CR by running the following command:

    1. $ oc apply -f <filename>.yaml

Viewing logs for a resource

Resource logs are a default feature that provides limited log viewing capability. You can view the logs for various resources, such as builds, deployments, and pods by using the OpenShift CLI (oc) and the web console.

To enhance your log retrieving and viewing experience, install the logging. The logging aggregates all the logs from your OKD cluster, such as node system audit logs, application container logs, and infrastructure logs, into a dedicated log store. You can then query, discover, and visualize your log data through the Kibana console or the OKD web console. Resource logs do not access the logging log store.

Viewing resource logs

You can view the log for various resources in the OpenShift CLI (oc) and web console. Logs read from the tail, or end, of the log.

Prerequisites

  • Access to the OpenShift CLI (oc).

Procedure (UI)

  1. In the OKD console, navigate to WorkloadsPods or navigate to the pod through the resource you want to investigate.

    Some resources, such as builds, do not have pods to query directly. In such instances, you can locate the Logs link on the Details page for the resource.

  2. Select a project from the drop-down menu.

  3. Click the name of the pod you want to investigate.

  4. Click Logs.

Procedure (CLI)

  • View the log for a specific pod:

    1. $ oc logs -f <pod_name> -c <container_name>

    where:

    -f

    Optional: Specifies that the output follows what is being written into the logs.

    <pod_name>

    Specifies the name of the pod.

    <container_name>

    Optional: Specifies the name of a container. When a pod has more than one container, you must specify the container name.

    For example:

    1. $ oc logs ruby-58cd97df55-mww7r
    1. $ oc logs -f ruby-57f7f4855b-znl92 -c ruby

    The contents of log files are printed out.

  • View the log for a specific resource:

    1. $ oc logs <object_type>/<resource_name> (1)
    1Specifies the resource type and name.

    For example:

    1. $ oc logs deployment/ruby

    The contents of log files are printed out.