Stream pipeline logs
Stream build and deploy pipeline stage execution logs from a self-managed Harness Delegate to your observability backend using OpenTelemetry or another supported log collector.
When enabled, Harness streams build and deploy pipeline stage execution logs to stdout as structured JSON, in parallel with the standard Harness Log Service. A log collector such as OpenTelemetry Collector, Fluent Bit, or Vector then captures these logs and forwards them to your observability backend.
This functionality offers the following benefits:
Consolidate build and deploy logs with existing observability data.
Enable sophisticated search and analytics.
Configure alerts and custom dashboards.
Manage log retention and meet compliance requirements.
What you will learn in this topic
How log streaming architecture works.
Which delegate and infrastructure combinations are supported.
How to enable log streaming on your delegate.
How to configure log collection with OpenTelemetry or other collectors.
How to verify log streaming in your observability backend.
The log format and schema Harness emits.
Example queries for Loki, Splunk, and Elasticsearch
Before you begin
Before you configure log streaming, ensure that you have:
A Harness account with access to the Deploy stage, Build stage, or both.
A supported self-managed Delegate with access to the infrastructure where your build and deploy pipeline stages execute.
Permission to update the Delegate configuration and set the
HARNESS_LOG_STREAMING_STDOUT_ENABLEDenvironment variable.For Kubernetes deployments, access to the cluster where the Delegate and build stage workloads run.
A log collector, such as OpenTelemetry Collector, Fluent Bit, Vector, or Promtail, configured to collect logs from the appropriate build and/or deploy stage log paths.
An observability backend capable of receiving the collected logs, such as Grafana Loki, Splunk, Datadog, or Elasticsearch.
Supported infrastructure
Support for log streaming depends on your delegate type and execution infrastructure:
Self-managed Legacy Delegate
Kubernetes cluster
Supported
A node-level log collector DaemonSet tails build stage pod logs and delegate execution logs, including deploy execution logs.
Self-managed Kubernetes Delegate
Kubernetes cluster
Not supported
Kubernetes-based builds on Delegate 3.x do not currently support log streaming.
Harness Cloud (hosted build infrastructure)
N/A
Not applicable
Logs are managed by Harness and are not exposed for external collection.
Log streaming architecture
When log streaming is enabled, Harness writes execution logs as structured JSON to stdout.
The log source differs slightly between build and deploy stage:
Build stage: The delegate propagates the log-streaming flag to the containers in build stage pods. The orchestrator container writes stage-level lines, such as setup, step dispatch, and teardown, while each step container writes its execution output as JSON to stdout.
Deploy stage: Deploy execution logs are emitted by the delegate process as structured JSON execution logs.
Because build and deploy stages logs originate from different workloads, the OTel Collector must include the appropriate paths for both log sources.
For Kubernetes:
Build stage pod logs:
/var/log/pods/<namespace>_harnessci-*/**/*.logDelegate execution logs, including deploy stage task execution:
/var/log/pods/<namespace>_<delegate-name>-*/**/*.log
The log-streaming enablement is the same for build and deploy stages, but logs are collected from different Kubernetes pod paths.
The example OTel configuration in this topic includes both the build stage pod path and the delegate path required for deploy execution logs.
Step 1: Enable log streaming
Enable log streaming by setting HARNESS_LOG_STREAMING_STDOUT_ENABLED=true. The same delegate configuration is used for build and deploy stages.
For Kubernetes environments (Legacy Delegate)
Edit your delegate Deployment manifest and add the environment variable HARNESS_LOG_STREAMING_STDOUT_ENABLED=true to the delegate container:
Apply the manifest and wait for the rollout to complete:
For Docker-based delegates
Add the environment variable to your docker run command:
After the delegate restarts with log streaming enabled, the setting applies to supported build and deploy pipeline stage executions handled by that delegate. No changes to individual pipeline YAML definitions are required.
Step 2: Configure log collection
Once log streaming is enabled, you can configure your log collector of choice to tail and forward the log records.
For Kubernetes environments, deploy an OpenTelemetry (OTel) Collector DaemonSet in your cluster to tail the node container logs. The filelog receiver tails container logs under /var/log/pods, and a parser extracts the JSON envelope emitted by Harness.
For deploy and build environments, configure the collector to include:
Build stage pod logs under
harnessci-*.Delegate pod logs for deploy stage and other delegate-level execution logs.
Below is an example snippet for the OTel Collector configuration. Replace <your-namespace> and <your-delegate-name> with your actual values:
The two include entries serve different purposes. If you use both build and deploy stages, keep both paths in the collector configuration.
Step 3: Verify log streaming
Perform the following steps to verify the log streaming:
Run a build stage or deploy pipeline handled by the configured delegate.
Check your collector DaemonSet logs:
Query your observability backend for logs with
service.name = "harness".Verify that the expected pipeline execution logs are present.
For build stage, verify logs generated by the build stage pod.
For deploy stage, verify execution logs collected from the delegate pod.
Log format reference
Build and deploy execution logs are written as structured JSON objects. The schema is identical for both build stage and deployment stage steps.
Field reference
timestamp
UTC timestamp in RFC 3339 nanosecond format.
level
Log level: INFO, WARN, ERROR. Note that for Kubernetes build pod stdout, this is currently hardcoded to INFO on the stdout stream. Severity-based filtering can be done on the message content downstream or by relying on the original Harness Log Service.
message
The actual log line content.
logType
Always EXECUTION_LOGS for the pipeline execution output.
logAbstractions.accountId
Your Harness account identifier.
logAbstractions.orgId
The organization identifier.
logAbstractions.projectId
The project identifier.
logAbstractions.pipelineId
The pipeline identifier.
logAbstractions.runSequence
The run number (or run sequence).
logAbstractions.planExecutionId
The unique execution ID for this pipeline run.
logAbstractions.stageIdentifier
The stage that produced the log.
logAbstractions.stepIdentifier
The identifier of the step that produced this line, or engine for stage-level orchestration lines.
logContext.taskId
The delegate task ID (present when available).
Query examples
The following query examples assume the default service.name (harness) tags configured in the steps above.
Grafana Loki (LogQL)
Splunk (SPL)
Elasticsearch (KQL)
Resiliency and data safety
Because log streaming writes logs in parallel to the standard flow, Harness UI logs are unaffected by outages in your external log collector or observability backend. The collector handles buffering and retries asynchronously.
Log collector restarts
The collector tracks its read position (offset) in each log file. Upon restart, it resumes reading from that offset.
No data lost (as long as files have not been rotated or pruned on disk).
Backend is temporarily down
The collector buffers logs in a sending queue and retries with exponential backoff.
No data lost (within the buffer and retry window).
Backend is down for an extended period
The sending queue becomes full. Once the queue is full, the oldest buffered log entries are dropped.
Logs may be lost on the collector side (only the external copy; Harness UI logs remain fully intact).
Collector crashes
In-memory buffers and queue states are lost.
Minimal data lost (limited to in-flight batches that were not yet flushed to the backend).
FAQs
Related concepts
Now that you understand log streaming for build and deploy pipelines, explore related infrastructure and logging topics:
Kubernetes deployments: Deploy applications to Kubernetes clusters. Log streaming captures all Kubernetes deployment step logs (such as Apply, Rolling, Blue Green) as structured JSON.
Set up a Kubernetes cluster build infrastructure: Learn how to configure a self-managed Kubernetes build farm for build stages.
Customize delegate logging: Configure log patterns and levels for the delegate process itself.
Continuous Integration: Learn how to build, test, and verify code using Harness build stage.
Continuous Delivery: Learn how to deploy and manage application delivery using Harness deploy stage.
Last updated
Was this helpful?