Troubleshooting audit logs

Troubleshooting audit logs

Cannot see audit logs in Kibana

The issue might be due to any of the following reasons:

Enable audit logging but do not send logs to ELK

If you want to enable audit logging, but do not want to send the logs to ELK, complete the following steps:

  1. Edit audit-logging-fluentd-ds-config ConfigMap file.

    kubectl -n kube-system edit configmap audit-logging-fluentd-ds-config
    
  2. Remove the following ELK configuration from fluentd configuration:

    <match icp-audit kube-audit>\n  @type elasticsearch\n  @log_level info\n  type_name fluentd\n  hosts \
    elasticsearch:9200\n  type_name fluentd\n  id_key _hash\n  remove_keys _hash\n  logstash_format true\n  \
    logstash_prefix audit\n  scheme https\n  ssl_version TLSv1_2\n  ca_file /fluentd/etc/tls/ca.crt\n  client_cert \
    /fluentd/etc/tls/curator.crt\n  client_key /fluentd/etc/tls/curator.key\n  client_key_pass \
    \"#{ENV[\"APP_KEYSTORE_PASSWORD\"]}\"\n  <buffer>\n    flush_thread_count 8\n    flush_interval 5s\n    \
    chunk_limit_size 2M\n    queue_limit_length 32\n    retry_max_interval 30\n    retry_forever true\n  </buffer>\n</match>
    

    Note: Carefully edit the ConfigMap. If you accidentally delete any space or add a line, the fluentd pods might show an error.

  3. Restart the fluentd pods.

    • Use the IBM® Cloud Private management console to restart the pods.

      a. Log on to the IBM® Cloud Private management console.

      b. From the navigation menu, click Workloads > DaemonSets > audit-logging-fluentd-ds.

      c. Remove all pods.

    • Use kubectl to restart the pods.

      kubectl -n kube-system get pod -o wide | grep audit-logging-fluentd-ds- | awk '{print $1}' | xargs kubectl delete pod -n kube-system
      

    Kubernetes restarts the fluentd pod with the updated configuration.

Error when upgrading audit-logging

When you use the web console to upgrade audit-logging, an error that resembles the following message appears at the top of the Upgrade modal:

"Invalid request : rpc error: code = Unknown desc = DaemonSet.apps "audit-logging-fluentd-ds" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"role":"fluentd", "app":"audit-logging-fluentd", "component":"fluentd", "heritage":"Tiller", "release":"audit-logging"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable"

If you see the error, you must use the command line interface (CLI). Complete the following steps to upgrade audit-logging.

  1. Delete all audit-logging-fluentd-ds- ConfigMaps.

    kubectl get cm -n kube-system -o wide | grep audit-logging-fluentd-ds- | awk '{print $1}' | xargs kubectl delete cm -n kube-system
    
  2. Upgrade the audit-logging Helm release.

    helm upgrade audit-logging mgmt-charts/audit-logging --force -f audit-value.yaml --version <newer version> --tls
    
  3. Alternatively, you can delete the audit-logging Helm release and configure a newer version.