Skip to content

GitOps-Deployed Observability Pipelines: From Sampling to Grafana

Interactive Diagram

새 탭 ↗

ā€œWe installed Grafanaā€ tells you almost nothing about observability. The decisions that actually matter sit behind it. Which Traces do you discard? What Metadata do you attach? Where do Traces, Metrics, and Logs live, and for how long? And does alerting actually exist?

By the time you have read up to Delivering Secrets to Kubernetes Workloads with Workload Identity and CSI, your applications already deploy declaratively. This article walks the pipeline that signals flow through on that same GitOps boundary. Storage cost and signal quality are set at each stage of that pipeline, not by which backend product you picked.

For Java applications, attaching an agent without code changes is the lowest-cost starting point. It comes down to a handful of environment variables in the Deployment overlay.

env:
- name: JDK_JAVA_OPTIONS
value: "-XX:+UseContainerSupport -javaagent:/app/bin/opentelemetry-javaagent.jar"
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: http://otel-collector.observability:4318
- name: OTEL_SERVICE_NAME
value: orders-api
- name: OTEL_RESOURCE_ATTRIBUTES
value: "service.namespace=orders"
- name: OTEL_INSTRUMENTATION_MICROMETER_ENABLED
value: "true"
- name: OTEL_INSTRUMENTATION_LOGBACK_ENABLED
value: "true"

Three things matter. First, the exporter endpoint is an in-cluster service DNS name. The application has no idea whether the backend is Tempo or Mimir, and that ignorance is what makes backend replacement possible. Second, OTEL_SERVICE_NAME and service.namespace become the axes of every later query. Changing the naming convention afterwards severs continuity with historical data, so fix it early. Third, the agent emits Metrics and Logs over the same OTLP path as Traces, so all three signals share identical resource attributes. That is the foundation of jumping from a Trace to its Logs later.

How you deploy the collector depends on what you are collecting.

  • A DaemonSet runs one instance per node. It is required for collection that must be node-local, such as reading host log files or scraping kubelet metrics.
  • A Deployment runs a few replicas behind a service. When applications push OTLP, node locality is irrelevant, and this shape suits processing that needs all spans of one Trace in one place, such as tail sampling.

This article deals with application telemetry, so it uses deployment mode. Tail sampling does introduce one constraint: if spans sharing a traceID scatter across replicas, the sampling decision fragments. Scaling out requires traceID-aware load balancing in front, or a separate sampling tier. Simply increasing the replica count is not safe scaling.

Kubernetes Metadata is attached through a preset.

mode: deployment
presets:
kubernetesAttributes:
enabled: true
extractAllPodLabels: true
extractAllPodAnnotations: false

extractAllPodLabels is convenient but not free. Labels become resource attributes verbatim, so a team that adds labels liberally quietly raises cardinality. Leaving annotations off is therefore sensible, annotations tend to hold long strings injected by deployment tooling.

PlantUML Diagram

The key property of this diagram is that only Traces pass through filter and tail sampling. Metrics arrive pre-aggregated and are not sampling candidates, and Log reduction is a separate policy problem.

The cheapest storage is data you never store. The filter processor is the first reduction point.

processors:
filter:
error_mode: ignore
traces:
span:
- IsMatch(attributes["http.route"], ".*actuator.*")
- attributes["code.function"] == "handle"

Health checks and metric scrape endpoints are called every few seconds and carry almost no diagnostic value. Such spans easily account for a large share of total span volume. error_mode: ignore means a failed condition evaluation will not kill the pipeline, and that deserves scrutiny: if a condition is silently voided, data keeps flowing, so you must confirm the filter is actually working through the collector’s own metrics.

The second caution is that attribute-based removal is fragile against route renaming. A pattern like .*actuator.* silently filters nothing once the framework’s endpoint paths change. You need a recurring check of the real span name distribution.

Head sampling decides at Trace start, so it cannot know whether the Trace ended in an error. Tail sampling decides after the Trace has (mostly) completed, so it can selectively retain errors and slow requests.

Tail sampling processor waiting until every span in a trace, from the root span down, is finished before making the sampling decision Source: OpenTelemetry docs, Sampling, The OpenTelemetry Authors, CC BY 4.0

tail_sampling:
decision_wait: 10s
num_traces: 1000
expected_new_traces_per_sec: 100
policies:
- name: slow
type: latency
latency: { threshold_ms: 500 }
- name: errors
type: status_code
status_code: { status_codes: [ERROR] }
- name: baseline
type: probabilistic
probabilistic: { sampling_percentage: 5 }

Policies combine as OR. A Trace is kept if it exceeds 500ms, or carries ERROR status, or falls in the 5% baseline sample of everything else. Each policy answers a different question. The latency policy answers ā€œcan I investigate requests that violated the SLO?ā€, the error policy answers ā€œam I missing any failures?ā€, and the probabilistic policy answers ā€œdo I have a baseline of normal behaviour to compare against?ā€. Drop the third and your Trace store contains only errors and slow requests, leaving you unable to answer what normal looked like.

These numbers are tuning inputs, not universal defaults. 500ms must come from that service’s SLO, and 5% must come from normal traffic volume and storage budget. decision_wait: 10s means Traces slower than that can be truncated, so it must exceed the real p99 response time. num_traces and expected_new_traces_per_sec directly determine collector memory usage and must be raised alongside traffic growth, otherwise the memory limiter starts dropping data.

The resource processor handles the final cleanup.

resource:
attributes:
- key: service.instance.id
from_attribute: k8s.pod.uid
action: insert

Promoting the Pod UID to an instance identifier makes ā€œa problem that only occurs on one replicaā€ distinguishable. action: insert means an existing value is not overwritten, respecting anything the application set itself.

The reason not to put all three signals in one store is that their query patterns and retention needs are entirely different.

SignalBackend roleDominant query patternCost driverReasonable retention
TraceRetrieve individual executions by traceID or attributesShort-window deep investigation after an incidentSpan count and per-span attribute sizeShort (days)
MetricTime-series aggregation and trendsDashboards and long-term comparisonNumber of active series, i.e. label cardinalityLong (months to years)
LogText search and contextA narrow time window arrived at from a TraceIngested bytes and number of indexed labelsMedium

All three backends use object storage as their real store and keep only ingest and query components in the cluster. This separation matters because retention is then controlled at the storage layer rather than by Kubernetes.

storage:
trace:
backend: azure
azure:
container_name: trace-chunks
storage_account_name: <storage-account>

Splitting containers per signal lets you apply different lifecycle rules per signal: delete the Trace container after 30 days, move the Metric container to a cheaper tier, each independently. Put everything in one container and the longest retention applies to all data, with cost set by the most expensive signal.

Rather than embedding a storage account key in the backend configuration, use workload identity as described in Delivering Secrets to Kubernetes Workloads with Workload Identity and CSI. A backend component is, after all, just another workload.

What is actually provisioned in Grafana, and what is not

Section titled ā€œWhat is actually provisioned in Grafana, and what is notā€

This is the easiest place to overstate things. You have to open the actual chart configuration and see what is switched on.

Datasources are provisioned. The values contain datasource definitions, including cross-signal linking.

datasources:
datasources.yaml:
apiVersion: 1
datasources:
- name: mimir
type: prometheus
url: http://mimir-gateway.mimir/prometheus
- name: loki
type: loki
url: http://loki-gateway.loki
- name: tempo
type: tempo
url: http://tempo-gateway.tempo
jsonData:
tracesToLogsV2:
datasourceUid: loki
spanStartTimeShift: "-10m"
spanEndTimeShift: "10m"
filterByTraceID: true
tracesToMetrics:
datasourceUid: mimir

tracesToLogsV2 and tracesToMetrics are the substantive value here. From a single span you can jump in one click to the Logs of that time window or to related Metrics. This linkage works only because the instrumentation stage made all three signals share resource attributes. Decisions made at the front of the pipeline are cashed in here.

Dashboards and alerting are not provisioned. Inspection shows dashboardProviders, dashboards, and dashboardsConfigMaps all empty, the sidecar’s dashboards.enabled and alerts.enabled both false, and alerting and notifiers empty. The backends match: Mimir’s and Loki’s ruler are disabled, as is Alertmanager.

Stated honestly: this configuration has no automated alerting. A collection of dashboard JSON files in a repository is an export library, not provisioning, and a sentence in a document saying ā€œthis value is dangerous when exceededā€ is not an alert. To claim alerting exists you need, at minimum, a ruler evaluating rules, an Alertmanager or Grafana unified alerting receiving the results, and a real contact point. Missing any of the three makes it a gap.

This pipeline was validated on the development cluster aks-platform-dev-01, and development-oriented simplifications appear in several places.

ItemDevelopment configurationRequired in production
Backend replicasMostly single replicaRedundancy on both ingest and query paths, restartable without outage
In-cluster transportPlaintext HTTP over service DNSmTLS or service-mesh-level transport protection
Collector scalingA single collector deploymenttraceID-aware load balancing with a separate sampling tier
AlertingNoneEnable the ruler, an Alertmanager or unified alerting, contact points and silence policy
DashboardsCreated by handDeclarative provisioning via sidecar or provider, with change history
Retention policyDefaultsPer-signal lifecycle rules and cost observation
Watching the collector itselfOnly self-metrics exposedAlert on dropped spans, refused data, and memory limiter activation

That last row matters most. If the observability pipeline itself fails quietly, you cannot distinguish ā€œthere are no incidentsā€ from ā€œno data is arriving.ā€ Exporter failure counts and refused-data counts on the collector must be under observation.

Observability quality and cost are determined by naming conventions at instrumentation, the collector’s deployment shape, filter and tail sampling policy, per-signal backends and object storage lifecycle, and what is genuinely provisioned as datasources and alerts. Grafana is the last window onto this pipeline, not the pipeline itself.

And it matters not to claim what you have not verified. This configuration is declaratively complete through signal collection and cross-signal query linking, but alert automation remains a next step. Calling a gap a gap is the only way a pipeline actually gets finished.