This commit is contained in:
Luckysideburn
2022-10-25 15:57:02 +00:00
parent 6129ed43f2
commit 0894106faf
3 changed files with 23 additions and 21 deletions
+3 -2
View File
@@ -238,15 +238,16 @@ experiments:
<button type="button" id="logConsoleButton" class="btn btn-light" onclick="setLogConsole()">Start Logs Tail</button>
</div>
</div>
<div id="logTailScreen" style="display: none;">
<div id="logTailRegexInput" style="display: block;">
<div class="row" style="margin-top: 2%;">
<input type="text" style="font-family: Courier New, Courier, monospace;" id="logTailRegex" value='{"pod:".*", "namespace":".*", "labels":".*", "annotations":".*"}'/>
<input type="text" style="font-family: Courier New, Courier, monospace;" id="logTailRegex" value='{"pod":".*", "namespace":".*", "labels":".*", "annotations":".*"}'/>
</div>
<div class="row" style="margin-top: 1%;">
<div class="col text-center">
<button type="button" style="width: 10em;" id="logConsoleRegex" class="btn btn-sm btn-dark ext-center" onclick="setLogRegex()">Set Regex</button>
</div>
</div>
<div id="logTailScreen" style="display: none;">
<div class="row">
<div id="logTailDiv" style="margin-top: 2%; overflow-y: scroll; height:700px; display: none;"></div>
</div>
+12 -13
View File
@@ -131,19 +131,18 @@ function getMetrics() {
function getChaosJobsLogs() {
var oReq = new XMLHttpRequest();
oReq.onload = function () {
if (programming_mode_switch) {
document.getElementById("chaosJobLogsDiv").innerHTML = "";
document.getElementById("chaosJobLogsDiv").innerHTML = this.responseText;
}
if (log_tail_switch) {
document.getElementById("logTailDiv").innerHTML = "";
document.getElementById("logTailDiv").innerHTML = this.responseText;
}
};;
oReq.onreadystatechange = function () {
if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
if (programming_mode_switch) {
document.getElementById("chaosJobLogsDiv").innerHTML = "";
document.getElementById("chaosJobLogsDiv").innerHTML = this.responseText;
}
if (log_tail_switch) {
document.getElementById("logTailDiv").innerHTML = "";
document.getElementById("logTailDiv").innerHTML = this.responseText;
}
}
};;
oReq.open("GET", "https://" + clu_endpoint + "/chaoslogs.html");
oReq.send();
}
+8 -6
View File
@@ -53,7 +53,7 @@ if r.exists("log_pod_regex"):
logging.info("The Redis key log_pod_regex exists...")
else:
logging.info("The Redis key log_pod_regex does NOT exists...")
r.set("log_pod_regex", '{"pod:".*", "namespace":".*", "labels":".*", "annotations":".*"}')
r.set("log_pod_regex", '{"pod":".*", "namespace":".*", "labels":".*", "annotations":".*"}')
if r.exists('logs_enabled'):
logging.info("The Redis key logs_enabled exists...")
@@ -98,17 +98,18 @@ while True:
if r.get("logs_enabled") == "1":
logging.info("Found regex log_pod_regex in Redis. Logs from all pods should be collected")
log_pod_regex = r.get("log_pod_regex")
logging.info(f"log_pod_regex is => |{log_pod_regex}|")
try:
api_response = api_instance.list_pod_for_all_namespaces()
except ApiException as e:
logging.info(e)
logging.info(f"Going to search pod compliant with the regex on {len(api_response.items)} pods")
json_regex = json.loads(log_pod_regex)
pod_re = json_regex["pod"]
namespace_re = json_regex["namespace"]
annotations_re = json_regex["annotations"]
labels_re = json_regex["labels"]
json_re = json.loads(log_pod_regex)
pod_re = json_re["pod"]
namespace_re = json_re["namespace"]
annotations_re = json_re["annotations"]
labels_re = json_re["labels"]
logging.info(f"Gobal Json Regex is #{json_re}")
logging.info(f"Regex for pod name is #{pod_re}")
@@ -129,6 +130,7 @@ while True:
webtail_switch = False
final_pod_list = webtail_pods + api_response.items
if len(webtail_pods) > 0:
webtail_switch = True