-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functional test for OTLP metrics collection and forward to promet…
…heus (#1850) Signed-off-by: Ishwar Kanse <[email protected]> Co-authored-by: Tyler Helmuth <[email protected]>
- Loading branch information
1 parent
92e5dee
commit e0d3fe8
Showing
17 changed files
with
293 additions
and
0 deletions.
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
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
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,6 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestSuite | ||
startKIND: false | ||
testDirs: | ||
- ./tests/e2e-openshift/ | ||
timeout: 150 |
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,10 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
namespace: kuttl-otlp-metrics | ||
name: jaeger-allinone | ||
status: | ||
availableReplicas: 1 | ||
readyReplicas: 1 | ||
replicas: 1 |
18 changes: 18 additions & 0 deletions
18
tests/e2e-openshift/otlp-metrics-traces/00-install-jaeger.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,18 @@ | ||
#Create the "kuttl-otlp-metrics" project to fulfill the requirement of specifying the Jaeger and OTEL collector endpoints. This project is essential due to KUTTL's current lack of support for templating. | ||
#For this test case you'll need to install the Jaeger operator (OpenShift Distributed Tracing Platform in OpenShift) | ||
|
||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: kuttl-otlp-metrics | ||
|
||
--- | ||
apiVersion: jaegertracing.io/v1 | ||
kind: Jaeger | ||
metadata: | ||
name: jaeger-allinone | ||
namespace: kuttl-otlp-metrics | ||
spec: | ||
strategy: allinone | ||
ingress: | ||
security: none |
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,22 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
namespace: openshift-user-workload-monitoring | ||
status: | ||
availableReplicas: 1 | ||
readyReplicas: 1 | ||
replicas: 1 | ||
|
||
--- | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
namespace: openshift-user-workload-monitoring | ||
status: | ||
availableReplicas: 2 | ||
currentReplicas: 2 | ||
readyReplicas: 2 | ||
replicas: 2 | ||
updatedReplicas: 2 | ||
|
11 changes: 11 additions & 0 deletions
11
tests/e2e-openshift/otlp-metrics-traces/01-workload-monitoring.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,11 @@ | ||
# oc -n openshift-user-workload-monitoring get pod | ||
# https://docs.openshift.com/container-platform/4.13/monitoring/enabling-monitoring-for-user-defined-projects.html#accessing-metrics-from-outside-cluster_enabling-monitoring-for-user-defined-projects | ||
|
||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: cluster-monitoring-config | ||
namespace: openshift-monitoring | ||
data: | ||
config.yaml: | | ||
enableUserWorkload: true |
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,9 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
namespace: kuttl-otlp-metrics | ||
status: | ||
availableReplicas: 1 | ||
readyReplicas: 1 | ||
replicas: 1 |
39 changes: 39 additions & 0 deletions
39
tests/e2e-openshift/otlp-metrics-traces/02-otel-metrics-collector.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,39 @@ | ||
#https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/prometheusexporter/README.md | ||
|
||
apiVersion: opentelemetry.io/v1alpha1 | ||
kind: OpenTelemetryCollector | ||
metadata: | ||
name: cluster-collector | ||
namespace: kuttl-otlp-metrics | ||
spec: | ||
mode: deployment | ||
ports: | ||
- name: promexporter | ||
port: 8889 | ||
protocol: TCP | ||
config: | | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
http: | ||
processors: | ||
exporters: | ||
jaeger: | ||
endpoint: jaeger-allinone-collector-headless.kuttl-otlp-metrics.svc:14250 | ||
tls: | ||
ca_file: "/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt" | ||
prometheus: | ||
endpoint: 0.0.0.0:8889 | ||
resource_to_telemetry_conversion: | ||
enabled: true # by default resource attributes are dropped | ||
service: | ||
pipelines: | ||
traces: | ||
receivers: [otlp] | ||
processors: [] | ||
exporters: [jaeger] | ||
metrics: | ||
receivers: [otlp] | ||
processors: [] | ||
exporters: [prometheus] |
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,25 @@ | ||
--- | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: PodMonitor | ||
metadata: | ||
name: otel-collector | ||
namespace: kuttl-otlp-metrics | ||
spec: | ||
podMetricsEndpoints: | ||
- port: metrics | ||
- metricRelabelings: | ||
- action: labeldrop | ||
regex: instance | ||
- action: labeldrop | ||
regex: job | ||
port: promexporter | ||
relabelings: | ||
- action: labeldrop | ||
regex: pod | ||
- action: labeldrop | ||
regex: container | ||
- action: labeldrop | ||
regex: endpoint | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: cluster-collector-collector |
26 changes: 26 additions & 0 deletions
26
tests/e2e-openshift/otlp-metrics-traces/03-podmonitor.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,26 @@ | ||
#https://docs.openshift.com/container-platform/4.13/monitoring/managing-metrics.html | ||
#https://docs.openshift.com/container-platform/4.13/rest_api/monitoring_apis/podmonitor-monitoring-coreos-com-v1.html | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: PodMonitor | ||
metadata: | ||
name: otel-collector | ||
namespace: kuttl-otlp-metrics | ||
spec: | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: cluster-collector-collector | ||
podMetricsEndpoints: | ||
- port: metrics | ||
- port: promexporter | ||
relabelings: | ||
- action: labeldrop | ||
regex: pod | ||
- action: labeldrop | ||
regex: container | ||
- action: labeldrop | ||
regex: endpoint | ||
metricRelabelings: | ||
- action: labeldrop | ||
regex: instance | ||
- action: labeldrop | ||
regex: job |
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,22 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: telemetrygen-traces | ||
status: | ||
active: 1 | ||
ready: 1 | ||
|
||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: telemetrygen-metrics | ||
status: | ||
active: 1 | ||
ready: 1 | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
status: | ||
phase: Running |
52 changes: 52 additions & 0 deletions
52
tests/e2e-openshift/otlp-metrics-traces/04-metrics-traces-gen.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,52 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: telemetrygen-traces | ||
spec: | ||
completions: 1 | ||
parallelism: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: telemetrygen-traces | ||
spec: | ||
containers: | ||
- name: telemetrygen-traces | ||
image: ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:latest | ||
command: ["./telemetrygen"] | ||
args: | ||
- "--otlp-endpoint=cluster-collector-collector-headless.kuttl-otlp-metrics.svc:4317" | ||
- "--otlp-insecure=true" | ||
- "--rate=1" | ||
- "--duration=30s" | ||
- "--otlp-attributes=telemetrygen=\"traces\"" | ||
- "--otlp-header=telemetrygen=\"traces\"" | ||
- "traces" | ||
restartPolicy: Never | ||
|
||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: telemetrygen-metrics | ||
spec: | ||
completions: 1 | ||
parallelism: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: telemetrygen-metrics | ||
spec: | ||
containers: | ||
- name: telemetrygen-metrics | ||
image: ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:latest | ||
command: ["./telemetrygen"] | ||
args: | ||
- "--otlp-endpoint=cluster-collector-collector-headless.kuttl-otlp-metrics.svc:4317" | ||
- "--otlp-insecure=true" | ||
- "--duration=30s" | ||
- "--rate=1" | ||
- "--otlp-attributes=telemetrygen=\"metrics\"" | ||
- "--otlp-header=telemetrygen=\"traces\"" | ||
- "metrics" | ||
restartPolicy: Never |
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,6 @@ | ||
--- | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
timeout: 30 | ||
commands: | ||
- script: ./tests/e2e-openshift/otlp-metrics/check_traces.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,6 @@ | ||
--- | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
timeout: 30 | ||
commands: | ||
- script: ./tests/e2e-openshift/otlp-metrics/check_metrics.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,15 @@ | ||
#!/bin/bash | ||
SECRET=$(oc get secret -n openshift-user-workload-monitoring | grep prometheus-user-workload-token | head -n 1 | awk '{print $1}') | ||
TOKEN=$(echo $(oc get secret $SECRET -n openshift-user-workload-monitoring -o json | jq -r '.data.token') | base64 -d) | ||
THANOS_QUERIER_HOST=$(oc get route thanos-querier -n openshift-monitoring -o json | jq -r '.spec.host') | ||
|
||
response=$(curl -k -H "Authorization: Bearer $TOKEN" -H "Content-type: application/json" "https://$THANOS_QUERIER_HOST/api/v1/query?query=gen") | ||
|
||
count=$(echo "$response" | jq -r '.data.result | length') | ||
|
||
if [[ $count -eq 0 ]]; then | ||
echo "No telemetrygen metrics count with value present. Exiting with status 1." | ||
exit 1 | ||
else | ||
echo "telemetrygen metrics with value is present." | ||
fi |
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,12 @@ | ||
#!/bin/bash | ||
JAEGER_URL=$(oc -n kuttl-otlp-metrics get route jaeger-allinone -o json | jq '.spec.host' -r) | ||
SERVICE_NAME="telemetrygen" | ||
|
||
trace_exists=$(curl -ksSL "https://$JAEGER_URL/api/traces?service=$SERVICE_NAME&limit=1" | jq -r '.data | length') | ||
|
||
if [[ $trace_exists -gt 0 ]]; then | ||
echo "Traces for $SERVICE_NAME exist in Jaeger." | ||
else | ||
echo "Trace for $SERVICE_NAME does not exist in Jaeger." | ||
exit 1 # Fail the test step if the trace doesn't exist | ||
fi |