lm-logs

by LogicMonitor

Helm chartv1.1.1App 1.4.0Verified publisher

A Helm chart for sending k8s logs to Logic Monitor

About this chart

Send Kubernetes logs to LM Logs

This chart deploy a fluentd based daemonset to collect and forward logs to LogicMonitor

Prerequisite

Deploy

Install the lm-logs chart, filling in the required values.

helm install -n <namespace> \
--set lm_company_name="<lm_company_name>" \
--set lm_access_id="<lm_access_id>" \
--set lm_access_key="<lm_access_key>" \
--set kubernetes.cluster_name="<cluster_name>" \
lm-logs logicmonitor/lm-logs

Install the lm-logs chart using a user defined secret for LM credentials.

# For LMv1
helm install lm-logs logicmonitor/lm-logs -n <namespace> \
  --set global.userDefinedSecret=lm-logs-credentials \
  --set kubernetes.cluster_name="<cluster_name>" \
  --set authMode=lmv1

# For Bearer
helm install lm-logs logicmonitor/lm-logs -n <namespace> \
  --set global.userDefinedSecret=lm-logs-credentials \
  --set kubernetes.cluster_name="<cluster_name>" \
  --set authMode=bearer

Parameters

The following tables lists the configurable parameters of the lm-logs chart and their default values.

ParameterDescriptionDefault
global.imagePullSecretsList of global registry secret names[] (does not add image pull secrets to deployed pods)
global.nameOverrideGlobal storage class for dynamic provisioning""
global.fullnameOverrideGlobal storage class for dynamic provisioning""
global.lm_company_nameLogicMonitor account namenil
global.userDefinedSecretUser Defined Secret for LM credentials""
global.lm_company_domainLogicMonitor company domain namelogicmonitor.com
global.lm_access_idLogicMonitor API Token Access IDnil
global.lm_access_keyLogicMonitor API Token Access Keynil
authModeMode to use for authenticating requests sent to LM. Can we lmv1/bearerlmv1
image.repositoryContainer image repositorylogicmonitor/lm-logs-k8s-fluentd
image.pullPolicyContainer image pull policyIfNotPresent
image.tagContainer image tag""
resources.limits.memoryContainer memory resource limit1000Mi
resources.requests.cpu.Container cpu resource requests300m
resources.requests.memoryContainer memory resource requests700Mi
fluent.device_less_logsbeta feature. when set true, do not send resource information. send service and namespace as metadata when truefalse
fluent.include_metadataif true send all metadata along with log msgtrue
fluent.resource_typeIf specified, the value will be statically applied to all ingested logs.""
fluent.buffer.typeBuffer type: memory or filememory
fluent.buffer.memory.flush_intervalFlush interval for memory buffer1s
fluent.buffer.memory.chunk_limit_sizeChunk limit size for memory buffer8m
fluent.buffer.memory.flush_thread_countNumber of flush threads for memory buffer8
fluent.buffer.memory.total_limit_sizeTotal buffer size limit for memory buffer512m
fluent.buffer.memory.compressCompression type for memory buffer (text or gzip)gzip
fluent.buffer.file.pathPrefix path for file buffer chunks/fluentd/buffer/lm-logs
fluent.buffer.file.flush_intervalFlush interval for file buffer1s
fluent.buffer.file.chunk_limit_sizeChunk limit size for file buffer8m
fluent.buffer.file.flush_thread_countNumber of flush threads for file buffer8
fluent.buffer.file.total_limit_sizeTotal buffer size limit for file buffer8g
fluent.buffer.file.compressCompression type for file buffer (text or gzip)gzip
tolerationsTolerations for pod assignment{} (evaluated as a template)
nodeSelectorsNode labels for pod assignment{} (evaluated as a template)
affinityAffinity for pod assignment{} (evaluated as a template)
envMap to add extra environment variables{}
kubernetes.multiline_start_regexpRegexp to match beginning of multiline/^\[(\d{4}-)?\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3}.*\]/
kubernetes.cluster_name(Required) Cluster name given while adding k8s cluster. Must be set for both standalone lm-logs and lm-container with lm-logs.""
kubernetes.multiline_concat_keyKey to look for fluentD to concatenate multiline logs"log"
fluent.monitorAgent.enabledEnable Fluentd monitor_agent to expose buffer metrics via HTTPfalse
fluent.monitorAgent.bindBind address for monitor_agent HTTP server0.0.0.0
fluent.monitorAgent.portListen port for monitor_agent HTTP server24220
fluent.extraFiltersExtra Fluentd <filter> YAML injected after Kubernetes metadata (only <filter> blocks allowed)""

Monitor Agent (Buffer Metrics)

The fluent.monitorAgent feature exposes Fluentd plugin and buffer metrics via HTTP, allowing clients to monitor buffer usage and plugin status in real-time.

Enable Monitor Agent

To enable the monitor agent:

helm install lm-logs logicmonitor/lm-logs -n <namespace> \
  --set lm_company_name="<company>" \
  --set lm_access_id="<access_id>" \
  --set lm_access_key="<access_key>" \
  --set kubernetes.cluster_name="<cluster_name>" \
  --set fluent.monitorAgent.enabled=true

Or in your values file:

fluent:
  monitorAgent:
    enabled: true
    bind: 0.0.0.0
    port: 24220

Access Monitor Metrics

After enabling, you can access the metrics endpoint:

# Port forward to a pod
kubectl port-forward ds/lm-logs 24220:24220 -n <namespace>

# Query the metrics endpoint
curl http://127.0.0.1:24220/api/plugins.json

This provides insights into:

  • Plugin status and configuration
  • Buffer queue size and memory usage
  • Retry counts and backoff state
  • Flush metrics and performance data

Buffer configuration (Fluentd)

The chart supports configuring all Fluentd buffer parameters. You can switch the buffer type between memory and file.

Defaults (Memory buffer)

By default, the chart uses the memory buffer with the following defaults:

buffer:
  type: memory
  memory:
    flush_interval: 1s
    chunk_limit_size: 8m
    flush_thread_count: 8
    total_limit_size: 512m
    compress: gzip   # text|gzip

All parameters are configurable.

File buffer

You can switch to file buffering by setting type=file:

buffer:
  type: file
  file:
    path: /fluentd/buffer/lm-logs
    flush_interval: 1s
    chunk_limit_size: 8m
    flush_thread_count: 8
    total_limit_size: 8g
    compress: gzip

All parameters are configurable, with the values above as defaults.

Custom Fluentd filters

Set fluent.extraFilters in your values file to inject additional Fluentd <filter> blocks after Kubernetes metadata enrichment. The chart only allows <filter> directives in this field; see values.yaml for commented examples.

For more information about custom filters configurable via the lm-logs Helm chart, refer to: https://www.logicmonitor.com/support/custom-fluentd-filters-in-the-lm-logs-helm-chart

Available Environment variables

For descriptions see: https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter

  • FLUENT_LOG_LEVEL
  • FLUENT_CONTAINER_TAIL_TAG
  • FLUENT_CONTAINER_TAIL_EXCLUDE_PATH
  • FLUENT_CONTAINER_TAIL_PARSER_TYPE
  • FLUENT_FILTER_KUBERNETES_URL
  • KUBERNETES_VERIFY_SSL
  • KUBERNETES_CA_FILE
  • FLUENT_KUBERNETES_METADATA_SKIP_LABELS
  • FLUENT_KUBERNETES_METADATA_SKIP_CONTAINER_METADATA
  • FLUENT_KUBERNETES_METADATA_SKIP_MASTER_URL
  • FLUENT_KUBERNETES_METADATA_SKIP_NAMESPACE_METADATA

User Defined Secret for LM credentials

You can create a kubernetes secret with your LM credentials and pass the secret name to the chart. The secret must contain the following keys:

  • account
  • accessID
  • accessKey
  • bearerToken (if accessKey/accessID is not present in the secret) Also, the authMode needs to be set accordingly. If the secret contains accessID/accessKey, authMode should be set to lmv1, otherwise bearer (similarly it should be set for the configurable parameters).

New deviceless logs k8s integration (beta)

Note: This feature may not be available to all customers. To enable this feature set fluent.device_less_logs=true

Problems with current integration

  • k8s pods are ephemeral, anomaly detection is done per pod. Which creates high volume of anomalies and makes it hard to monitor.
  • When new pod is created, argus takes time to register it as LM Device and resource mapping fails until then. Consequently we miss initial pod logs.

When fluent.device_less_logs=true Anomaly detection will be done on namespace and service

  • namespace will be k8s namespace
  • service will be extracted from metadata for yaml in the following priority.
    • kubernetes.labels.app ( deployments )
    • kubernetes.labels.app_kubernetes_io/name (daemon sets)
    • kubernetes.container_name
    • kubernetes.pod_name

Multiline log support for k8s lm logs

To use regexp to match beginning of multiline set kubernetes.multiline_start_regexp=<some-regex-pattern> by default the regex is set to /^\[(\d{4}-)?\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3}.*\]/

Logs appearing in cri format

If container runtime is containerD or cri-o, on lm-logs ui you might see logs with prefix eg.

2016-10-06T00:17:09.669794202Z stdout F The content of the log entry 1

To solve this we need to install lm-logs with following command :

helm upgrade --install -n <namespace> \
--set lm_company_name="<company>" \
--set lm_access_id="<access_id>" \
--set lm_access_key="<access_key"> \
--set kubernetes.cluster_name="<cluster_name>" \
--set env.FLUENT_CONTAINER_TAIL_PARSER_TYPE="cri" \
--set kubernetes.multiline_concat_key="message" \
lm-logs logicmonitor/lm-logs

Deploy lm-logs with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has lm-logs on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartlm-logs is pinned at v1.1.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply