forked from open-telemetry/opentelemetry-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Export logs to in-cluster logging (open-telemetry#3217)
- Loading branch information
1 parent
9272b88
commit 3592a15
Showing
13 changed files
with
837 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
tests/e2e-openshift/export-to-cluster-logging-lokistack/chainsaw-test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
name: export-to-cluster-logging-lokistack | ||
spec: | ||
namespace: chainsaw-incllogs | ||
description: Tests shipping of logs to OpenShift in-cluster Logging LokiStack instance using OpenTelemetry collector. The tests requires the Loki, OpenTelemetry and Cluster Observability Operator to be installed along with logcli | ||
steps: | ||
- name: Create the OTEL collector instance | ||
try: | ||
- apply: | ||
file: otel-collector.yaml | ||
- assert: | ||
file: otel-collector-assert.yaml | ||
- name: Install Minio instance | ||
try: | ||
- apply: | ||
file: install-minio.yaml | ||
- assert: | ||
file: install-minio-assert.yaml | ||
- name: Create the LokiStack instance | ||
try: | ||
- apply: | ||
file: install-loki.yaml | ||
- assert: | ||
file: install-loki-assert.yaml | ||
- name: Check the status of LokiStack instance | ||
try: | ||
- script: | ||
timeout: 5m | ||
content: kubectl get --namespace openshift-logging lokistacks logging-loki -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}' | ||
- name: Enable Logging UI. Not needed by test but can be used for debugging | ||
try: | ||
- apply: | ||
file: logging-uiplugin.yaml | ||
- assert: | ||
file: logging-uiplugin-assert.yaml | ||
- name: Generate logs | ||
try: | ||
- apply: | ||
file: generate-logs.yaml | ||
- assert: | ||
file: generate-logs-assert.yaml | ||
- name: Check logs in LokiStack instance | ||
try: | ||
- script: | ||
timeout: 5m | ||
content: ./check_logs.sh | ||
cleanup: | ||
- delete: | ||
ref: | ||
apiVersion: loki.grafana.com/v1 | ||
kind: LokiStack | ||
name: logging-loki | ||
namespace: openshift-logging | ||
- delete: | ||
ref: | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
labels: | ||
app.kubernetes.io/instance: "logging-loki" | ||
namespace: openshift-logging |
27 changes: 27 additions & 0 deletions
27
tests/e2e-openshift/export-to-cluster-logging-lokistack/check_logs.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
TOKEN=$(oc -n openshift-logging create token otel-collector-deployment) | ||
LOKI_URL=$(oc -n openshift-logging get route logging-loki -o json | jq '.spec.host' -r) | ||
|
||
while true; do | ||
LOG_OUTPUT=$(logcli -o raw --tls-skip-verify \ | ||
--bearer-token="${TOKEN}" \ | ||
--addr "https://${LOKI_URL}/api/logs/v1/application" query '{log_type="application"}') | ||
|
||
if echo "$LOG_OUTPUT" | jq -e ' | ||
. as $root | | ||
select( | ||
.body == "the message" and | ||
.severity == "Info" and | ||
.attributes.app == "server" and | ||
.resources."k8s.container.name" == "telemetrygen" and | ||
.resources."k8s.namespace.name" == "chainsaw-incllogs" | ||
) | ||
' > /dev/null; then | ||
echo "Logs found:" | ||
break | ||
else | ||
echo "Logs not found. Continuing to check..." | ||
sleep 5 | ||
fi | ||
done |
7 changes: 7 additions & 0 deletions
7
tests/e2e-openshift/export-to-cluster-logging-lokistack/generate-logs-assert.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: telemetrygen | ||
namespace: chainsaw-incllogs | ||
status: | ||
active: 1 |
20 changes: 20 additions & 0 deletions
20
tests/e2e-openshift/export-to-cluster-logging-lokistack/generate-logs.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: telemetrygen | ||
namespace: chainsaw-incllogs | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: telemetrygen | ||
image: ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:v0.106.1 | ||
args: | ||
- logs | ||
- --otlp-endpoint=otel-collector.openshift-logging.svc.cluster.local:4317 | ||
- --otlp-insecure | ||
- --workers=1 | ||
- --duration=120s | ||
- --otlp-attributes=k8s.container.name="telemetrygen" | ||
restartPolicy: Never | ||
backoffLimit: 4 |
Oops, something went wrong.