Setting Up Effective Log Management in Kubernetes
Installing and configuring an effective logging system for SecureAuth stack in any environment.
Logging at SecureAuth
At SecureAuth, we believe that logging is essential for security audits and incident investigations. By analyzing logs, security teams can identify and respond to suspicious activities, detect data breaches, and comply with regulatory standards that require data access and modification tracking.
The article describes how to configure logging in SecureAuth for both on-premises installation and SaaS solution.
Customer Deployed Installation
For on-premises installations, we recommend configuring Elasticsearch in Kubernetes (using Elastic Cloud on Kubernetes - ECK) to collect and analyze logs and tracing (OpenTelemetry - OTEL). This section includes instructions on configuring and deploying ECK, setting up OpenTelemetry to ingest logs, and visualizing and analyzing the logs collected on Elasticsearch.
Prerequisites
Configuration
In order to collect SecureAuth logs install Elastic Filebeat, a lightweight agent for forwarding and centralizing log data.
Each Kubernetes node should have an instance of Filebeat, so they should be backed by a DaemonSet object. Please follow these steps to install Filebeat using the Helm chart:
-
Add the Elastic Helm charts repo:
helm repo add elastic https://helm.elastic.co -
Update Helm repositories:
helm repo update -
Prepare
values.yamlconfiguration file. Below is the minimal version of the file based on our experience:daemonset:filebeatConfig:filebeat.yml: |filebeat.inputs:- type: containerpaths:- /var/log/containers/acp*.logprocessors:- decode_json_fields:fields: ["message"]target: jsonmax_depth: 1add_error_key: trueprocessors:- add_host_metadata:- add_kubernetes_metadata:host: $${NODE_NAME}matchers:- logs_path:logs_path: "/var/log/containers/"- copy_fields:fields:- from: kubernetes.container.nameto: event.dataset- from: kubernetes.container.nameto: appfail_on_error: falseignore_missing: true- rename:fields:- from: input.typeto: host.type- from: json.causeto: error.type- from: json.codeto: event.code- from: json.descriptionto: event.type:info- from: json.detailsto: event.reason- from: json.durationto: event.duration- from: json.errorto: error.message- from: json.hintto: event.kind:enrichment- from: json.hostto: host.container.ip- from: json.ipto: client.ip- from: json.levelto: log.level- from: json.methodto: http.request.method- from: json.msgto: event.action- from: json.nameto: service.name- from: json.pathto: url.path- from: json.sizeto: http.response.bytes- from: json.stackto: error.stack_trace- from: json.statusto: http.response.status_code- from: json.subto: user.id- from: json.tenantIDto: tenant.id- from: json.traceIDto: trace.id- from: json.userAgentto: user_agent.originalignore_missing: truefail_on_error: false- convert:fields:- from: event.durationtype: long- from: http.request.bytestype: long- from: http.response.body.bytestype: long- from: http.response.status_codetype: long- from: error.codetype: longignore_missing: truefail_on_error: falseoutput.elasticsearch:hosts: ["<elasticearch svc address>:9200"]protocol: "https"username: '<elasticsearch username>'password: '<elasticsearch password>'ssl:certificate_authorities: ["/usr/share/filebeat/certs/ca.crt"]noteRefer to the official
filebeat.ymlreference page to get know more possible options for this file. -
Install Filebeat in a dedicated
loggingnamespace:helm install filebeat-release --values values.yaml --namespace logging --create-namespace elastic/filebeat -
Verify installation:
helm list --allkubectl get pods --namespace loggingThe output of the above commands should present that the Helm chart is installed and all Filebeat pods are up and running.
Hardening
In the production environment, the Elasticsearch credentials defined in the values.yaml file should be stored in a Secret entity and referred to in that file. Also, the SSL verification should be enabled, and the CA certificate of Elastisearch should be provided.