Configuring for Containers
Configuring for Containers
- Creating a Kubernetes Cluster
- Getting the ingestion key
- Configuring Kubernetes to Send logs
- Deploying the LogDNA agent on Kubernetes
- Customizing LogDNA Views
First create a Kubernetes Cluster using this information, See, Getting Started Kubernetes
After you create a Kubernetes Cluster, use the IBM Cloud menu->Kubernetes->Cluster, and then select the cluster which you want information for. It will show the dashboard similar to the one below.
Note: Kubernetes event logs can be sent in the same region or in a different region.
You’ll need to provision an instance of the IBM Log Analysis with LogDNA service. This allows for a configured centralized log management system where log data is hosted on IBM Cloud. You can use either an existing Kubernetes cluster or configure Kubernetes on the IBM Cloud. Use an existing or provision a new instance of IBM Log Analysis with LogDNA through the IBM Cloud console, see Getting Started LogDNA
Make sure to choose your supported region, see Supported Regions.
For more information on setting up LogDNA, see Getting Started
Complete the following steps to get the ingestion key:
- Log in to your IBM Cloud account . After you log in, the IBM Cloud UI opens.
- Click the Menu icon Observability to access the Observability dashboard.
- Select Logging. The IBM Log Analysis with LogDNA dashboard opens. You can see the list of logging instances that are available on IBM Cloud.
- Identify the instance for which you want to get the ingestion key, and click View key.
- A window opens where you can click Show to view the ingestion key.
Now, let’s configure our Kubernetes cluster to send logs to the IBM LogDNA instance configured earlier. We can configure our Kubernetes cluster to send event log traffic to the us-south region, you’ll need to complete the following procedures below.
Open a terminal to login into your IBM Cloud account.
$ ibmcloud login -a cloud.ibm.com
Set the cluster where you want to configure logging as the context for this session.
$ ibmcloud ks cluster-config cluster_name_or_ID
Let’s now create a Kubernetes secret to store your logDNA ingestion key for your service instance.
- Note: us-south region is shown below, choose the region according to your requirements.
$ kubectl create -f https://assets.us-south.logging.cloud.ibm.com/clients/logdna-agent-ds.yaml
The LogDNA ingestion key will be used to open a secure web socket to the logDNA ingestion server and to authenticate the logging agent with the IBM Log Analysis with LogDNA service.
Now, let’s verify our LogDNA agent was deployed successfully by running the following command.
$ kubectl get pods
If the deployment was successful you should see one or more LogDNA pods running.
You’ll notice the number of LogDNA pods is equal to the number of worker nodes in your cluster. All pods should be in a Running state.
Now let’s take a look at the logs captured by IBM Log Analysis with LogDNA, by viewing the dashboard. Launch the LogDNA dashboard and view logs. You can do so by going through the IBM Cloud console, following the steps below:
Log in to your IBM Cloud account External link icon.
From the Menu icon, select Observability.
Select Logging. The list of IBM Log Analysis with LogDNA service instances that are available on IBM Cloud is displayed.
Select one instance and click View LogDNA. The LogDNA dashboard opens.
Now let’s customize your default view. In the USER PREFERENCES section, you can modify the order of the data fields that are displayed per line.
Complete the following steps to modify the format of a log line: Select the Configuration icon.
Select USER PREFERENCES. A new window opens.
Choose something different from the default Viewer Theme, let’s select Monokai.
Select Log Format, modify the Line Format section to match your requirements.
Let’s look into a log line, at anytime you can view each event log line in context. Complete the following steps:
- Click the Views icon Configuration icon.
- Select Everything or a view.
- Identify a line in the log that you want to explore.
- Expand the log line.
Information about line identifiers, tags, and labels is displayed.
Expanded view of the log line, from step 4 above.
Click View in Context to see the log line in context of other log lines.
Click Copy to clipboard to copy the message field to the clipboard. When you are finished, close the line.
With IBM Log Analysis with LogDNA, you can filter logs by log source, application and even log level. Sources of event log searches or filters can be a host, computer, virtual machine or Heroku app. Next, let’s try out filtering logs.
Click on the Views icon
Select Everything or a view.
Expand All Tags to see the list of tags that are identified in the logs. Then, choose the ones that you want.
Expand All Sources to see the list of log sources that are identified in the logs. Then, choose the ones that you want.
Expand All Apps to see the list of apps that are identified in the logs. Then, choose the ones that you want.
Expand All Levels to see the list of log levels that are identified in the logs. Then, choose the ones that you want.
Notice, the All Apps expanded view below.
For our last activity, lets create a view. Follow the steps below.
Click the Views icon Configuration icon.
Select Everything or a view.
Filter log data then click Save as new view / alert. The Create new view page opens.
Enter a name for the view in the Name field.
Optionally, attach an alert. A new section is displayed for you to configure the alert.
Click Save View
Shown below is a saved view, notice the error logs displayed.
You can manage your Views by Categories.