Configure Log Collection, Target, and Visualization - Private Cloud
Note!
You need to have a proper Kubernetes cluster setup in order to proceed with these steps.
By default, Usage Engine deployed in Kubernetes outputs logging to disk and console output. If persistent disk storage is enabled, the logs end up on the mounted shared disk. However, persistent disk is not always the desired log target, especially in a cloud environment where persistent data is typically accessed through services and APIs rather than as files. The console logs can be accessed through the "kubectl logs" command or from a Kubernetes dashboard. The buffer for storing the Kubernetes console logs is stored in memory only though and thus will be lost when a Pod terminates.
To get a production ready log configuration you can use tools from the Kubernetes ecosystem. In this guide we show you how to set up:
Fluent-bit for log collection and log forwarding
Elasticsearch for log storage
Kibana for log visualization
These tools give you powerful and flexible log collection, storage, monitoring and visualization. The Elasticsearch database storage also provides powerful tools to perform analytics on the log data.
Prerequisite
Before setting up log collection, ensure that Usage Engine was installed withย JSON formatted logging enabled, as below:
log:
# Format can be "json" or "raw". Default is "raw"
format: json
ย
Note that youย mustย install Elastic Search, Fluent-bit and Kibana on the same namespace in order to allow working properly. These are some of the reasons:
Elastic Search service needs to be accessible by Fluent-bit andย Kibana to establish connection.
Kibana required Elastic Search master cert secret presented on the namespace.
Hence, in this guide we are using namespace 'logging' for the installations.
Install Elastic Search
Elastic Search will be installed to the namespace logging
Create namespace logging
kubectl create namespace logging
Add Elastic Search repository to Helm and update repository to retrieve the latest version with the following commands:
helm repo add elastic https://helm.elastic.co
Install Elastic Search.ย
Example - Installing Elasticsearch without Persistent storage
This example installs Elasticsearch without persistent storage. Refer to Elasticsearch Helm chart documentation for help to enable persistent storage:
Install Fluent-bit
Fluent-bitย will be installed in the same namespace as Elastic Search, that isย logging.
Get the service name of Elastic Search pods with the following command:
This service name is the value set to Host in [OUTPUT] directive.
Get theย username and password credential for Elastic X-Pack access with the following commands:
The decrypted username and password are the value set to HTTP_User andย HTTP_Passwdย in the [OUTPUT] directive.
Create a custom values yaml file, for exampleย fluent-bit-values.yamlย with the following content:
Add the
fluent
ย helm repo and update repo with the following commands:
Deploy the Fluent Bit DaemonSet to the cluster with the following command:
Verify every Fluent-bit pod's log. Should not see any error or exception if connection to Elastic Search is established successfully with the following command:
Install Kibana
Kibanaย will be installed to the same namespace as Fluent-bit, i.e., logging.ย
Install Kibana.ย
Note that service type is set to NodePort to allow access outside of the cluster.
Configure Kibana
Kibana is a visual interface tool that allows you to explore, visualize, and build a dashboard over the log data massed in Elastic Search cluster.ย
Up to this stage, all pods under namespaceย logging should be up and running.ย
If all looks good, you can proceed to login to Kibana dashboard web UI.
Retrieve the public access IP Address of the Kibana dashboard with the following command:
Login to Kibana dashboard web interface using the HTTP_User and HTTP_Passwd configured in the previous section.
Go to Management > Stack Management > Index Management.
If the Fluent-bit connection to Elastic Search established successfully, the Indices is created automatically.
Go to Management > Stack Management > Kibana and create a Data view matching the index pattern
Go to Analytics > Discover to search for logs belong to each index pattern respectively.
You can filter logs using KQL syntax. For instance, enter "ECDeployment" in the KQL filter input field.
A log record in json format is parsed into fields, as below: