Skip to content

Commit

Permalink
Fix prometheus
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <p.loffay@gmail.com>
  • Loading branch information
pavolloffay committed Oct 31, 2023
1 parent ff0eec6 commit cb74227
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 13 deletions.
8 changes: 3 additions & 5 deletions 07-correlation.md
Expand Up @@ -41,7 +41,6 @@ By default, it associates the incoming connection IP to the Pod IP.
The processor requires following RBAC to query the API server:

```yaml
kubectl apply -f - <<EOF
apiVersion: v1
kind: ServiceAccount
metadata:
Expand Down Expand Up @@ -75,7 +74,6 @@ roleRef:
kind: ClusterRole
name: otel-collector
apiGroup: rbac.authorization.k8s.io
EOF
```

```yaml
Expand All @@ -84,9 +82,9 @@ EOF
passthrough: false # when true only pod IP addresses are added, that can be used later for attributes association
extract:
annotations:
- tag_name: a1 # extracts value of annotation from pods with key `annotation-one` and inserts it as a tag with key `a1`
key: annotation-one
from: pod
- tag_name: tutorial # extracts value of annotation from pods with key `annotation-one` and inserts it as a tag with key `a1`
key: kubecon-tutorial
from: namespace
```

## Resource Detection Processor
Expand Down
2 changes: 2 additions & 0 deletions app/k8s-annotated.yaml
Expand Up @@ -2,6 +2,8 @@ apiVersion: v1
kind: Namespace
metadata:
name: tutorial-application
annotations:
kubecon-tutorial: otel-metrics
---
apiVersion: apps/v1
kind: Deployment
Expand Down
2 changes: 2 additions & 0 deletions app/k8s.yaml
Expand Up @@ -2,6 +2,8 @@ apiVersion: v1
kind: Namespace
metadata:
name: tutorial-application
annotations:
kubecon-tutorial: otel-metrics
---
apiVersion: apps/v1
kind: Deployment
Expand Down
49 changes: 41 additions & 8 deletions backend/07-collector-correlation.yaml
@@ -1,7 +1,36 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: otel-collector
rules:
- apiGroups: [""]
resources: ["pods", "namespaces"]
verbs: ["get", "watch", "list"]
- apiGroups: ["apps"]
resources: ["replicasets"]
verbs: ["get", "list", "watch"]
- apiGroups: ["extensions"]
resources: ["replicasets"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: otel-collector
subjects:
- kind: ServiceAccount
name: otel-collector
namespace: observability-backend
roleRef:
kind: ClusterRole
name: otel-collector
apiGroup: rbac.authorization.k8s.io
---
apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
name: collector-correlation
name: otel
namespace: observability-backend
spec:
image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.87.0
Expand All @@ -28,24 +57,28 @@ spec:
passthrough: false
extract:
annotations:
- tag_name: a1 # extracts value of annotation from pods with key `annotation-one` and inserts it as a tag with key `a1`
key: annotation-one
from: pod
- tag_name: tutorial # extracts value of annotation from pods with key `annotation-one` and inserts it as a tag with key `a1`
key: kubecon-tutorial
from: namespace
exporters:
debug:
verbosity: detailed
otlp/metrics:
endpoint: "http://prometheus.observability-backend.svc.cluster.local:80/api/v1/otlp/v1/metrics"
otlphttp/metrics:
endpoint: http://prometheus.observability-backend.svc.cluster.local:80/api/v1/otlp/
tls:
insecure: true
otlp/traces:
endpoint: jaeger-collector.observability-backend.svc.cluster.local:4317
tls:
insecure: true
service:
pipelines:
metrics:
receivers: [otlp]
processors: [memory_limiter, k8sattributes, batch]
exporters: [logging, prometheusremotewrite]
exporters: [debug, otlphttp/metrics]
traces:
receivers: [otlp]
processors: [memory_limiter, k8sattributes, batch]
exporters: [logging]
exporters: [otlp/traces]

0 comments on commit cb74227

Please sign in to comment.