From 4f3eb33ced1654216a0fa25bf470655fd80e39f4 Mon Sep 17 00:00:00 2001 From: Young Bu Park Date: Thu, 12 Mar 2020 21:47:19 -0700 Subject: [PATCH 1/6] add localforwarder docker and deployment yamls --- .../localforwarder/Dockerfile | 8 ++++ .../localforwarder/appinsight-tracing.yaml | 23 ++++++++++ .../localforwarder/dapr-localforwarder.yaml | 43 +++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 howto/diagnose-with-tracing/localforwarder/Dockerfile create mode 100644 howto/diagnose-with-tracing/localforwarder/appinsight-tracing.yaml create mode 100644 howto/diagnose-with-tracing/localforwarder/dapr-localforwarder.yaml diff --git a/howto/diagnose-with-tracing/localforwarder/Dockerfile b/howto/diagnose-with-tracing/localforwarder/Dockerfile new file mode 100644 index 000000000..f2e6372da --- /dev/null +++ b/howto/diagnose-with-tracing/localforwarder/Dockerfile @@ -0,0 +1,8 @@ +FROM mcr.microsoft.com/dotnet/core/runtime:2.1 +RUN mkdir /lf +WORKDIR /lf +RUN curl -LsO https://github.com/microsoft/ApplicationInsights-LocalForwarder/releases/download/v0.1-beta1/LF-ConsoleHost-linux-x64.tar.gz +RUN tar xzf LF-ConsoleHost-linux-x64.tar.gz +RUN rm -f LF-ConsoleHost-linux-x64.tar.gz +EXPOSE 6789 +ENTRYPOINT ["/lf/Microsoft.LocalForwarder.ConsoleHost", "noninteractive"] diff --git a/howto/diagnose-with-tracing/localforwarder/appinsight-tracing.yaml b/howto/diagnose-with-tracing/localforwarder/appinsight-tracing.yaml new file mode 100644 index 000000000..6ff1f60ff --- /dev/null +++ b/howto/diagnose-with-tracing/localforwarder/appinsight-tracing.yaml @@ -0,0 +1,23 @@ +--- +apiVersion: dapr.io/v1alpha1 +kind: Configuration +metadata: + name: tracing +spec: + tracing: + enabled: true + expandParams: true + includeBody: true +--- +apiVersion: dapr.io/v1alpha1 +kind: Component +metadata: + name: native +spec: + type: exporters.native + metadata: + - name: enabled + value: "true" + - name: agentEndpoint + value: "dapr-localforwarder.monitoring.svc.cluster.local:6789" +--- \ No newline at end of file diff --git a/howto/diagnose-with-tracing/localforwarder/dapr-localforwarder.yaml b/howto/diagnose-with-tracing/localforwarder/dapr-localforwarder.yaml new file mode 100644 index 000000000..a105ca1c6 --- /dev/null +++ b/howto/diagnose-with-tracing/localforwarder/dapr-localforwarder.yaml @@ -0,0 +1,43 @@ +kind: Service +apiVersion: v1 +metadata: + name: dapr-localforwarder + labels: + app: dapr-localforwarder +spec: + selector: + app: dapr-localforwarder + ports: + - protocol: TCP + port: 6789 + targetPort: 6789 + type: ClusterIP + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: dapr-localforwarder + labels: + app: dapr-localforwarder +spec: + replicas: 1 + selector: + matchLabels: + app: dapr-localforwarder + template: + metadata: + labels: + app: dapr-localforwarder + spec: + containers: + - name: dapr-localforwarder + image: docker.io/daprio/dapr-localforwarder:0.1-beta1 + ports: + - containerPort: 6789 + imagePullPolicy: Always + env: + - name: APPINSIGHTS_INSTRUMENTATIONKEY + value: "" + - name: APPINSIGHTS_LIVEMETRICSSTREAMAUTHENTICATIONAPIKEY + value: "" From db3b397cf4c9a7393e2a0d25fb0e732b3a13a6ed Mon Sep 17 00:00:00 2001 From: Young Bu Park Date: Thu, 12 Mar 2020 22:14:32 -0700 Subject: [PATCH 2/6] update docs --- howto/diagnose-with-tracing/azure-monitor.md | 51 ++++++++++++++----- .../localforwarder/appinsight-tracing.yaml | 2 +- .../localforwarder/dapr-localforwarder.yaml | 12 ++--- 3 files changed, 46 insertions(+), 19 deletions(-) diff --git a/howto/diagnose-with-tracing/azure-monitor.md b/howto/diagnose-with-tracing/azure-monitor.md index f8aa20788..752ad721b 100644 --- a/howto/diagnose-with-tracing/azure-monitor.md +++ b/howto/diagnose-with-tracing/azure-monitor.md @@ -1,28 +1,55 @@ -# Set up distributed tracing with Azure Monitor +# Set up distributed tracing with Application insights -Dapr integrates with Application Monitor through OpenTelemetry's default exporter along with a dedicated agent known as [Local Forwarder](https://docs.microsoft.com/en-us/azure/azure-monitor/app/opencensus-local-forwarder). +Dapr integrates with Application Insights through OpenTelemetry's default exporter along with a dedicated agent known as [Local Forwarder](https://docs.microsoft.com/en-us/azure/azure-monitor/app/opencensus-local-forwarder). -## How to configure distributed tracing with Azure Monitor +## How to configure distributed tracing wit Application insights -The following steps will show you how to configure Dapr to send distributed tracing data to Azure Monitor. +The following steps will show you how to configure Dapr to send distributed tracing data to Application insights. -### Setup Azure Monitor +### Setup Application insights 1. First, you'll need an Azure account. Please see instructions [here](https://azure.microsoft.com/free/) to apply for a **free** Azure account. 2. Follow instructions [here](https://docs.microsoft.com/en-us/azure/azure-monitor/app/create-new-resource) to create a new Application Insights resource. +3. Get Application insights Intrumentation key from your application insights page +4. Go to `Configure -> API Access` +5. Click `Create API Key` +6. Select all checkboxes under `Choose what this API key will allow apps to do:` + - Read telemetry + - Write annotations + - Authenticate SDK control channel +7. Generate Key and get API key ### Setup the Local Forwarder -The Local Forwarder listens to OpenTelemetry's traces through -Please follow the insturctions [here](https://docs.microsoft.com/en-us/azure/azure-monitor/app/opencensus-local-forwarder) to setup Local Forwarder as a local service or daemon. +#### Local environment -> **NOTE**: At the time of writing, there's no official guidance on packaging and running the Local Forwarder as a Docker container. To use Local Forwarder on Kubernetes, you'll need to package the Local Forwarder as a Docker container and register a *ClusterIP* service. Then, you should set the service as the export target of the native exporter. +```bash +docker run -e APPINSIGHTS_INSTRUMENTATIONKEY= -e APPINSIGHTS_LIVEMETRICSSTREAMAUTHENTICATIONAPIKEY= -d -p 50001:50001 daprio/dapr-localforwarder:0.1-beta1 +``` -### How to configure distributed tracing with Azure Monitor +#### Kubernetes + +1. Download [dapr-localforwarder.yaml](./localforwarder/dapr-localforwarder.yaml) +2. Replace `` with your Instrumentation Key and `` with the generated key in the file + +```yaml + - name: APPINSIGHTS_INSTRUMENTATIONKEY + value: # Replace with your ikey + - name: APPINSIGHTS_LIVEMETRICSSTREAMAUTHENTICATIONAPIKEY + value: # Replace with your generated api key +``` + +3. Deploy dapr-localfowarder.yaml + +```bash +kubectl apply -f ./dapr-localforwarder.yaml +``` + +### How to configure distributed tracing with Application insights You'll need two YAML files - a Dapr configuration file that enables tracing, and a native export configuration file that configures the native exporter. -1. Create the following YAML files: +1. Create the following YAML files * native.yaml @@ -37,7 +64,7 @@ spec: - name: enabled value: "true" - name: agentEndpoint - value: "" + value: "" ``` * tracing.yaml @@ -54,7 +81,7 @@ spec: includeBody: true ``` -2. When running under local mode, copy *tracing.yaml* to a *components* folder under the same folder where you run you application. When running under Kubernetes model, use kubectl to apply the above CRD files: +1. When running under local mode, copy *tracing.yaml* to a *components* folder under the same folder where you run you application. When running under Kubernetes model, use kubectl to apply the above CRD files: ```bash kubectl apply -f tracing.yaml diff --git a/howto/diagnose-with-tracing/localforwarder/appinsight-tracing.yaml b/howto/diagnose-with-tracing/localforwarder/appinsight-tracing.yaml index 6ff1f60ff..6155c56c1 100644 --- a/howto/diagnose-with-tracing/localforwarder/appinsight-tracing.yaml +++ b/howto/diagnose-with-tracing/localforwarder/appinsight-tracing.yaml @@ -19,5 +19,5 @@ spec: - name: enabled value: "true" - name: agentEndpoint - value: "dapr-localforwarder.monitoring.svc.cluster.local:6789" + value: "dapr-localforwarder.monitoring.svc.cluster.local:50001" --- \ No newline at end of file diff --git a/howto/diagnose-with-tracing/localforwarder/dapr-localforwarder.yaml b/howto/diagnose-with-tracing/localforwarder/dapr-localforwarder.yaml index a105ca1c6..1715ab885 100644 --- a/howto/diagnose-with-tracing/localforwarder/dapr-localforwarder.yaml +++ b/howto/diagnose-with-tracing/localforwarder/dapr-localforwarder.yaml @@ -9,8 +9,8 @@ spec: app: dapr-localforwarder ports: - protocol: TCP - port: 6789 - targetPort: 6789 + port: 50001 + targetPort: 50001 type: ClusterIP --- @@ -21,7 +21,7 @@ metadata: labels: app: dapr-localforwarder spec: - replicas: 1 + replicas: 3 # Adjust replica # based on your telemetry volume selector: matchLabels: app: dapr-localforwarder @@ -34,10 +34,10 @@ spec: - name: dapr-localforwarder image: docker.io/daprio/dapr-localforwarder:0.1-beta1 ports: - - containerPort: 6789 + - containerPort: 50001 imagePullPolicy: Always env: - name: APPINSIGHTS_INSTRUMENTATIONKEY - value: "" + value: # Replace with your ikey - name: APPINSIGHTS_LIVEMETRICSSTREAMAUTHENTICATIONAPIKEY - value: "" + value: # Replace with your generated api key From 5ac90c94c3f87d391067698ad85e3b3863398806 Mon Sep 17 00:00:00 2001 From: Young Bu Park Date: Fri, 13 Mar 2020 08:57:50 -0700 Subject: [PATCH 3/6] wip --- howto/diagnose-with-tracing/azure-monitor.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/howto/diagnose-with-tracing/azure-monitor.md b/howto/diagnose-with-tracing/azure-monitor.md index 752ad721b..ac19117dd 100644 --- a/howto/diagnose-with-tracing/azure-monitor.md +++ b/howto/diagnose-with-tracing/azure-monitor.md @@ -27,7 +27,7 @@ The following steps will show you how to configure Dapr to send distributed trac docker run -e APPINSIGHTS_INSTRUMENTATIONKEY= -e APPINSIGHTS_LIVEMETRICSSTREAMAUTHENTICATIONAPIKEY= -d -p 50001:50001 daprio/dapr-localforwarder:0.1-beta1 ``` -#### Kubernetes +#### Kubernetes environment 1. Download [dapr-localforwarder.yaml](./localforwarder/dapr-localforwarder.yaml) 2. Replace `` with your Instrumentation Key and `` with the generated key in the file @@ -64,7 +64,7 @@ spec: - name: enabled value: "true" - name: agentEndpoint - value: "" + value: "" ``` * tracing.yaml @@ -81,7 +81,7 @@ spec: includeBody: true ``` -1. When running under local mode, copy *tracing.yaml* to a *components* folder under the same folder where you run you application. When running under Kubernetes model, use kubectl to apply the above CRD files: +2. When running under local mode, copy *tracing.yaml* to a *components* folder under the same folder where you run you application. When running under Kubernetes model, use kubectl to apply the above CRD files: ```bash kubectl apply -f tracing.yaml @@ -119,7 +119,7 @@ That's it! There's no need include any SDKs or instrument your application code Generate some workloads. And after a few minutes, you should see tracing logs appearing in your Application Insights resource. And you can also use **Application map** to examine the topology of your services, as shown below: -![Azure Monitor screen](../../images/azure-monitor.png) +![Application map](../../images/azure-monitor.png) ## Tracing Configuration From 0be7f06ee1c44567103368ae59877e2949a35907 Mon Sep 17 00:00:00 2001 From: Young Bu Park Date: Fri, 13 Mar 2020 09:32:58 -0700 Subject: [PATCH 4/6] fix cr --- howto/diagnose-with-tracing/azure-monitor.md | 59 ++++++++++++++++---- 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/howto/diagnose-with-tracing/azure-monitor.md b/howto/diagnose-with-tracing/azure-monitor.md index ac19117dd..5d51601de 100644 --- a/howto/diagnose-with-tracing/azure-monitor.md +++ b/howto/diagnose-with-tracing/azure-monitor.md @@ -2,6 +2,8 @@ Dapr integrates with Application Insights through OpenTelemetry's default exporter along with a dedicated agent known as [Local Forwarder](https://docs.microsoft.com/en-us/azure/azure-monitor/app/opencensus-local-forwarder). +> Note: Local forwarder is still under preview, but being deprecated. Application insights team recommends to use [Opentelemetry collector](https://github.com/open-telemetry/opentelemetry-collector) (which is in alpha state) for the future so that we're working on moving from local forwarder to [Opentelemetry collector](https://github.com/open-telemetry/opentelemetry-collector). + ## How to configure distributed tracing wit Application insights The following steps will show you how to configure Dapr to send distributed tracing data to Application insights. @@ -23,10 +25,52 @@ The following steps will show you how to configure Dapr to send distributed trac #### Local environment +1. Run localfowarder + ```bash docker run -e APPINSIGHTS_INSTRUMENTATIONKEY= -e APPINSIGHTS_LIVEMETRICSSTREAMAUTHENTICATIONAPIKEY= -d -p 50001:50001 daprio/dapr-localforwarder:0.1-beta1 ``` +> Note: dapr-localforwarder is created by using [0.1-beta1 release](https://github.com/microsoft/ApplicationInsights-LocalForwarder/releases/tag/v0.1-beta1). If you want to create your own image, please use [this dockerfile](./localforwarder/Dockerfile). + +1. Copy *tracing.yaml* to a *components* folder under the same folder where you run you application. + +* native.yaml + +```yaml +apiVersion: dapr.io/v1alpha1 +kind: Component +metadata: + name: native +spec: + type: exporters.native + metadata: + - name: enabled + value: "true" + - name: agentEndpoint + value: "localhost:5001" +``` + +* tracing.yaml + +```yaml +apiVersion: dapr.io/v1alpha1 +kind: Configuration +metadata: + name: tracing +spec: + tracing: + enabled: true + expandParams: true + includeBody: true +``` + +3. When running in the local mode, you need to launch Dapr with the `--config` parameter: + +```bash +dapr run --app-id mynode --app-port 3000 --config ./tracing.yaml node app.js +``` + #### Kubernetes environment 1. Download [dapr-localforwarder.yaml](./localforwarder/dapr-localforwarder.yaml) @@ -45,11 +89,7 @@ docker run -e APPINSIGHTS_INSTRUMENTATIONKEY= -e APPIN kubectl apply -f ./dapr-localforwarder.yaml ``` -### How to configure distributed tracing with Application insights - -You'll need two YAML files - a Dapr configuration file that enables tracing, and a native export configuration file that configures the native exporter. - -1. Create the following YAML files +4. Create the following YAML files * native.yaml @@ -81,19 +121,14 @@ spec: includeBody: true ``` -2. When running under local mode, copy *tracing.yaml* to a *components* folder under the same folder where you run you application. When running under Kubernetes model, use kubectl to apply the above CRD files: +5. Use kubectl to apply the above CRD files: ```bash kubectl apply -f tracing.yaml kubectl apply -f native.yaml ``` -3. When running in the local mode, you need to launch Dapr with the `--config` parameter: - -```bash -dapr run --app-id mynode --app-port 3000 --config ./tracing.yaml node app.js -``` - +6. Deploy your app with tracing When running in the Kubernetes model, you need to add a `dapr.io/config` annotation to your container that you want to participate in the distributed tracing, as shown in the following example: ```yaml From bfe3a919e44c623099e006f1623739268c27b692 Mon Sep 17 00:00:00 2001 From: Young Bu Park Date: Fri, 13 Mar 2020 09:37:54 -0700 Subject: [PATCH 5/6] fix nitpicks --- howto/diagnose-with-tracing/azure-monitor.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/howto/diagnose-with-tracing/azure-monitor.md b/howto/diagnose-with-tracing/azure-monitor.md index 5d51601de..8a5b82478 100644 --- a/howto/diagnose-with-tracing/azure-monitor.md +++ b/howto/diagnose-with-tracing/azure-monitor.md @@ -104,7 +104,7 @@ spec: - name: enabled value: "true" - name: agentEndpoint - value: "" + value: "" ``` * tracing.yaml From 5d5a3ad62883373a519a50604348d4cd225a06c9 Mon Sep 17 00:00:00 2001 From: Young Bu Park Date: Fri, 13 Mar 2020 19:35:49 -0700 Subject: [PATCH 6/6] wip --- howto/diagnose-with-tracing/azure-monitor.md | 6 +++--- howto/diagnose-with-tracing/localforwarder/Dockerfile | 2 +- .../localforwarder/appinsight-tracing.yaml | 2 +- .../localforwarder/dapr-localforwarder.yaml | 7 +++---- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/howto/diagnose-with-tracing/azure-monitor.md b/howto/diagnose-with-tracing/azure-monitor.md index 8a5b82478..9f71e717e 100644 --- a/howto/diagnose-with-tracing/azure-monitor.md +++ b/howto/diagnose-with-tracing/azure-monitor.md @@ -28,7 +28,7 @@ The following steps will show you how to configure Dapr to send distributed trac 1. Run localfowarder ```bash -docker run -e APPINSIGHTS_INSTRUMENTATIONKEY= -e APPINSIGHTS_LIVEMETRICSSTREAMAUTHENTICATIONAPIKEY= -d -p 50001:50001 daprio/dapr-localforwarder:0.1-beta1 +docker run -e APPINSIGHTS_INSTRUMENTATIONKEY= -e APPINSIGHTS_LIVEMETRICSSTREAMAUTHENTICATIONAPIKEY= -d -p 55678:55678 daprio/dapr-localforwarder:0.1-beta1 ``` > Note: dapr-localforwarder is created by using [0.1-beta1 release](https://github.com/microsoft/ApplicationInsights-LocalForwarder/releases/tag/v0.1-beta1). If you want to create your own image, please use [this dockerfile](./localforwarder/Dockerfile). @@ -48,7 +48,7 @@ spec: - name: enabled value: "true" - name: agentEndpoint - value: "localhost:5001" + value: "localhost:55678" ``` * tracing.yaml @@ -104,7 +104,7 @@ spec: - name: enabled value: "true" - name: agentEndpoint - value: "" + value: "" ``` * tracing.yaml diff --git a/howto/diagnose-with-tracing/localforwarder/Dockerfile b/howto/diagnose-with-tracing/localforwarder/Dockerfile index f2e6372da..ffce37e65 100644 --- a/howto/diagnose-with-tracing/localforwarder/Dockerfile +++ b/howto/diagnose-with-tracing/localforwarder/Dockerfile @@ -4,5 +4,5 @@ WORKDIR /lf RUN curl -LsO https://github.com/microsoft/ApplicationInsights-LocalForwarder/releases/download/v0.1-beta1/LF-ConsoleHost-linux-x64.tar.gz RUN tar xzf LF-ConsoleHost-linux-x64.tar.gz RUN rm -f LF-ConsoleHost-linux-x64.tar.gz -EXPOSE 6789 +EXPOSE 55678 ENTRYPOINT ["/lf/Microsoft.LocalForwarder.ConsoleHost", "noninteractive"] diff --git a/howto/diagnose-with-tracing/localforwarder/appinsight-tracing.yaml b/howto/diagnose-with-tracing/localforwarder/appinsight-tracing.yaml index 6155c56c1..764c8a34a 100644 --- a/howto/diagnose-with-tracing/localforwarder/appinsight-tracing.yaml +++ b/howto/diagnose-with-tracing/localforwarder/appinsight-tracing.yaml @@ -19,5 +19,5 @@ spec: - name: enabled value: "true" - name: agentEndpoint - value: "dapr-localforwarder.monitoring.svc.cluster.local:50001" + value: dapr-localforwarder.default.svc.cluster.local:55678 --- \ No newline at end of file diff --git a/howto/diagnose-with-tracing/localforwarder/dapr-localforwarder.yaml b/howto/diagnose-with-tracing/localforwarder/dapr-localforwarder.yaml index 1715ab885..58cad087e 100644 --- a/howto/diagnose-with-tracing/localforwarder/dapr-localforwarder.yaml +++ b/howto/diagnose-with-tracing/localforwarder/dapr-localforwarder.yaml @@ -9,10 +9,9 @@ spec: app: dapr-localforwarder ports: - protocol: TCP - port: 50001 - targetPort: 50001 + port: 55678 + targetPort: 55678 type: ClusterIP - --- apiVersion: apps/v1 kind: Deployment @@ -34,7 +33,7 @@ spec: - name: dapr-localforwarder image: docker.io/daprio/dapr-localforwarder:0.1-beta1 ports: - - containerPort: 50001 + - containerPort: 55678 imagePullPolicy: Always env: - name: APPINSIGHTS_INSTRUMENTATIONKEY