Skip to content

Commit

Permalink
Added documentation for logging API calls (#2240)
Browse files Browse the repository at this point in the history
* Added documentation for logging API calls

Signed-off-by: Amulya Varote <amulyavarote@Amulyas-MacBook-Pro.local>
Signed-off-by: Amulya Varote <amulyavarote@microsoft.com>

* Completed api call logs documentation

Signed-off-by: Amulya Varote <amulyavarote@QTM-SWATHIKIL-1.redmond.corp.microsoft.com>
Signed-off-by: Amulya Varote <amulyavarote@microsoft.com>

* Modified content

Signed-off-by: Amulya Varote <amulyavarote@Amulyas-MacBook-Pro.local>
Signed-off-by: Amulya Varote <amulyavarote@microsoft.com>

* Chnages based on the review comments - 1

Signed-off-by: Amulya Varote <amulyavarote@Amulyas-MacBook-Pro.local>
Signed-off-by: Amulya Varote <amulyavarote@microsoft.com>

* Chnages based on the review comments

Signed-off-by: Amulya Varote <amulyavarote@Amulyas-MacBook-Pro.local>
Signed-off-by: Amulya Varote <amulyavarote@microsoft.com>

* Fixing all the external validations

Signed-off-by: Amulya Varote <amulyavarote@Amulyas-MacBook-Pro.local>
Signed-off-by: Amulya Varote <amulyavarote@microsoft.com>

* Fixed external link validation

Signed-off-by: Amulya Varote <amulyavarote@Amulyas-MacBook-Pro.local>
Signed-off-by: Amulya Varote <amulyavarote@microsoft.com>

* Ignoring a few links validation

Signed-off-by: Amulya Varote <amulyavarote@Amulyas-MacBook-Pro.local>
Signed-off-by: Amulya Varote <amulyavarote@microsoft.com>

* Fixed some spelling mistakes

Signed-off-by: Amulya Varote <amulyavarote@Amulyas-MacBook-Pro.local>
Signed-off-by: Amulya Varote <amulyavarote@microsoft.com>

* Merge conflicts

Signed-off-by: Amulya Varote <amulyavarote@microsoft.com>

* Added annotation api log level

Signed-off-by: Amulya Varote <amulyavarote@microsoft.com>

* Changes based on the review comments

Signed-off-by: Amulya Varote <amulyavarote@microsoft.com>

Co-authored-by: Amulya Varote <amulyavarote@Amulyas-MacBook-Pro.local>
Co-authored-by: Mark Fussell <markfussell@gmail.com>
  • Loading branch information
3 people committed Mar 22, 2022
1 parent 5012d7f commit df8bc96
Show file tree
Hide file tree
Showing 13 changed files with 132 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ Invoke-RestMethod -Method Post -ContentType 'application/cloudevents+json' -Body

## Next steps

- Try the [Pub/Sub quickstart sample](https://github.com/dapr/quickstarts/tree/master/pub_sub)
- Try the [Pub/Sub quickstart sample](https://github.com/dapr/quickstarts/tree/master/tutorials/pub-sub)
- Learn about [PubSub routing]({{< ref howto-route-messages >}})
- Learn about [topic scoping]({{< ref pubsub-scopes.md >}})
- Learn about [message time-to-live]({{< ref pubsub-message-ttl.md >}})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ The publish/subscribe API is located in the [API reference]({{< ref pubsub_api.m
* Follow these guides on:
* [How-To: Publish a message and subscribe to a topic]({{< ref howto-publish-subscribe.md >}})
* [How-To: Configure Pub/Sub components with multiple namespaces]({{< ref pubsub-namespaces.md >}})
* Try out the [Pub/Sub quickstart sample](https://github.com/dapr/quickstarts/tree/master/pub_sub)
* Try out the [Pub/Sub quickstart sample](https://github.com/dapr/quickstarts/tree/master/tutorials/pub-sub)
* Learn about [topic scoping]({{< ref pubsub-scopes.md >}})
* Learn about [message time-to-live (TTL)]({{< ref pubsub-message-ttl.md >}})
* Learn about [pubsub without CloudEvent]({{< ref pubsub-raw.md >}})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Visit [this guide]({{< ref "howto-publish-subscribe.md#step-3-publish-a-topic" >
## Related links

- Overview of the Dapr [Pub/Sub building block]({{< ref pubsub-overview.md >}})
- Try the [Pub/Sub quickstart sample](https://github.com/dapr/quickstarts/tree/master/pub_sub)
- Try the [Pub/Sub quickstart sample](https://github.com/dapr/quickstarts/tree/master/tutorials/pub-sub)
- Read the [guide on publishing and subscribing]({{< ref howto-publish-subscribe.md >}})
- Learn about [topic scoping]({{< ref pubsub-scopes.md >}})
- Learn about [message time-to-live]({{< ref pubsub-message-ttl.md >}})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ In some scenarios, applications can be spread across namespaces and share a queu
Namespaces are a Dapr concept used for scoping applications and components. This example uses Kubernetes namespaces, however the Dapr component namespace scoping can be used on any supported platform. Read [How-To: Scope components to one or more applications]({{< ref "component-scopes.md" >}}) for more information on scoping components.
{{% /alert %}}

This example uses the [PubSub sample](https://github.com/dapr/quickstarts/tree/master/pub_sub). The Redis installation and the subscribers are in `namespace-a` while the publisher UI is in `namespace-b`. This solution will also work if Redis is installed on another namespace or if you use a managed cloud service like Azure ServiceBus, AWS SNS/SQS or GCP PubSub.
This example uses the [PubSub sample](https://github.com/dapr/quickstarts/tree/master/tutorials/pub-sub). The Redis installation and the subscribers are in `namespace-a` while the publisher UI is in `namespace-b`. This solution will also work if Redis is installed on another namespace or if you use a managed cloud service like Azure ServiceBus, AWS SNS/SQS or GCP PubSub.

This is a diagram of the example using namespaces.

Expand All @@ -33,7 +33,7 @@ The table below shows which resources are deployed to which namespaces:
## Pre-requisites

* [Dapr installed on Kubernetes]({{< ref "kubernetes-deploy.md" >}}) in any namespace since Dapr works at the cluster level.
* Checkout and cd into the directory for [PubSub quickstart](https://github.com/dapr/quickstarts/tree/master/pub_sub).
* Checkout and cd into the directory for [PubSub quickstart](https://github.com/dapr/quickstarts/tree/master/tutorials/pub-sub).

## Setup `namespace-a`

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
type: docs
title: "Dapr API Logs"
linkTitle: "API Logs"
weight: 3000
description: "Understand how API logging works in Dapr and how to view logs"
---

API logging enables you to see the API calls from your application to the Dapr sidecar and debug issues as a result with different verbosity levels. You can also combine Dapr API logging with Dapr log events (see [configure and view Dapr Logs]({{< ref "logs-troubleshooting.md" >}}) into the output, if you want to use the logging capabilities together.

## Overview

API logs have different, configurable verbosity levels and is applicable for both HTTP and GRPC calls.

1. info
2. debug

The default level is debug, which provides a balanced amount of information for operating Dapr in normal conditions.

To set the output level, you can use the `--api-log-level` command-line option. For example:

```bash
./daprd --api-log-level info
./daprd --api-log-level debug
```

This starts the Dapr runtime with a api log level of `info` and `debug` accordingly.

## Configuring API logging in self hosted mode

To set the log level when running your app with the Dapr CLI, pass the `api-log-level` param:

```bash
dapr run --api-log-level info node myapp.js
```

### Viewing API logs in self hosted mode

When running Dapr with the Dapr CLI, both your app's log output and the Dapr runtime log output are redirected to the same session, for easy debugging.

The below example shows `info` level API logging:

```bash
dapr run --api-log-level info node myapp.js

ℹ️ Starting Dapr with id order-processor on port 56730
✅ You are up and running! Both Dapr and your app logs will appear here.
.....
INFO[0000] HTTP API Called: POST /v1.0/state/statestore app_id=order-processor instance=QTM-SWATHIKIL-1.redmond.corp.microsoft.com scope=dapr.runtime.http type=log ver=edge
== APP == INFO:root:Saving Order: {'orderId': '483'}
INFO[0000] HTTP API Called: GET /v1.0/state/statestore/483 app_id=order-processor instance=QTM-SWATHIKIL-1.redmond.corp.microsoft.com scope=dapr.runtime.http type=log ver=edge
== APP == INFO:root:Getting Order: {'orderId': '483'}
INFO[0000] HTTP API Called: DELETE /v1.0/state/statestore app_id=order-processor instance=QTM-SWATHIKIL-1.redmond.corp.microsoft.com scope=dapr.runtime.http type=log ver=edge
== APP == INFO:root:Deleted Order: {'orderId': '483'}
INFO[0000] HTTP API Called: PUT /v1.0/metadata/cliPID app_id=order-processor instance=QTM-SWATHIKIL-1.redmond.corp.microsoft.com scope=dapr.runtime.http type=log ver=edge
```

The below example is for debug level API logging

```bash
dapr run --api-log-level debug node myapp.js
ℹ️ Starting Dapr with id order-processor on port 56730
✅ You are up and running! Both Dapr and your app logs will appear here.
.....
DEBU[0000] HTTP API Called: POST /v1.0/state/statestore app_id=order-processor instance=QTM-SWATHIKIL-1.redmond.corp.microsoft.com scope=dapr.runtime.http type=log ver=edge
== APP == INFO:root:Saving Order: {'orderId': '483'}
DEBU[0000] HTTP API Called: GET /v1.0/state/statestore/483 app_id=order-processor instance=QTM-SWATHIKIL-1.redmond.corp.microsoft.com scope=dapr.runtime.http type=log ver=edge
== APP == INFO:root:Getting Order: {'orderId': '483'}
DEBU[0000] HTTP API Called: DELETE /v1.0/state/statestore app_id=order-processor instance=QTM-SWATHIKIL-1.redmond.corp.microsoft.com scope=dapr.runtime.http type=log ver=edge
== APP == INFO:root:Deleted Order: {'orderId': '483'}
DEBU[0000] HTTP API Called: PUT /v1.0/metadata/cliPID app_id=order-processor instance=QTM-SWATHIKIL-1.redmond.corp.microsoft.com scope=dapr.runtime.http type=log ver=edge
```

## Configuring API logging in Kubernetes

You can set the log level individually for every sidecar by providing the following annotation in your pod spec template:

```yml
annotations:
dapr.io/api-log-level: "info"
```
or
```yml
annotations:
dapr.io/api-log-level: "debug"
```
### Viewing API logs on Kubernetes
Dapr API logs are written to stdout and stderr and you can view API logs on Kubernetes.
See the kubernetes API logs by executing the below command.
```bash
kubectl logs <pod_name> daprd -n <name_space>
```

The example below show `info` level API logging in Kubernetes.

```bash
time="2022-03-16T18:32:02.487041454Z" level=info msg="HTTP API Called: GET /v1.0/invoke/invoke-receiver/method/my-method" app_id=invoke-caller instance=invokecaller-f4f949886-cbnmt scope=dapr.runtime.http type=log ver=edge
time="2022-03-16T18:32:02.698387866Z" level=info msg="HTTP API Called: GET /v1.0/invoke/invoke-receiver/method/my-method" app_id=invoke-caller instance=invokecaller-f4f949886-cbnmt scope=dapr.runtime.http type=log ver=edge
time="2022-03-16T18:32:02.917629403Z" level=info msg="HTTP API Called: GET /v1.0/invoke/invoke-receiver/method/my-method" app_id=invoke-caller instance=invokecaller-f4f949886-cbnmt scope=dapr.runtime.http type=log ver=edge
time="2022-03-16T18:32:03.137830112Z" level=info msg="HTTP API Called: GET /v1.0/invoke/invoke-receiver/method/my-method" app_id=invoke-caller instance=invokecaller-f4f949886-cbnmt scope=dapr.runtime.http type=log ver=edge
time="2022-03-16T18:32:03.359097916Z" level=info msg="HTTP API Called: GET /v1.0/invoke/invoke-receiver/method/my-method" app_id=invoke-caller instance=invokecaller-f4f949886-cbnmt scope=dapr.runtime.http type=log ver=edge
```

The below example is for debug level API logging in Kubernetes. The debug level API logs are visible only when the log-level is set to debug.

```bash
time="2022-03-18T21:03:00.03969986Z" level=debug msg="HTTP API Called: GET /v1.0/invoke/invoke-receiver/method/my-method" app_id=invoke-caller instance=invokecaller-56894979cd-rt87b scope=dapr.runtime.http type=log ver=edge
time="2022-03-18T21:03:00.271463876Z" level=debug msg="HTTP API Called: GET /v1.0/invoke/invoke-receiver/method/my-method" app_id=invoke-caller instance=invokecaller-56894979cd-rt87b scope=dapr.runtime.http type=log ver=edge
time="2022-03-18T21:03:00.492570204Z" level=debug msg="HTTP API Called: GET /v1.0/invoke/invoke-receiver/method/my-method" app_id=invoke-caller instance=invokecaller-56894979cd-rt87b scope=dapr.runtime.http type=log ver=edge
time="2022-03-18T21:03:00.705486991Z" level=debug msg="HTTP API Called: GET /v1.0/invoke/invoke-receiver/method/my-method" app_id=invoke-caller instance=invokecaller-56894979cd-rt87b scope=dapr.runtime.http type=log ver=edge
time="2022-03-18T21:03:00.916868445Z" level=debug msg="HTTP API Called: GET /v1.0/invoke/invoke-receiver/method/my-method" app_id=invoke-caller instance=invokecaller-56894979cd-rt87b scope=dapr.runtime.http type=log ver=edge
```
2 changes: 1 addition & 1 deletion daprdocs/content/en/reference/api/pubsub_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,4 @@ Dapr Pub/Sub adheres to version 1.0 of CloudEvents.
## Related links

* [How to publish to and consume topics]({{< ref howto-publish-subscribe.md >}})
* [Sample for pub/sub](https://github.com/dapr/quickstarts/tree/master/pub_sub)
* [Sample for pub/sub](https://github.com/dapr/quickstarts/tree/master/tutorials/pub-sub)
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ This table is meant to help users understand the equivalent options for running
| `--unix-domain-socket` | `--unix-domain-socket` | `-u` | not supported | On Linux, when communicating with the Dapr sidecar, use unix domain sockets for lower latency and greater throughput compared to TCP ports. Not available on Windows OS |
| `--log-as-json` | not supported | | `dapr.io/log-as-json` | Setting this parameter to `true` outputs logs in JSON format. Default is `false` |
| `--log-level` | `--log-level` | | `dapr.io/log-level` | Sets the log level for the Dapr sidecar. Allowed values are `debug`, `info`, `warn`, `error`. Default is `info` |
| `--api-log-level` | `--api-log-level` | | `dapr.io/api-log-level` | Sets the API log level for the Dapr sidecar. Allowed values are `debug`, `info`. Default is `debug` |
| `--app-max-concurrency` | `--app-max-concurrency` | | `dapr.io/app-max-concurrency` | Limit the concurrency of your application. A valid value is any number larger than `0`
| `--metrics-port` | `--metrics-port` | | `dapr.io/metrics-port` | Sets the port for the sidecar metrics server. Default is `9090` |
| `--mode` | not supported | | not supported | Runtime mode for Dapr (default "standalone") |
Expand Down
1 change: 1 addition & 0 deletions daprdocs/content/en/reference/cli/dapr-run.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dapr run [flags] [command]
| `--help`, `-h` | | | Print this help message |
| `--image` | | | The image to build the code in. Input is: `repository/image` |
| `--log-level` | | `info` | The log verbosity. Valid values are: `debug`, `info`, `warn`, `error`, `fatal`, or `panic` |
| `--api-log-level` | | `debug` | The API log verbosity. Valid values are: `debug` or `info` |
| `--metrics-port` | `DAPR_METRICS_PORT` | `9090` | The port that Dapr sends its metrics information to |
| `--profile-port` | | `7777` | The port for the profile server to listen on |
| `--unix-domain-socket`, `-u` | | | Path to a unix domain socket dir mount. If specified, communication with the Dapr sidecar uses unix domain sockets for lower latency and greater throughput when compared to using TCP ports. Not available on Windows OS |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,11 @@ The payload format is documented [here](https://developer.apple.com/documentatio
"operation": "create"
}
```

<!-- IGNORE_LINKS -->
The `data` object contains a complete push notification specification as described in the [Apple documentation](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification). The `data` object will be sent directly to the APNs service.

Besides the `device-token` value, the HTTP headers specified in the [Apple documentation](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns) can be sent as metadata fields and will be included in the HTTP request to the APNs service.
<!-- END_IGNORE -->

### Response format

Expand Down
2 changes: 1 addition & 1 deletion sdkdocs/dotnet
Submodule dotnet updated 38 files
+4 −49 CONTRIBUTING.md
+0 −14 all.sln
+0 −42 daprdocs/content/en/dotnet-sdk-docs/dotnet-client/_index.md
+3 −3 examples/Actor/DemoActor/Properties/launchSettings.json
+2 −2 examples/Actor/README.md
+0 −12 examples/Client/ConfigurationApi/Components/redisconfig.yaml
+0 −11 examples/Client/ConfigurationApi/ConfigurationApi.csproj
+0 −30 examples/Client/ConfigurationApi/Program.cs
+0 −30 examples/Client/ConfigurationApi/Properties/launchSettings.json
+0 −62 examples/Client/ConfigurationApi/README.md
+0 −9 examples/Client/ConfigurationApi/appsettings.Development.json
+0 −10 examples/Client/ConfigurationApi/appsettings.json
+9 −30 src/Dapr.Actors.AspNetCore/ActorsEndpointRouteBuilderExtensions.cs
+28 −8 src/Dapr.Actors/Runtime/ActorManager.cs
+0 −46 src/Dapr.Client/ConfigurationItem.cs
+0 −32 src/Dapr.Client/DaprClient.cs
+0 −107 src/Dapr.Client/DaprClientGrpc.cs
+0 −33 src/Dapr.Client/GetConfigurationResponse.cs
+0 −34 src/Dapr.Client/StateQueryException.cs
+0 −92 src/Dapr.Client/StateQueryResponse.cs
+0 −135 test/Dapr.Client.Test/ConfigurationApiTest.cs
+0 −98 test/Dapr.Client.Test/StateApiTest.cs
+0 −32 test/Dapr.E2E.Test.Actors/RegressionActor/IRegression762Actor.cs
+0 −22 test/Dapr.E2E.Test.Actors/RegressionActor/StateCall.cs
+0 −14 test/Dapr.E2E.Test.App.ReentrantActor/Dapr.E2E.Test.App.ReentrantActors.csproj
+0 −33 test/Dapr.E2E.Test.App.ReentrantActor/Program.cs
+0 −51 test/Dapr.E2E.Test.App.ReentrantActor/Startup.cs
+0 −9 test/Dapr.E2E.Test.App.ReentrantActor/appsettings.Development.json
+0 −10 test/Dapr.E2E.Test.App.ReentrantActor/appsettings.json
+1 −0 test/Dapr.E2E.Test.App/Actors/ReentrantActor.cs
+0 −65 test/Dapr.E2E.Test.App/Actors/Regression762Actor.cs
+2 −2 test/Dapr.E2E.Test.App/Startup.cs
+0 −44 test/Dapr.E2E.Test/ActorRuntimeChecker.cs
+2 −23 test/Dapr.E2E.Test/Actors/E2ETests.ReentrantTests.cs
+0 −116 test/Dapr.E2E.Test/Actors/E2ETests.Regression762Tests.cs
+1 −2 test/Dapr.E2E.Test/Dapr.E2E.Test.csproj
+0 −2 test/Dapr.E2E.Test/DaprTestAppLifecycle.cs
+16 −1 test/Dapr.E2E.Test/E2ETests.cs
2 changes: 1 addition & 1 deletion sdkdocs/java
Submodule java updated 810 files
2 changes: 1 addition & 1 deletion sdkdocs/js
Submodule js updated 162 files
2 changes: 1 addition & 1 deletion sdkdocs/python
Submodule python updated 157 files

0 comments on commit df8bc96

Please sign in to comment.