Skip to content

Commit

Permalink
latest updates
Browse files Browse the repository at this point in the history
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
  • Loading branch information
jpkrohling committed Nov 7, 2024
1 parent 975a98e commit 23dc144
Show file tree
Hide file tree
Showing 12 changed files with 242 additions and 153 deletions.
52 changes: 52 additions & 0 deletions auto-instrumentation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 🍜 Recipe: Auto-instrumentation

TODO

## 🧄 Ingredients

- OpenTelemetry Operator, see the main [`README.md`](../README.md) for instructions
- A non-instrumented application written in a language that has auto-instrumentation support, such as Keycloak (Java)
- The `otelcol-cr.yaml` file from this directory
- A `GRAFANA_CLOUD_USER` environment variable, also known as Grafana Cloud instance ID, found under the instructions for "OpenTelemetry" on your Grafana Cloud stack.
- A `GRAFANA_CLOUD_TOKEN` environment variable, which can be generated under the instructions for "OpenTelemetry" on your Grafana Cloud stack.
- The endpoint for your stack

## 🥣 Preparation

1. Create and switch to a namespace for our recipe
```terminal
kubectl create ns auto-instrumentation
kubens auto-instrumentation
```

2. Create a secret with the credentials:
```terminal
kubectl create secret generic grafana-cloud-credentials --from-literal=GRAFANA_CLOUD_USER="$GRAFANA_CLOUD_USER" --from-literal=GRAFANA_CLOUD_TOKEN="$GRAFANA_CLOUD_TOKEN"
```

3. Change the `endpoint` parameter for the `otlphttp` exporter to point to your stack's endpoint

4. Install the OTel Collector custom resource
```terminal
kubectl apply -f auto-instrumentation/otelcol-cr.yaml
```

5. Install the application to be instrumented, like Keycloak
```terminal
kubectl apply -f auto-instrumentation/keycloak.yaml
```

6. Play with the application, so that it generates telemetry
```terminal
kubectl port-forward svc/keycloak 8080
```

7. Open your Grafana instance, go to Explore, and select the appropriate datasource, such as "...-traces". If used the command above, click "Search" and you should see two traces listed, each with two spans.

## 😋 Executed last time with these versions

The most recent execution of this recipe was done with these versions:

- OpenTelemetry Operator v0.100.1
- OpenTelemetry Collector Contrib v0.101.0
- `telemetrygen` v0.101.0
51 changes: 51 additions & 0 deletions auto-instrumentation/keycloak.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: v1
kind: Service
metadata:
name: keycloak
labels:
app: keycloak
spec:
ports:
- name: http
port: 8080
targetPort: 8080
selector:
app: keycloak
type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: keycloak
labels:
app: keycloak
spec:
replicas: 1
selector:
matchLabels:
app: keycloak
template:
metadata:
labels:
app: keycloak
annotations:
instrumentation.opentelemetry.io/inject-java: "true"
spec:
containers:
- name: keycloak
image: quay.io/keycloak/keycloak:25.0.2
args: ["start-dev"]
env:
- name: KEYCLOAK_ADMIN
value: "admin"
- name: KEYCLOAK_ADMIN_PASSWORD
value: "admin"
- name: KC_PROXY
value: "edge"
ports:
- name: http
containerPort: 8080
readinessProbe:
httpGet:
path: /realms/master
port: 8080
56 changes: 56 additions & 0 deletions auto-instrumentation/otelcol-cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
apiVersion: opentelemetry.io/v1alpha1
kind: Instrumentation
metadata:
name: java
spec:
env:
- name: OTEL_TRACES_EXPORTER
value: otlp
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: http://auto-instrumentation-collector-headless.auto-instrumentation.svc.cluster.local:4317
exporter:
endpoint: http://auto-instrumentation-collector-headless.auto-instrumentation.svc.cluster.local:4317
---
apiVersion: opentelemetry.io/v1beta1
kind: OpenTelemetryCollector
metadata:
name: auto-instrumentation
spec:
image: ghcr.io/jpkrohling/otelcol-distributions/otelcol-otlp:0.101.5
envFrom:
- secretRef:
name: grafana-cloud-credentials
config:
extensions:
basicauth:
client_auth:
username: "${env:GRAFANA_CLOUD_USER}"
password: "${env:GRAFANA_CLOUD_TOKEN}"

receivers:
otlp:
protocols:
grpc: {}

exporters:
otlphttp:
endpoint: https://otlp-gateway-prod-eu-west-2.grafana.net/otlp
auth:
authenticator: basicauth

service:
extensions: [ basicauth ]
pipelines:
traces:
receivers: [ otlp ]
processors: [ ]
exporters: [ otlphttp ]
logs:
receivers: [ otlp ]
processors: [ ]
exporters: [ otlphttp ]
metrics:
receivers: [ otlp ]
processors: [ ]
exporters: [ otlphttp ]
3 changes: 2 additions & 1 deletion kafka-on-kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Note that we've used the `transform` processor to add the current timestamp to a
- OpenTelemetry Operator, see the main [`README.md`](../README.md) for instructions
- A Kafka Cluster and one topic for each telemetry data type (metric, logs, traces)
- The `telemetrygen` tool, or any other application that is able to send OTLP data to our collector
- The `otelcol-cr.yaml` file from this directory
- The `otelcol-pub.yaml` file from this directory
- The `otelcol-sub.yaml` file from this directory
- A `GRAFANA_CLOUD_USER` environment variable, also known as Grafana Cloud instance ID, found under the instructions for "OpenTelemetry" on your Grafana Cloud stack.
- A `GRAFANA_CLOUD_TOKEN` environment variable, which can be generated under the instructions for "OpenTelemetry" on your Grafana Cloud stack.
- The endpoint for your stack
Expand Down
2 changes: 1 addition & 1 deletion kafka-on-kubernetes/otelcol-pub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: OpenTelemetryCollector
metadata:
name: otelcol-pub
spec:
image: ghcr.io/jpkrohling/otelcol-distributions/otelcol-kafka:0.101.5
image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.113.0
config:
receivers:
otlp:
Expand Down
2 changes: 1 addition & 1 deletion kafka-on-kubernetes/otelcol-sub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: OpenTelemetryCollector
metadata:
name: otelcol-sub
spec:
image: ghcr.io/jpkrohling/otelcol-distributions/otelcol-kafka:0.101.5
image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.113.0
envFrom:
- secretRef:
name: grafana-cloud-credentials
Expand Down
4 changes: 2 additions & 2 deletions own-telemetry/otelcol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ service:
endpoint: https://otlp-gateway-prod-eu-west-2.grafana.net/otlp/v1/traces
protocol: http/protobuf
headers:
Authorization: "Basic ..."
Authorization: "Basic OTQyNzM4OmdsY19leUp2SWpvaU5USTVNemN4SWl3aWJpSTZJbk4wWVdOckxUazBNamN6T0MxdmRHeHdMWGR5YVhSbExYUnZhMlZ1TFRJd01qUXRNVEV0TURjaUxDSnJJam9pT0cwNFJWbzBTbkkwV2tKMk1USTNTall5T1hKamMwSjVJaXdpYlNJNmV5SnlJam9pY0hKdlpDMWxkUzEzWlhOMExUSWlmWDA9"
metrics:
level: detailed
readers:
Expand All @@ -38,6 +38,6 @@ service:
endpoint: https://otlp-gateway-prod-eu-west-2.grafana.net/otlp/v1/metrics
protocol: http/protobuf
headers:
Authorization: "Basic ..."
Authorization: "Basic OTQyNzM4OmdsY19leUp2SWpvaU5USTVNemN4SWl3aWJpSTZJbk4wWVdOckxUazBNamN6T0MxdmRHeHdMWGR5YVhSbExYUnZhMlZ1TFRJd01qUXRNVEV0TURjaUxDSnJJam9pT0cwNFJWbzBTbkkwV2tKMk1USTNTall5T1hKamMwSjVJaXdpYlNJNmV5SnlJam9pY0hKdlpDMWxkUzEzWlhOMExUSWlmWDA9"
resource:
"service.name": "otelcol-own-telemetry"
3 changes: 2 additions & 1 deletion profiling-the-collector/otelcol-cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: OpenTelemetryCollector
metadata:
name: profiling-the-collector
spec:
image: ghcr.io/jpkrohling/otelcol-distributions/otelcol-otlp:0.101.5
image: ghcr.io/jpkrohling/otelcol-distributions/opentelemetry-collector-otlp:0.108.1
config:
extensions:
pprof:
Expand All @@ -13,6 +13,7 @@ spec:
otlp:
protocols:
grpc: {}
http: {}

exporters:
nop: {}
Expand Down
108 changes: 0 additions & 108 deletions ratatouille/kubernetes/k8sevents/k8sevents.yaml

This file was deleted.

19 changes: 0 additions & 19 deletions ratatouille/kubernetes/k8sevents/workload.yaml

This file was deleted.

Loading

0 comments on commit 23dc144

Please sign in to comment.