Skip to content

Commit

Permalink
feat(demo): add demo using OpenObserve's OTLP GRPC ingestion
Browse files Browse the repository at this point in the history
Signed-off-by: Szilard Parrag <szilard.parrag@axoflow.com>
  • Loading branch information
OverOrion committed Feb 2, 2024
1 parent ebd679c commit f818b75
Show file tree
Hide file tree
Showing 3 changed files with 219 additions and 0 deletions.
73 changes: 73 additions & 0 deletions demos/openobserve/demo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
apiVersion: v1
kind: Namespace
metadata:
name: collector
---
apiVersion: v1
kind: Namespace
metadata:
labels:
nsSelector: example-tenant
name: example-tenant-ns
---
apiVersion: telemetry.kube-logging.dev/v1alpha1
kind: Collector
metadata:
name: example-collector
spec:
controlNamespace: collector
tenantSelector:
matchLabels:
collectorLabel: example-collector
---
apiVersion: telemetry.kube-logging.dev/v1alpha1
kind: Tenant
metadata:
labels:
collectorLabel: example-collector
name: example-tenant
spec:
subscriptionNamespaceSelectors:
- matchLabels:
nsSelector: example-tenant
logSourceNamespaceSelectors:
- matchLabels:
nsSelector: example-tenant
---
apiVersion: telemetry.kube-logging.dev/v1alpha1
kind: Subscription
metadata:
name: subscription-sample-1
namespace: example-tenant-ns
spec:
ottl: 'route()'
outputs:
- name: otlp-openobserve
namespace: collector
---
apiVersion: telemetry.kube-logging.dev/v1alpha1
kind: Subscription
metadata:
name: subscription-sample-2
namespace: example-tenant-ns
spec:
ottl: 'route()'
outputs:
- name: otlp-openobserve
namespace: collector
---
apiVersion: telemetry.kube-logging.dev/v1alpha1
kind: OtelOutput
metadata:
name: otlp-openobserve
namespace: collector
spec:
otlp:
endpoint: openobserve-otlp-grpc.openobserve.svc.cluster.local:5081
headers:
# Add token from Web UI manually as there is no way to query it
Authorization: "Basic cm9vdEBleGFtcGxlLmNvbTp1TzU4QmFaeXAzeDZRUDlZ" # echo -n username:pwd | base64
organization: default
stream-name: default
tls:
insecure: true
145 changes: 145 additions & 0 deletions demos/openobserve/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
#!/usr/bin/env bash
KIND_CLUSTER_NAME=${KIND_CLUSTER_NAME:-kind}

# Install OpenObserve
kubectl create namespace openobserve

kubectl apply -f - <<EOF
apiVersion: v1
kind: Service
metadata:
name: openobserve
namespace: openobserve
spec:
clusterIP: None
selector:
app: openobserve
ports:
- name: http
port: 5080
targetPort: 5080
---
apiVersion: v1
kind: Service
metadata:
name: openobserve-otlp-grpc
namespace: openobserve
spec:
clusterIP: None
selector:
app: openobserve
ports:
- name: otlp-grpc
port: 5081
targetPort: 5081
---
# create statefulset
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: openobserve
namespace: openobserve
labels:
name: openobserve
spec:
serviceName: openobserve
replicas: 1
selector:
matchLabels:
name: openobserve
app: openobserve
template:
metadata:
labels:
name: openobserve
app: openobserve
spec:
securityContext:
fsGroup: 2000
runAsUser: 10000
runAsGroup: 3000
runAsNonRoot: true
# terminationGracePeriodSeconds: 0
containers:
- name: openobserve
image: public.ecr.aws/zinclabs/openobserve:v0.7.2
env:
- name: ZO_ROOT_USER_EMAIL
value: root@example.com
- name: ZO_ROOT_USER_PASSWORD
value: Complexpass#123
- name: ZO_DATA_DIR
value: /data
# command: ["/bin/bash", "-c", "while true; do sleep 1; done"]
imagePullPolicy: Always
resources:
limits:
cpu: 4096m
memory: 2048Mi
requests:
cpu: 256m
memory: 50Mi
ports:
- containerPort: 5080
name: http
- containerPort: 50801
name: otlp-grpc
volumeMounts:
- name: data
mountPath: /data
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes:
- ReadWriteOnce
# storageClassName: default
# NOTE: You can increase the storage size
resources:
requests:
storage: 10Gi
EOF

# Check for readiness
while
echo "Waiting for OpenObserve pod to be running"
kubectl get pods -n openobserve | grep -qi "running"

[[ $? -ne 0 ]]
do sleep 3; done

# Install prerequisites

helm upgrade \
--install \
--repo https://charts.jetstack.io \
cert-manager cert-manager \
--namespace cert-manager \
--create-namespace \
--version v1.13.3 \
--set installCRDs=true \
--wait

kubectl apply -f https://github.com/open-telemetry/opentelemetry-operator/releases/latest/download/opentelemetry-operator.yaml --wait
echo "Wait until otel operator pod is in ready state..."
kubectl wait --namespace opentelemetry-operator-system --for=condition=available deployment/opentelemetry-operator-controller-manager --timeout=300s


(cd ../.. && make manifests generate install)

cd ../../ && make docker-build
kind load docker-image controller:latest --name "${KIND_CLUSTER_NAME}"
make deploy && cd -

kubectl apply -f ./demo.yaml


# OpenObserve UI
kubectl -n openobserve port-forward svc/openobserve 5080:5080 &
# OpenObserve OTLP GRPC
#kubectl -n openobserve port-forward svc/openobserve-otlp-grpc 5081:5081 &
sleep 5

# Create log-generator
helm install --wait --create-namespace --namespace example-tenant-ns --generate-name oci://ghcr.io/kube-logging/helm-charts/log-generator
1 change: 1 addition & 0 deletions internal/controller/telemetry/otel_conf_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func (cfgInput *OtelColConfigInput) generateOTLPExporters() map[string]any {
name := fmt.Sprintf("otlp/%s_%s", output.Namespace, output.Name)
result[name] = map[string]any{
"endpoint": output.Spec.OTLP.GRPCClientSettings.Endpoint,
"headers": output.Spec.OTLP.Headers,
"tls": map[string]any{
"insecure": output.Spec.OTLP.TLSSetting.Insecure,
},
Expand Down

0 comments on commit f818b75

Please sign in to comment.