Skip to content

Commit

Permalink
Merge pull request #1181 from kusumachalasani/cwlogs
Browse files Browse the repository at this point in the history
Change to cloudwatch logging structure to resemble similar to ROS
  • Loading branch information
dinogun authored Apr 24, 2024
2 parents dd1caa8 + dab68fb commit 36df6a5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
12 changes: 6 additions & 6 deletions design/KruizeConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,27 @@ The following environment variables are set using the `kubectl apply` command wi

## CloudWatch Configuration

- **cloudwatch_accessKeyId**
- **logging_cloudwatch_accessKeyId**
- Description: AWS account's access key ID. If not provided, CloudWatch logging is disabled.
- Value: ""

- **cloudwatch_secretAccessKey**
- **logging_cloudwatch_secretAccessKey**
- Description: AWS account's secret access key. If not provided, CloudWatch logging is disabled.
- Value: ""

- **cloudwatch_region**
- **logging_cloudwatch_region**
- Description: AWS region where CloudWatch logs are stored. If not provided, CloudWatch logging is disabled.
- Value: ""

- **cloudwatch_logGroup**
- **logging_cloudwatch_logGroup**
- Description: Name of the CloudWatch log group. Defaults to "kruize-logs".
- Value: "kruize-logs"

- **cloudwatch_logStream**
- **logging_cloudwatch_logStream**
- Description: Name of the CloudWatch log stream within the log group. Defaults to "kruize-stream".
- Value: "kruize-stream"

- **cloudwatch_logLevel**
- **logging_cloudwatch_logLevel**
- Description: The minimum level of log events to send to CloudWatch. Defaults to "INFO".
- Value: "INFO"

Expand Down
16 changes: 9 additions & 7 deletions design/KruizeConfigurationProcedure.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ data:
"hbm2ddlauto": "update",
"showsql": "true"
},
"cloudwatch": {
"accessKeyId": "",
"secretAccessKey": "",
"region": "",
"logGroup": "kruize-logs",
"logStream": "kruize-stream",
"logLevel": "INFO"
"logging": {
"cloudwatch": {
"accessKeyId": "",
"secretAccessKey": "",
"region": "",
"logGroup": "kruize-logs",
"logStream": "kruize-stream",
"logLevel": "INFO"
}
}
}
```
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/autotune/utils/CloudWatchAppender.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package com.autotune.utils;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.Filter;
Expand All @@ -16,13 +17,15 @@
import software.amazon.awssdk.services.cloudwatchlogs.CloudWatchLogsAsyncClient;
import software.amazon.awssdk.services.cloudwatchlogs.CloudWatchLogsClient;
import software.amazon.awssdk.services.cloudwatchlogs.model.*;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import static com.autotune.operator.KruizeDeploymentInfo.*;

public class CloudWatchAppender extends AbstractAppender {
private static final Logger LOGGER = LoggerFactory.getLogger(CloudWatchAppender.class);
private final String logGroupName;
private final String logStreamName;
private final CloudWatchLogsAsyncClient cloudWatchLogsClient;
Expand Down Expand Up @@ -106,6 +109,7 @@ public static void configureLoggerForCloudWatchLog() {
LoggerConfig loggerConfig = config.getLoggerConfig("com.autotune");
loggerConfig.addAppender(appender, level, filter);
context.updateLoggers(config);
LOGGER.debug("Enabled CloudWatch logs");

} catch (Exception e) {
LOGGER.error(e.getMessage());
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/autotune/utils/KruizeConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -599,12 +599,12 @@ public static final class KRUIZE_CONFIG_ENV_NAME {
public static final String SETTINGS_HIBERNATE_SHOW_SQL = "hibernate_showsql";
public static final String SETTINGS_HIBERNATE_TIME_ZONE = "hibernate_timezone";
public static final String PLOTS = "plots";
public static final String CLOUDWATCH_LOGS_ACCESS_KEY_ID = "cloudwatch_accessKeyId";
public static final String CLOUDWATCH_LOGS_SECRET_ACCESS_KEY = "cloudwatch_secretAccessKey";
public static final String CLOUDWATCH_LOGS_LOG_GROUP = "cloudwatch_logGroup";
public static final String CLOUDWATCH_LOGS_REGION = "cloudwatch_region";
public static final String CLOUDWATCH_LOGS_LOG_STREAM = "cloudwatch_logStream";
public static final String CLOUDWATCH_LOGS_LOG_LEVEL = "cloudwatch_logLevel";
public static final String CLOUDWATCH_LOGS_ACCESS_KEY_ID = "logging_cloudwatch_accessKeyId";
public static final String CLOUDWATCH_LOGS_SECRET_ACCESS_KEY = "logging_cloudwatch_secretAccessKey";
public static final String CLOUDWATCH_LOGS_LOG_GROUP = "logging_cloudwatch_logGroup";
public static final String CLOUDWATCH_LOGS_REGION = "logging_cloudwatch_region";
public static final String CLOUDWATCH_LOGS_LOG_STREAM = "logging_cloudwatch_logStream";
public static final String CLOUDWATCH_LOGS_LOG_LEVEL = "logging_cloudwatch_logLevel";
public static final String LOCAL = "local";
public static final String LOG_HTTP_REQ_RESP = "logAllHttpReqAndResp";
}
Expand Down

0 comments on commit 36df6a5

Please sign in to comment.