×

There are various methods to view your logs in Red Hat OpenShift Service on AWS (ROSA). Use the following procedures to forward the logs to AWS CloudWatch and view the logs directly through the pod by using oc logs.

ROSA is not preconfigured with a logging solution.

Forwarding logs to CloudWatch

Install the logging add-on service to forward the logs to AWS CloudWatch.

  1. Run the following script to configure your ROSA cluster to forward logs to CloudWatch:

    $ curl https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/resources/configure-cloudwatch.sh | bash

    Configuring ROSA to send logs to CloudWatch goes beyond the scope of this tutorial. Integrating with AWS and enabling CloudWatch logging are important aspects of ROSA, so a script is included to simplify the configuration process. The script will automatically set up AWS CloudWatch. You can examine the script to understand the steps involved.

    Example output
    Varaibles are set...ok.
    Policy already exists...ok.
    Created RosaCloudWatch-mycluster role.
    Attached role policy.
    Deploying the Red Hat OpenShift Logging Operator
    namespace/openshift-logging configured
    operatorgroup.operators.coreos.com/cluster-logging created
    subscription.operators.coreos.com/cluster-logging created
    Waiting for Red Hat OpenShift Logging Operator deployment to complete...
    Red Hat OpenShift Logging Operator deployed.
    secret/cloudwatch-credentials created
    clusterlogforwarder.logging.openshift.io/instance created
    clusterlogging.logging.openshift.io/instance created
    Complete.
  2. After a few minutes, you should begin to see log groups inside of AWS CloudWatch. Run the following command to see the log groups:

    $ aws logs describe-log-groups --log-group-name-prefix rosa-mycluster
    Example output
    {
        "logGroups": [
            {
                "logGroupName": "rosa-mycluster.application",
                "creationTime": 1724104537717,
                "metricFilterCount": 0,
                "arn": "arn:aws:logs:us-west-2:000000000000:log-group:rosa-mycluster.application:*",
                "storedBytes": 0,
                "logGroupClass": "STANDARD",
                "logGroupArn": "arn:aws:logs:us-west-2:000000000000:log-group:rosa-mycluster.application"
            },
            {
                "logGroupName": "rosa-mycluster.audit",
                "creationTime": 1724104152968,
                "metricFilterCount": 0,
                "arn": "arn:aws:logs:us-west-2:000000000000:log-group:rosa-mycluster.audit:*",
                "storedBytes": 0,
                "logGroupClass": "STANDARD",
                "logGroupArn": "arn:aws:logs:us-west-2:000000000000:log-group:rosa-mycluster.audit"
            },

Outputting the data to the streams and logs

  1. Output a message to stdout.

    1. In the OSToy application, click Home and then click the message box for Log Message (stdout).

    2. Write a message to output to the stdout stream, for example "All is well!".

    3. Click Send Message.

      cloud experts deploying application logging ostoy stdout

  2. Output a message to stderr.

    1. Click the message box for Log Message (stderr).

    2. Write a message to output to the stderr stream, for example "Oh no! Error!".

    3. Click Send Message.

      cloud experts deploying application logging ostoy stderr

Viewing the application logs by using the oc command

  1. Enter the following command in the command line interface (CLI) to retrieve the name of your frontend pod:

    $ oc get pods -o name
    Example output
    pod/ostoy-frontend-679cb85695-5cn7x (1)
    pod/ostoy-microservice-86b4c6f559-p594d
    1 The pod name is ostoy-frontend-679cb85695-5cn7x.
  2. Run the following command to see both the stdout and stderr messages:

    $ oc logs <pod-name>
    Example output
    $ oc logs ostoy-frontend-679cb85695-5cn7x
    [...]
    ostoy-frontend-679cb85695-5cn7x: server starting on port 8080
    Redirecting to /home
    stdout: All is well!
    stderr: Oh no! Error!

Viewing the logs with CloudWatch

  1. Navigate to CloudWatch on the AWS web console.

  2. In the left menu, click Logs and then Log groups to see the different groups of logs. You should see 3 groups:

    • rosa-<cluster-name>.application

    • rosa-<cluster-name>.audit

    • rosa-<cluster-name>.infrastructure

      cloud experts deploying application logging cw

  3. Click rosa-<cluster-name>.application.

  4. Click the log stream for the frontend pod.

    cloud experts deploying application logging logstream2

  5. Filter for stdout and stderr.

  6. Expand the row to show the messages you entered earlier and other pertinent information.

    cloud experts deploying application logging stderr

  7. Return to the log streams and select the microservice.

  8. Enter "microservice" in the search bar to see other messages in your logs.

  9. Expand one of the entries to see the color the frontend pod received from microservice and which pod sent that color to the frontend pod.

    cloud experts deploying application logging messages

Additional resources