Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files for the grafana operator. Also modify log parser. #344

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions acto/parse_log/parse_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@
logrus_regex += r'\s*$'
# this is semi-auto generated by copilot, holy moly

# This one is similar to logr_special_regex and logrus_regex, but with some differences
# 2024-03-05T10:07:17Z ERROR GrafanaReconciler reconciler error in stage {"controller": "grafana", "controllerGroup": "grafana.integreatly.org", "controllerKind": "Grafana", "Grafana": {"name":"test-cluster","namespace":"grafana"}, "namespace": "grafana", "name": "test-cluster", "reconcileID": "5aa39e3e-d5d3-47fc-848d-c3d15dfbcc3d", "stage": "deployment", "error": "Deployment.apps \"test-cluster-deployment\" is invalid: [spec.template.spec.containers[0].image: Required value, spec.template.spec.affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution[0].topologyKey: Required value: can not be empty, spec.template.spec.affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution[0].topologyKey: Invalid value: \"\": name part must be non-empty, spec.template.spec.affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution[0].topologyKey: Invalid value: \"\": name part must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyName', or 'my.name', or '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]')]"}
grafana_logr_regex = r'^\s*'
grafana_logr_regex += r'(\d{4}\-\d{2}\-\d{2}T\d{2}:\d{2}:\d{2}Z)' # Group 1: timestamp
grafana_logr_regex += r'\s+([A-Z]+)' # Group 2: level
grafana_logr_regex += r'\s+(\S+)' # Group 3: Source
grafana_logr_regex += r'\s+(.*?)' # Group 4: Message
grafana_logr_regex += r'\s*$' # Take up any remaining whitespace

def parse_log(line: str) -> dict:
'''Try to parse the log line with some predefined format
Expand Down Expand Up @@ -89,6 +97,10 @@
match = re.search(logrus_regex, line)
log_line['level'] = match.group(2)
log_line['msg'] = match.group(3)
elif re.search(grafana_logr_regex, line) != None:
match = re.search(grafana_logr_regex, line)
log_line['level'] = match.group(2).lower()
log_line['msg'] = match.group(4)

Check warning on line 103 in acto/parse_log/parse_log.py

View workflow job for this annotation

GitHub Actions / coverage-report

Missing coverage

Missing coverage on lines 101-103
else:
try:
log_line = json.loads(line)
Expand Down
14 changes: 14 additions & 0 deletions data/grafana_grafana-operator/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"deploy": {
"steps": [
{
"apply": {
"file": "data/grafana_grafana-operator/kustomize-cluster_scoped.yaml",
"operator": true
}
}
]
},
"crd_name": "grafanas.grafana.integreatly.org",
"seed_custom_resource": "data/grafana_grafana-operator/grafanas-cr.yaml"
}
Loading
Loading