-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
- Loading branch information
1 parent
975a98e
commit 23dc144
Showing
12 changed files
with
242 additions
and
153 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,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 |
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,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 |
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,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 ] |
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.