Prometheus Operators
in the Wild
Observability Day; KubeCon; Paris 2024
Bartłomiej Płotka; Google
Mahmoud Amin; Google
@bwplotka
@maxamins
@bwplotka
@maxamins
Who are we?
Mahmoud Amin
Software Engineer @ Google
Fun fact: 10 patents
@bwplotka
@maxamins
Who are we?
Bartłomiej Płotka
Senior Software Engineer @ Google
Tech Lead for Google Cloud Managed Service for Prometheus
Maintainer for e.g. Prometheus, Thanos, GMP Operator
Tech Lead for CNCF TAG Observability
@bwplotka
@maxamins
Who are we?
Bartłomiej Płotka
Senior Software Engineer @ Google
Tech Lead for Google Cloud Managed Service for Prometheus
Maintainer for e.g. Prometheus, Thanos, GMP Operator
Tech Lead for CNCF TAG Observability
Efficient Go book: https://www.bwplotka.dev/book
🔥 Giveaway & signing tomorrow 10:40 G18 O’Reilly booth
@bwplotka
@maxamins
Prometheus (collection) in Kubernetes
@bwplotka
@maxamins
Do we need Operators?
@bwplotka
@maxamins
K8s Consistent & Multi-Tenant Configuration
global:
scrape_interval: 15s
external_labels:
prom: 1
scrape_configs:
-job_name: “Application A”
metrics_path: /metrics
scheme: http
kubernetes_sd_config:
role: pod
authorization: ..
relabel_config: …
-job_name: “Application B”
metrics_path: /internal/metrics
scheme: https
kubernetes_sd_config:
role: pod
@bwplotka
@maxamins
K8s Consistent & Multi-Tenant Configuration
apiVersion: …
kind: …
spec:
selector:
matchLabels:
app: App A
endpoints:
- port: metrics
interval: 15s
status:
targets:
- address: …
status: OK
lastError: “”
duration: 596ms
apiVersion: …
kind: …
spec:
selector:
matchLabels:
app: App B
endpoints:
- port: metrics
interval: 10s
path: /internal/metrics
status:
targets:
- address: …
status: OK
lastError: “”
duration: 270ms
@bwplotka
@maxamins
Deployment & Scalability
@bwplotka
@maxamins
Deployment & Scalability
prometheus:
hashmod: true
series_per_replica: 1M
@bwplotka
@maxamins
Prometheus Operators to Help!
For:
👉🏽 Kubernetes native, simplified, multi-tenant scrape configuration
👉🏽 Easy installation & operations for complex, scalable deployments
@bwplotka
@maxamins
Prometheus Operator
https://prometheus-operator.dev/
@bwplotka
@maxamins
@bwplotka
@maxamins
Prometheus/PrometheusAgent CR
apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
name: prometheus
spec:
podMonitorNamespaceSelector: {}
podMonitorSelector: {}
shards: 3
remoteWrite:
- url: https://remote-endpoint…
@bwplotka
@maxamins
PodMonitor CR
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
spec:
namespaceSelector: A
selector:
matchLabels:
app: App A
podMetricsEndpoints:
- port: metrics
interval: 15s
apiVersion:
monitoring.coreos.com/v1
kind: PodMonitor
spec:
namespaceSelector: B
selector:
matchLabels:
app: App B
endpoints:
- port: metrics
interval: 10s
path: /internal/metrics
@bwplotka
@maxamins
GMP Operator
https://github.com/GoogleCloudPlatform/prometheus-engine
@bwplotka
@maxamins
@bwplotka
@maxamins
GMP deploys Prometheus as a DaemonSet
@bwplotka
@maxamins
GMP OperatorConfig CR
apiVersion: monitoring.googleapis.com/v1
kind: OperatorConfig
metadata:
namespace: gmp-public
name: config
exports:
url:
- https://remote-endpoint…
collection:
compression: gzip
filter:
matchOneOf:
- '{__name__!~"container_foo.*"}'
@bwplotka
@maxamins
GMP PodMonitoring CR
apiVersion: monitoring.googleapis.com/v1
kind: PodMonitoring
metadata:
namespace: namespace-1
name: prom-example
spec:
selector:
matchLabels:
app: App A
endpoints:
- port: metrics
interval: 15s
@bwplotka
@maxamins
GMP ClusterPodMonitoring CR
apiVersion: monitoring.googleapis.com/v1
kind: ClusterPodMonitoring
metadata:
name: prom-example
spec:
selector:
matchLabels:
app: App A
endpoints:
- port: metrics
interval: 15s
@bwplotka
@maxamins
Optimizing for DaemonSet Deployment
👉🏽 Tailoring CRDs (PodMonitoring) for DaemonSet case (e.g. no ServiceMonitor).
👉🏽 Leveraging how Kubernetes caches Pod API (it’s cached per node).
👉🏽 (upcoming) Secure & efficient secret support.
https://kccncna2022.sched.com/event/182IV/stateless-collectors-for-stateful-data-scaling-prometheus-as-a-node-agent-danny-clark-google
@bwplotka
@maxamins
Demo Time!
@bwplotka
@maxamins
@bwplotka
@maxamins
TL;DR: Prometheus vs GMP Operator
Simpler stack (also enabled by default on GKE)
More options & useful when you need local query
@bwplotka
@maxamins
Thanks!
Questions…?
Feedback & contributions welcome on both!
Prometheus Operator
https://prometheus-operator.dev/
GMP Operator
https://github.com/GoogleCloudPlatform/prometheus-engine
@bwplotka
@maxamins
@bwplotka
@maxamins
Demo Reference
@bwplotka
@maxamins
Demo Reference
@bwplotka
@maxamins
Demo Reference
@bwplotka
@maxamins
Demo Reference
@bwplotka
@maxamins
Demo Reference
@bwplotka
@maxamins
Demo Reference
@bwplotka
@maxamins
Demo Reference
@bwplotka
@maxamins