forked from openshift/distributed-tracing-qe
-
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.
Merge pull request openshift#47 from IshwarKanse/groupbyattrs
Add test case for groupbyattrsprocessor
- Loading branch information
Showing
13 changed files
with
369 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
name: groupbyattrsprocessor | ||
spec: | ||
namespace: chainsaw-gba | ||
description: | ||
steps: | ||
- name: Enable user workload monitoring | ||
try: | ||
- apply: | ||
file: workload-monitoring.yaml | ||
- assert: | ||
file: workload-monitoring-assert.yaml | ||
- name: Create OTEl collector with kubletstats receiver | ||
try: | ||
- apply: | ||
file: otel-collector.yaml | ||
- assert: | ||
file: otel-collector-assert.yaml | ||
- name: Create OTEL collector with groupbyattrs processor | ||
try: | ||
- apply: | ||
file: otel-groupbyattributes.yaml | ||
- assert: | ||
file: otel-groupbyattributes-assert.yaml | ||
- name: Check the groupbyattrs metrics | ||
try: | ||
- apply: | ||
file: monitoring-view-role.yaml | ||
- script: | ||
timeout: 5m | ||
content: ./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,26 @@ | ||
#!/bin/bash | ||
|
||
TOKEN=$(oc create token prometheus-user-workload -n openshift-user-workload-monitoring) | ||
THANOS_QUERIER_HOST=$(oc get route thanos-querier -n openshift-monitoring -o json | jq -r '.spec.host') | ||
|
||
#Check metrics for OpenTelemetry collector instance. | ||
metrics="otelcol_processor_groupbyattrs_metric_groups_sum otelcol_processor_groupbyattrs_num_non_grouped_metrics otelcol_processor_groupbyattrs_metric_groups_bucket otelcol_processor_groupbyattrs_metric_groups_count" | ||
|
||
for metric in $metrics; do | ||
query="$metric" | ||
count=0 | ||
|
||
# Keep fetching and checking the metrics until metrics with value is present. | ||
while [[ $count -eq 0 ]]; do | ||
response=$(curl -k -H "Authorization: Bearer $TOKEN" -H "Content-type: application/json" "https://$THANOS_QUERIER_HOST/api/v1/query?query=$query") | ||
count=$(echo "$response" | jq -r '.data.result | length') | ||
|
||
if [[ $count -eq 0 ]]; then | ||
echo "No metric '$metric' with value present. Retrying..." | ||
sleep 5 # Wait for 5 seconds before retrying | ||
else | ||
echo "Metric '$metric' with value is present." | ||
fi | ||
done | ||
done | ||
|
23 changes: 23 additions & 0 deletions
23
tests/e2e-otel/groupbyattrsprocessor/monitoring-view-role.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,23 @@ | ||
# Add the clusterrole and rolebinding required for fetching metrics from Thanos querier. Refer https://issues.redhat.com/browse/MON-3379 | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: chainsaw-gba | ||
rules: | ||
- apiGroups: ["monitoring.coreos.com"] | ||
resources: ["prometheuses/api"] | ||
verbs: ["get", "list", "watch"] | ||
|
||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: chainsaw-gba | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: chainsaw-gba | ||
subjects: | ||
- kind: ServiceAccount | ||
name: prometheus-user-workload | ||
namespace: openshift-user-workload-monitoring |
64 changes: 64 additions & 0 deletions
64
tests/e2e-otel/groupbyattrsprocessor/otel-collector-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,64 @@ | ||
apiVersion: project.openshift.io/v1 | ||
kind: Project | ||
metadata: | ||
name: chainsaw-gba | ||
status: | ||
phase: Active | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: chainsaw-gba | ||
namespace: chainsaw-gba | ||
|
||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: chainsaw-gba-role | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- nodes/stats | ||
verbs: | ||
- get | ||
- watch | ||
- list | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- nodes/proxy | ||
verbs: | ||
- get | ||
|
||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: chainsaw-gba-binding | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: chainsaw-gba-role | ||
subjects: | ||
- kind: ServiceAccount | ||
name: chainsaw-gba | ||
namespace: chainsaw-gba | ||
|
||
--- | ||
apiVersion: apps/v1 | ||
kind: DaemonSet | ||
metadata: | ||
name: chainsaw-gba-collector | ||
namespace: chainsaw-gba | ||
spec: | ||
updateStrategy: | ||
rollingUpdate: | ||
maxSurge: 0 | ||
maxUnavailable: 1 | ||
type: RollingUpdate | ||
status: | ||
numberMisscheduled: 0 | ||
(desiredNumberScheduled == numberReady): 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,70 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: chainsaw-gba | ||
namespace: chainsaw-gba | ||
|
||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: chainsaw-gba-role | ||
rules: | ||
- apiGroups: [''] | ||
resources: ['nodes/stats'] | ||
verbs: ['get', 'watch', 'list'] | ||
- apiGroups: [""] | ||
resources: ["nodes/proxy"] | ||
verbs: ["get"] | ||
|
||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: chainsaw-gba-binding | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: chainsaw-gba-role | ||
subjects: | ||
- kind: ServiceAccount | ||
name: chainsaw-gba | ||
namespace: chainsaw-gba | ||
|
||
--- | ||
apiVersion: opentelemetry.io/v1alpha1 | ||
kind: OpenTelemetryCollector | ||
metadata: | ||
name: chainsaw-gba | ||
namespace: chainsaw-gba | ||
spec: | ||
mode: daemonset | ||
image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.98.0 | ||
serviceAccount: chainsaw-gba | ||
serviceAccountName: chainsaw-gba | ||
env: | ||
- name: K8S_NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
config: | | ||
receivers: | ||
kubeletstats: | ||
collection_interval: 20s | ||
auth_type: "serviceAccount" | ||
endpoint: "https://${env:K8S_NODE_NAME}:10250" | ||
insecure_skip_verify: true | ||
exporters: | ||
otlp: | ||
endpoint: gba-main-collector.chainsaw-gba.svc:4317 | ||
tls: | ||
insecure: true | ||
service: | ||
pipelines: | ||
metrics: | ||
receivers: [kubeletstats] | ||
exporters: [otlp] | ||
tolerations: | ||
- key: node-role.kubernetes.io/master | ||
operator: Exists | ||
effect: NoSchedule |
32 changes: 32 additions & 0 deletions
32
tests/e2e-otel/groupbyattrsprocessor/otel-groupbyattributes-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,32 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: gba-main-collector | ||
namespace: chainsaw-gba | ||
status: | ||
availableReplicas: 1 | ||
readyReplicas: 1 | ||
replicas: 1 | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: gba-main-collector | ||
namespace: chainsaw-gba | ||
spec: | ||
ports: | ||
- appProtocol: grpc | ||
name: otlp-grpc | ||
port: 4317 | ||
protocol: TCP | ||
targetPort: 4317 | ||
- name: prometheus | ||
port: 8889 | ||
protocol: TCP | ||
targetPort: 8889 | ||
selector: | ||
app.kubernetes.io/component: opentelemetry-collector | ||
app.kubernetes.io/instance: chainsaw-gba.gba-main | ||
app.kubernetes.io/managed-by: opentelemetry-operator | ||
app.kubernetes.io/part-of: opentelemetry |
39 changes: 39 additions & 0 deletions
39
tests/e2e-otel/groupbyattrsprocessor/otel-groupbyattributes.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 @@ | ||
apiVersion: opentelemetry.io/v1alpha1 | ||
kind: OpenTelemetryCollector | ||
metadata: | ||
name: gba-main | ||
namespace: chainsaw-gba | ||
spec: | ||
mode: deployment | ||
image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.98.0 | ||
observability: | ||
metrics: | ||
enableMetrics: true | ||
config: | | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
processors: | ||
groupbyattrs: | ||
keys: | ||
- k8s.namespace.name | ||
- k8s.container.name | ||
- k8s.pod.name | ||
batch: | ||
attributes: | ||
actions: | ||
- key: otelpipeline | ||
value: gba | ||
action: insert | ||
exporters: | ||
prometheus: | ||
endpoint: 0.0.0.0:8889 | ||
resource_to_telemetry_conversion: | ||
enabled: true # by default resource attributes are dropped | ||
service: | ||
pipelines: | ||
metrics: | ||
receivers: [otlp] | ||
processors: [attributes, batch, groupbyattrs] | ||
exporters: [prometheus] |
28 changes: 28 additions & 0 deletions
28
tests/e2e-otel/groupbyattrsprocessor/workload-monitoring-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,28 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: prometheus-operator | ||
namespace: openshift-user-workload-monitoring | ||
(status.replicas == spec.replicas): true | ||
spec: | ||
(replicas >= `1`): true | ||
|
||
--- | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: prometheus-user-workload | ||
namespace: openshift-user-workload-monitoring | ||
(status.replicas == spec.replicas): true | ||
spec: | ||
(replicas >= `1`): true | ||
|
||
--- | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: thanos-ruler-user-workload | ||
namespace: openshift-user-workload-monitoring | ||
(status.replicas == spec.replicas): true | ||
spec: | ||
(replicas >= `1`): true |
11 changes: 11 additions & 0 deletions
11
tests/e2e-otel/groupbyattrsprocessor/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
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
Oops, something went wrong.