$ curl https://raw.githubusercontent.com/openshift-cs/rosaworkshop/master/rosa-workshop/ostoy/resources/configure-cloudwatch.sh | bash
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. |
Install the logging add-on service to forward the logs to AWS CloudWatch.
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. |
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.
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
{
"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"
},
Output a message to stdout
.
In the OSToy application, click Home and then click the message box for Log Message (stdout).
Write a message to output to the stdout
stream, for example "All is well!".
Click Send Message.
Output a message to stderr
.
Click the message box for Log Message (stderr).
Write a message to output to the stderr
stream, for example "Oh no! Error!".
Click Send Message.
oc
commandEnter the following command in the command line interface (CLI) to retrieve the name of your frontend pod:
$ oc get pods -o name
pod/ostoy-frontend-679cb85695-5cn7x (1)
pod/ostoy-microservice-86b4c6f559-p594d
1 | The pod name is ostoy-frontend-679cb85695-5cn7x . |
Run the following command to see both the stdout
and stderr
messages:
$ oc logs <pod-name>
$ 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!
Navigate to CloudWatch on the AWS web console.
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
Click rosa-<cluster-name>.application
.
Click the log stream for the frontend pod.
Filter for stdout
and stderr
.
Expand the row to show the messages you entered earlier and other pertinent information.
Return to the log streams and select the microservice.
Enter "microservice" in the search bar to see other messages in your logs.
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.