Log Management is a configurable feature that can be enabled or disabled at the client level through the portal.

Prerequisites

To use Log Management, the Log Management option must be enabled. This can be done either during client creation or after the client has been created:

Configuration

By default, the agent will collect all pod logs and export them to OpsRamp if enableLogManagement is set to TRUE in the manifest file and Enable Log Management is set to Yes on the client details page.

Custom Configuration

For users who wish to customize log collection, the ConfigMap opsramp-pod-logs-user-config is available in the agent-installed namespace and supports various configurations.

Default ConfigMap

The default ConfigMap allows users to edit settings for log customization later without any initial modifications.

To list the default ConfigMap, use the following command:

kubectl get configmap opsramp-logs-user-config -n <agent-installed-namespace>

The manifest will appear as follows:

apiVersion: v1
kind: ConfigMap
metadata:
  name: "opsramp-logs-user-config"
  labels:
    app: "opsramp-logs-user-config"
  namespace: <agent-installed-namespace>
data:
  logsConfig.yaml: |
    pods:
      additional_labels:   
      namespaces:
        include: 
        is_include_regex: false
        exclude: 
        is_exclude_regex: false
      log_level: "Unspecified"

Additional Labels

Under additional_labels, users can specify key-value pairs that will be added as attributes to each log record. To edit the ConfigMap, use:

kubectl edit configmap opsramp-logs-user-config -n <agent-installed-namespace>  

Example:

apiVersion: v1
kind: ConfigMap
metadata:
  name: "opsramp-logs-user-config"
  labels:
    app: "opsramp-logs-user-config"
  namespace: <agent-installed-namespace>
data:
  logsConfig.yaml: |
    pods:
      additional_labels:  
        app: nginx
        env: staging  

Namespace Filtering

By default, the agent will collect pod logs in all namespaces. Suppose the user wants to have logs of only a few namespaces. In that case, the user has to specify inclusion or exclusion rules on namespaces by editing the opsramp-pod-logs-user-config ConfigMap.

kubectl edit configmap opsramp-logs-user-config -n <agent-installed-namespace>

Example:

apiVersion: v1
kind: ConfigMap
metadata:
  name: "opsramp-logs-user-config"
  labels:
    app: "opsramp-logs-user-config"
  namespace: <agent-installed-namespace>
data:
  logsConfig.yaml: |  
    pods: 
      namespaces:
          include: 
            - ^monitoring
          is_include_regex: true
          exclude: 
            - monitoring-test
          is_exclude_regex: false

Use Case:

InclusionExclusionResult
Not setNot setLogs of all namespaces will be collected
Some filterNot setLogs of namespaces that match the inclusion filter
Not setSome filterLogs of all namespaces except those that match the exclusion filter
Some filterSome filterLogs of namespaces that match the inclusion filter minus logs that match the exclusion filter

Use CaseInclusionExclusion
Collects logs of a single namespace " agent."include: agent
is_include_regex: false
-
Collect logs of all namespaces which starting with test onlyinclude: ^test
is_include_regex: true
-
Collects logs of all namespaces except the "kube-system" namespace-exclude: kube-system
is_exclude_regex: false
Collects logs of all namespaces except namespace ending with the name " system."-exclude: system$
is_exclude_regex: true
Collects logs of all namespaces starting with test or kube.include: ^test|^kube
is_include_regex: true
-
Collects logs of all namespaces which start with test or kube but exclude testing or kube-system namespacesinclude: ^test|^kube
is_include_regex: true
exclude: testing, kube-system
is_exclude_regex: false
Collects logs of namespaces which end with "agent" but excludes any namespace starting with opsrampinclude: agent$
is_include_regex: true
exclude: ^opsramp
is_exclude_regex: true

Log-Level Filtering

Log severity levels are prioritized as follows: Fatal > Error > Warn > Info > Debug > Trace > Unspecified/Unknown. By default, all logs are sent based on this hierarchy. To filter logs by severity, specify a log level in the configuration:

Example-1:

log_level: Warn 

Example-2:

log_level: Info

View Logs in OpsRamp Portal

Users can view logs in the OpsRamp portal from Infrastructure > Logs.

  1. Default Logs Screen: Access your logs through the Logs UI.
    Event Management
  2. Logs Filter: Click on +FILTER to select resource types and operators (e.g., Equals, Regex Not Contains).
  3. Live Tail: Click on LIVE TAIL to view real-time logs.
  4. Log Details: Click on any log entry for detailed information.
    Event Management

Once you edit the K8s ConfigMap and apply it to your cluster, the OpsRamp Agent will pick up the latest configuration changes within a few minutes. This version organizes the content into clear sections and uses straightforward language for better understanding.