-
Notifications
You must be signed in to change notification settings - Fork 34
K8s auto-instrumentation details and example (Node.js) #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
03f6d51
instrumenting-nodejs.md draft added
eedugon 930a908
commented section made visible
eedugon 933a774
getting started guide link updated
eedugon df8b32c
example removed
eedugon d2a8261
example removed
eedugon 90f4db5
example removed
eedugon 49f8239
example removed
eedugon c9da9b0
Merge branch 'main' into k8s_instrumenting_nodejs
eedugon 4a15e4d
content aligned with other guides, indentation fixed, and Trent's sug…
eedugon 890b8cb
pods made plural
eedugon 366ee27
traffic generation tip added
eedugon b2be789
Update docs/kubernetes/operator/instrumenting-nodejs.md
eedugon dce176c
kubectl port-forward link added
eedugon 4afebb4
Update docs/kubernetes/operator/instrumenting-nodejs.md
eedugon 9c94031
Update docs/kubernetes/operator/instrumenting-nodejs.md
eedugon ccb8af5
Update docs/kubernetes/operator/instrumenting-nodejs.md
eedugon 78a54d5
Update docs/kubernetes/operator/instrumenting-nodejs.md
eedugon 5e0cfe1
indentation and minor fixes
eedugon 543dd99
link to nodejs doc added in instrumenting_applications.md
eedugon 2839fcc
link to nodejs doc added in instrumenting_applications.md
eedugon e5bbaae
removed port-forward hint because the user should know how to generat…
eedugon 94b095e
Update docs/kubernetes/operator/instrumenting-nodejs.md
eedugon fbb486d
env var check sentence moved upwards
eedugon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,94 @@ | ||
| # Instrumenting Node.js applications with EDOT SDKs on Kubernetes | ||
|
|
||
| This document focuses on instrumenting Node.js applications on Kubernetes, using [Elastic Distribution of OpenTelemetry Node.js (EDOT Node.js)](https://github.com/elastic/elastic-otel-nodejs) together with the OpenTelemetry Operator and the EDOT Collectors described in the [getting started](./README.md) guide. | ||
|
|
||
| For general knowledge about the EDOT Node.js SDK, refer to the [getting started guide](https://github.com/elastic/elastic-otel-node/blob/main/packages/opentelemetry-node/docs/get-started.md) and [configuration](https://github.com/elastic/elastic-otel-node/blob/main/packages/opentelemetry-node/docs/configure.md). | ||
|
|
||
| For general information about instrumenting applications on kubernetes, refer to [instrumenting applications](./instrumenting-applications.md). | ||
|
|
||
| (TBD / PENDING: extra topics or relevant details about Node.js specifics for Kubernetes, if any). | ||
|
|
||
| ## Guided example to instrument a Node.js app with EDOT Node.js SDK on Kubernetes | ||
|
|
||
| <!-- | ||
| Useful links: | ||
| - Example: https://github.com/elastic/elastic-otel-node/tree/main/examples/otel-operator/ documented at https://github.com/elastic/elastic-otel-node/blob/main/DEVELOPMENT.md#testing-k8s-auto-instrumentation-with-otel-operator | ||
| (not user friendly, but we could use it in the future if we want to add a proper example here) | ||
| --> | ||
|
|
||
| In this section you will learn how to: | ||
|
|
||
| - Enable auto-instrumentation of a Node.js application following any of the supported methods, such as: | ||
| - Adding an annotation to the deployment pods. | ||
| - Adding an annotation to the namespace. | ||
| - Verify that auto-instrumentation libraries are injected and configured correctly. | ||
| - Confirm data is flowing to **Kibana Observability**. | ||
|
|
||
| For demonstration purposes, we assume the application to be instrumented is a deployment named `nodejs-app` running in the `nodejs-ns` namespace. | ||
|
|
||
| 1. Ensure you have successfully [installed the OpenTelemetry Operator](./README.md), and confirm that the following `Instrumentation` object exists in the system: | ||
|
|
||
| ```bash | ||
| $ kubectl get instrumentation -n opentelemetry-operator-system | ||
| NAME AGE ENDPOINT | ||
| elastic-instrumentation 107s http://opentelemetry-kube-stack-daemon-collector.opentelemetry-operator-system.svc.cluster.local:4318 | ||
| ``` | ||
| > [!NOTE] | ||
| > If your `Instrumentation` object has a different name or is created in a different namespace, you will have to adapt the annotation value in the next step. | ||
|
|
||
| 2. Enable auto-instrumentation of the Node.js application using one of the following methods: | ||
|
|
||
| - Edit the workload definition and include the annotation under `spec.template.metadata.annotations`: | ||
eedugon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```yaml | ||
| spec: | ||
| ... | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: nodejs-app | ||
| annotations: | ||
| instrumentation.opentelemetry.io/inject-nodejs: opentelemetry-operator-system/elastic-instrumentation | ||
| ... | ||
| ``` | ||
|
|
||
| - Alternatively, add the annotation at namespace level to apply auto-instrumentation in all Pods of the namespace: | ||
|
|
||
| ```bash | ||
| kubectl annotate namespace nodejs-ns instrumentation.opentelemetry.io/inject-nodejs=opentelemetry-operator-system/elastic-instrumentation | ||
| ``` | ||
|
|
||
| 3. Restart application: | ||
|
|
||
| Once the annotation has been set, the Pods need to be recreated for the instrumentation libraries to be injected. | ||
|
|
||
| ```bash | ||
| kubectl rollout restart deployment nodejs-app -n nodejs | ||
| ``` | ||
|
|
||
| 4. Verify the auto-instrumentation resources are injected in the Pod: | ||
|
|
||
| Node.js apps are instrumented by the OpenTelemetry Operator with the following actions: | ||
| (TBD / WE NEED TO REVIEW HOW THIS IS DONE / NODE_OPTIONS env var?) | ||
|
|
||
| - ??It adds an init container in the Pod with the objective of copying the SDK to a shared volume. | ||
|
|
||
| - ??Defines an `emptyDir volume` mounted in both containers. | ||
|
|
||
| - ??Adds `NODE_OPTIONS` and other OTEL related environment variables. | ||
eedugon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 5. Confirm data is flowing through in **Kibana**: | ||
eedugon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - Open Observability -> Applications -> Service Inventory, and determine if: | ||
eedugon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - The application appears in the list of services. | ||
eedugon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - The application shows transactions and metrics. | ||
eedugon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - For application container logs, open **Kibana Discover** and filter for your pods logs. In the provided example we could filter them with any of: | ||
eedugon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - `k8s.deployment.name: "nodejs-app"` (**adapt the query filter to your use case**) | ||
| - `k8s.pod.name: nodejs-app*` (**adapt the query filter to your use case**) | ||
|
|
||
| Note that the container logs are not provided by the instrumentation library, but by the DaemonSet collector deployed as part of the [operator installation](./README.md). | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| - Refer to [troubleshoot auto-instrumentation](./troubleshoot-auto-instrumentation.md) for further analysis. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.