lm-logs
by LogicMonitor
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
- LogicMonitor Collector installed and monitoring your Kubernetes Cluster.
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.
| Parameter | Description | Default |
|---|---|---|
global.imagePullSecrets | List of global registry secret names | [] (does not add image pull secrets to deployed pods) |
global.nameOverride | Global storage class for dynamic provisioning | "" |
global.fullnameOverride | Global storage class for dynamic provisioning | "" |
global.lm_company_name | LogicMonitor account name | nil |
global.userDefinedSecret | User Defined Secret for LM credentials | "" |
global.lm_company_domain | LogicMonitor company domain name | logicmonitor.com |
global.lm_access_id | LogicMonitor API Token Access ID | nil |
global.lm_access_key | LogicMonitor API Token Access Key | nil |
authMode | Mode to use for authenticating requests sent to LM. Can we lmv1/bearer | lmv1 |
image.repository | Container image repository | logicmonitor/lm-logs-k8s-fluentd |
image.pullPolicy | Container image pull policy | IfNotPresent |
image.tag | Container image tag | "" |
resources.limits.memory | Container memory resource limit | 1000Mi |
resources.requests.cpu. | Container cpu resource requests | 300m |
resources.requests.memory | Container memory resource requests | 700Mi |
fluent.device_less_logs | beta feature. when set true, do not send resource information. send service and namespace as metadata when true | false |
fluent.include_metadata | if true send all metadata along with log msg | true |
fluent.resource_type | If specified, the value will be statically applied to all ingested logs. | "" |
fluent.buffer.type | Buffer type: memory or file | memory |
fluent.buffer.memory.flush_interval | Flush interval for memory buffer | 1s |
fluent.buffer.memory.chunk_limit_size | Chunk limit size for memory buffer | 8m |
fluent.buffer.memory.flush_thread_count | Number of flush threads for memory buffer | 8 |
fluent.buffer.memory.total_limit_size | Total buffer size limit for memory buffer | 512m |
fluent.buffer.memory.compress | Compression type for memory buffer (text or gzip) | gzip |
fluent.buffer.file.path | Prefix path for file buffer chunks | /fluentd/buffer/lm-logs |
fluent.buffer.file.flush_interval | Flush interval for file buffer | 1s |
fluent.buffer.file.chunk_limit_size | Chunk limit size for file buffer | 8m |
fluent.buffer.file.flush_thread_count | Number of flush threads for file buffer | 8 |
fluent.buffer.file.total_limit_size | Total buffer size limit for file buffer | 8g |
fluent.buffer.file.compress | Compression type for file buffer (text or gzip) | gzip |
tolerations | Tolerations for pod assignment | {} (evaluated as a template) |
nodeSelectors | Node labels for pod assignment | {} (evaluated as a template) |
affinity | Affinity for pod assignment | {} (evaluated as a template) |
env | Map to add extra environment variables | {} |
kubernetes.multiline_start_regexp | Regexp 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_key | Key to look for fluentD to concatenate multiline logs | "log" |
fluent.monitorAgent.enabled | Enable Fluentd monitor_agent to expose buffer metrics via HTTP | false |
fluent.monitorAgent.bind | Bind address for monitor_agent HTTP server | 0.0.0.0 |
fluent.monitorAgent.port | Listen port for monitor_agent HTTP server | 24220 |
fluent.extraFilters | Extra 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.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartlm-logs is pinned at v1.1.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- 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