Skip to content

Instantly share code, notes, and snippets.

@eriksywu
Created August 13, 2025 22:38
Show Gist options
  • Select an option

  • Save eriksywu/d3a5b66848efe78125bebd5ceb134fa2 to your computer and use it in GitHub Desktop.

Select an option

Save eriksywu/d3a5b66848efe78125bebd5ceb134fa2 to your computer and use it in GitHub Desktop.
otelcol yaml with `metricstarttime` processor using start_time_attribute
apiVersion: apps/v1
kind: Deployment
metadata:
name: otelcollector-deployment
spec:
replicas: 1
selector:
matchLabels:
app: otelcollector-deployment
template:
metadata:
annotations:
prometheus.io/port: "8888"
prometheus.io/scrape: "true"
creationTimestamp: null
labels:
app: otelcollector-deployment
spec:
containers:
- command:
- /otelcontribcol
- --config=/etc/otelcollector/config.yml
- --feature-gates=receiver.prometheusreceiver.EnableCreatedTimestampZeroIngestion,receiver.prometheusreceiver.RemoveStartTimeAdjustment
image: otelcontribcol:v0.132.0-podstarttime
imagePullPolicy: IfNotPresent
name: opentelemetry-collector
ports:
- containerPort: 4317
name: otel
protocol: TCP
- containerPort: 4318
name: otel-http
protocol: TCP
volumeMounts:
- mountPath: /etc/otelcollector
name: otelcollector-deployment-config
dnsPolicy: ClusterFirst
serviceAccount: otel-collector
serviceAccountName: otel-collector
volumes:
- configMap:
defaultMode: 420
name: otelcollector-deployment-config
name: otelcollector-deployment-config
---
apiVersion: v1
kind: ConfigMap
metadata:
name: otelcollector-deployment-config
data:
config.yml: |
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
prometheus:
config:
scrape_configs:
- job_name: 'nginx-tests'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_label_app]
action: keep
regex: nginx-test
processors:
metricstarttime/attributes:
strategy: start_time_attribute
include_metrics:
match_type: regexp
metrics: ["^nginx_.*"]
attributes_filters:
labels:
- key: app
value: nginx-test
op: "="
exporters:
debug:
verbosity: detailed
extensions:
zpages:
endpoint: 0.0.0.0:55679
health_check:
endpoint: "0.0.0.0:13133"
path: "/"
pprof: {}
service:
telemetry:
logs:
level: info
metrics:
level: normal
extensions:
- health_check
- pprof
- zpages
pipelines:
metrics:
receivers: [otlp, prometheus]
processors: [metricstarttime/attributes]
exporters: [debug]
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app: otelcollector-deployment
name: otel-collector
namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: otel-collector
labels:
app: otelcollector-deployment
rules:
- apiGroups: [""]
resources: ["namespaces", "pods"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: otel-collector
labels:
app: otelcollector-deployment
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: otel-collector
subjects:
- kind: ServiceAccount
name: otel-collector
namespace: default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment