diff --git a/daprdocs/content/en/operations/monitoring/logging/fluentd.md b/daprdocs/content/en/operations/monitoring/logging/fluentd.md index 35a14b738..0c15c1584 100644 --- a/daprdocs/content/en/operations/monitoring/logging/fluentd.md +++ b/daprdocs/content/en/operations/monitoring/logging/fluentd.md @@ -12,16 +12,15 @@ description: "How to install Fluentd, Elastic Search, and Kibana to search logs - [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) - [Helm 3](https://helm.sh/) - ## Install Elastic search and Kibana -1. Create namespace for monitoring tool and add Helm repo for Elastic Search +1. Create a Kubernetes namespace for monitoring tools ```bash kubectl create namespace dapr-monitoring ``` -2. Add Elastic helm repo +2. Add the helm repo for Elastic Search ```bash helm repo add elastic https://helm.elastic.co @@ -30,23 +29,23 @@ description: "How to install Fluentd, Elastic Search, and Kibana to search logs 3. Install Elastic Search using Helm -By default the chart creates 3 replicas which must be on different nodes. If your cluster has less than 3 nodes, specify a lower number of replicas. For example, this sets it to 1: + By default, the chart creates 3 replicas which must be on different nodes. If your cluster has fewer than 3 nodes, specify a smaller number of replicas. For example, this sets the number of replicas to 1: -```bash -helm install elasticsearch elastic/elasticsearch -n dapr-monitoring --set replicas=1 -``` + ```bash + helm install elasticsearch elastic/elasticsearch -n dapr-monitoring --set replicas=1 + ``` -Otherwise: + Otherwise: -```bash -helm install elasticsearch elastic/elasticsearch -n dapr-monitoring -``` + ```bash + helm install elasticsearch elastic/elasticsearch -n dapr-monitoring + ``` -If you are using minikube or want to disable persistent volumes for development purposes, you can disable it by using the following command: + If you are using minikube or simply want to disable persistent volumes for development purposes, you can do so by using the following command: -```bash -helm install elasticsearch elastic/elasticsearch -n dapr-monitoring --set persistence.enabled=false,replicas=1 -``` + ```bash + helm install elasticsearch elastic/elasticsearch -n dapr-monitoring --set persistence.enabled=false,replicas=1 + ``` 4. Install Kibana @@ -54,12 +53,10 @@ helm install elasticsearch elastic/elasticsearch -n dapr-monitoring --set persis helm install kibana elastic/kibana -n dapr-monitoring ``` -5. Validation - - Ensure Elastic Search and Kibana are running in your Kubernetes cluster. +5. Ensure that Elastic Search and Kibana are running in your Kubernetes cluster ```bash - kubectl get pods -n dapr-monitoring + $ kubectl get pods -n dapr-monitoring NAME READY STATUS RESTARTS AGE elasticsearch-master-0 1/1 Running 0 6m58s kibana-kibana-95bc54b89-zqdrk 1/1 Running 0 4m21s @@ -69,30 +66,29 @@ helm install elasticsearch elastic/elasticsearch -n dapr-monitoring --set persis 1. Install config map and Fluentd as a daemonset -Download these config files: -- [fluentd-config-map.yaml](/docs/fluentd-config-map.yaml) -- [fluentd-dapr-with-rbac.yaml](/docs/fluentd-dapr-with-rbac.yaml) + Download these config files: + - [fluentd-config-map.yaml](/docs/fluentd-config-map.yaml) + - [fluentd-dapr-with-rbac.yaml](/docs/fluentd-dapr-with-rbac.yaml) -> Note: If you already have Fluentd running in your cluster, please enable the nested json parser to parse JSON formatted log from Dapr. + > Note: If you already have Fluentd running in your cluster, please enable the nested json parser so that it can parse JSON-formatted logs from Dapr. -Apply the configurations to your cluster: + Apply the configurations to your cluster: -```bash -kubectl apply -f ./fluentd-config-map.yaml -kubectl apply -f ./fluentd-dapr-with-rbac.yaml -``` + ```bash + kubectl apply -f ./fluentd-config-map.yaml + kubectl apply -f ./fluentd-dapr-with-rbac.yaml + ``` -2. Ensure that Fluentd is running as a daemonset; the number of instances should be the same as the number of cluster nodes. In the example below we only have 1 node. - -```bash -kubectl get pods -n kube-system -w -NAME READY STATUS RESTARTS AGE -coredns-6955765f44-cxjxk 1/1 Running 0 4m41s -coredns-6955765f44-jlskv 1/1 Running 0 4m41s -etcd-m01 1/1 Running 0 4m48s -fluentd-sdrld 1/1 Running 0 14s -``` +2. Ensure that Fluentd is running as a daemonset. The number of FluentD instances should be the same as the number of cluster nodes. In the example below, there is only one node in the cluster: + ```bash + $ kubectl get pods -n kube-system -w + NAME READY STATUS RESTARTS AGE + coredns-6955765f44-cxjxk 1/1 Running 0 4m41s + coredns-6955765f44-jlskv 1/1 Running 0 4m41s + etcd-m01 1/1 Running 0 4m48s + fluentd-sdrld 1/1 Running 0 14s + ``` ## Install Dapr with JSON formatted logs @@ -106,80 +102,83 @@ fluentd-sdrld 1/1 Running 0 14s 2. Enable JSON formatted log in Dapr sidecar -Add `dapr.io/log-as-json: "true"` annotation to your deployment yaml. + Add the `dapr.io/log-as-json: "true"` annotation to your deployment yaml. For example: -Example: -```yaml -apiVersion: apps/v1 -kind: Deployment -metadata: - name: pythonapp - namespace: default - labels: - app: python -spec: - replicas: 1 - selector: - matchLabels: - app: python - template: + ```yaml + apiVersion: apps/v1 + kind: Deployment metadata: + name: pythonapp + namespace: default labels: app: python - annotations: - dapr.io/enabled: "true" - dapr.io/app-id: "pythonapp" - dapr.io/log-as-json: "true" -... -``` + spec: + replicas: 1 + selector: + matchLabels: + app: python + template: + metadata: + labels: + app: python + annotations: + dapr.io/enabled: "true" + dapr.io/app-id: "pythonapp" + dapr.io/log-as-json: "true" + ... + ``` ## Search logs > Note: Elastic Search takes a time to index the logs that Fluentd sends. -1. Port-forward to svc/kibana-kibana +1. Port-forward from localhost to `svc/kibana-kibana` -``` -$ kubectl port-forward svc/kibana-kibana 5601 -n dapr-monitoring -Forwarding from 127.0.0.1:5601 -> 5601 -Forwarding from [::1]:5601 -> 5601 -Handling connection for 5601 -Handling connection for 5601 -``` + ```bash + $ kubectl port-forward svc/kibana-kibana 5601 -n dapr-monitoring + Forwarding from 127.0.0.1:5601 -> 5601 + Forwarding from [::1]:5601 -> 5601 + Handling connection for 5601 + Handling connection for 5601 + ``` -2. Browse `http://localhost:5601` +2. Browse to `http://localhost:5601` -3. Click Management -> Index Management +3. Expand the drop-down menu and click **Management → Stack Management** -![kibana management](/images/kibana-1.png) + ![Stack Management item under Kibana Management menu options](/images/kibana-1.png) -4. Wait until dapr-* is indexed. +4. On the Stack Management page, select **Data → Index Management** and wait until `dapr-*` is indexed. -![index log](/images/kibana-2.png) + ![Index Management view on Kibana Stack Management page](/images/kibana-2.png) -5. Once dapr-* indexed, click Kibana->Index Patterns and Create Index Pattern +5. Once `dapr-*` is indexed, click on **Kibana → Index Patterns** and then the **Create index pattern** button. -![create index pattern](/images/kibana-3.png) + ![Kibana create index pattern button](/images/kibana-3.png) -6. Define index pattern - type `dapr*` in index pattern +6. Define a new index pattern by typing `dapr*` into the **Index Pattern name** field, then click the **Next step** button to continue. -![define index pattern](/images/kibana-4.png) + ![Kibana define an index pattern page](/images/kibana-4.png) -7. Select time stamp filed: `@timestamp` +7. Configure the primary time field to use with the new index pattern by selecting the `@timestamp` option from the **Time field** drop-down. Click the **Create index pattern** button to complete creation of the index pattern. -![timestamp](/images/kibana-5.png) + ![Kibana configure settings page for creating an index pattern](/images/kibana-5.png) -8. Confirm that `scope`, `type`, `app_id`, `level`, etc are being indexed. +8. The newly created index pattern should be shown. Confirm that the fields of interest such as `scope`, `type`, `app_id`, `level`, etc. are being indexed by using the search box in the **Fields** tab. -> Note: if you cannot find the indexed field, please wait. it depends on the volume of data and resource size where elastic search is running. + > Note: If you cannot find the indexed field, please wait. The time it takes to search across all indexed fields depends on the volume of data and size of the resource that the elastic search is running on. -![indexing](/images/kibana-6.png) + ![View of created Kibana index pattern](/images/kibana-6.png) -9. Click `discover` icon and search `scope:*` +9. To explore the indexed data, expand the drop-down menu and click **Analytics → Discover**. -> Note: it would take some time to make log searchable based on the data volume and resource. + ![Discover item under Kibana Analytics menu options](/images/kibana-7.png) -![discover](/images/kibana-7.png) +10. In the search box, type in a query string such as `scope:*` and click the **Refresh** button to view the results. + + > Note: This can take a long time. The time it takes to return all results depends on the volume of data and size of the resource that the elastic search is running on. + + ![Using the search box in the Kibana Analytics Discover page](/images/kibana-8.png) ## References diff --git a/daprdocs/static/docs/fluentd-dapr-with-rbac.yaml b/daprdocs/static/docs/fluentd-dapr-with-rbac.yaml index d6c06ff5a..f6b12fae5 100644 --- a/daprdocs/static/docs/fluentd-dapr-with-rbac.yaml +++ b/daprdocs/static/docs/fluentd-dapr-with-rbac.yaml @@ -6,7 +6,7 @@ metadata: namespace: kube-system --- -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: fluentd @@ -24,7 +24,7 @@ rules: --- kind: ClusterRoleBinding -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: rbac.authorization.k8s.io/v1 metadata: name: fluentd namespace: default diff --git a/daprdocs/static/images/kibana-1.png b/daprdocs/static/images/kibana-1.png index 2ff76b0d0..738e88b53 100644 Binary files a/daprdocs/static/images/kibana-1.png and b/daprdocs/static/images/kibana-1.png differ diff --git a/daprdocs/static/images/kibana-2.png b/daprdocs/static/images/kibana-2.png index eb1b0835d..e2cbd3bf3 100644 Binary files a/daprdocs/static/images/kibana-2.png and b/daprdocs/static/images/kibana-2.png differ diff --git a/daprdocs/static/images/kibana-3.png b/daprdocs/static/images/kibana-3.png index 151de4a99..fa4184e6a 100644 Binary files a/daprdocs/static/images/kibana-3.png and b/daprdocs/static/images/kibana-3.png differ diff --git a/daprdocs/static/images/kibana-4.png b/daprdocs/static/images/kibana-4.png index c11a7a9a6..600be9c0a 100644 Binary files a/daprdocs/static/images/kibana-4.png and b/daprdocs/static/images/kibana-4.png differ diff --git a/daprdocs/static/images/kibana-5.png b/daprdocs/static/images/kibana-5.png index b29ad2749..c04128dd1 100644 Binary files a/daprdocs/static/images/kibana-5.png and b/daprdocs/static/images/kibana-5.png differ diff --git a/daprdocs/static/images/kibana-6.png b/daprdocs/static/images/kibana-6.png index 09b8bbb4d..377e23742 100644 Binary files a/daprdocs/static/images/kibana-6.png and b/daprdocs/static/images/kibana-6.png differ diff --git a/daprdocs/static/images/kibana-7.png b/daprdocs/static/images/kibana-7.png index d8c7cd7f3..7d1c5081f 100644 Binary files a/daprdocs/static/images/kibana-7.png and b/daprdocs/static/images/kibana-7.png differ diff --git a/daprdocs/static/images/kibana-8.png b/daprdocs/static/images/kibana-8.png new file mode 100644 index 000000000..c2c9cc34d Binary files /dev/null and b/daprdocs/static/images/kibana-8.png differ