1 of 30

Prometheus Operators

in the Wild

Observability Day; KubeCon; Paris 2024

Bartłomiej Płotka; Google

Mahmoud Amin; Google

@bwplotka

@maxamins

@bwplotka

@maxamins

2 of 30

Who are we?

Mahmoud Amin

Software Engineer @ Google

  • GMP Operator maintainer
  • OSS (e.g. GSoC) mentor

Fun fact: 10 patents

@bwplotka

@maxamins

3 of 30

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

4 of 30

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

5 of 30

Prometheus (collection) in Kubernetes

@bwplotka

@maxamins

6 of 30

Do we need Operators?

@bwplotka

@maxamins

7 of 30

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

8 of 30

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

9 of 30

Deployment & Scalability

@bwplotka

@maxamins

10 of 30

Deployment & Scalability

prometheus:

hashmod: true

series_per_replica: 1M

@bwplotka

@maxamins

11 of 30

Prometheus Operators to Help!

For:

👉🏽 Kubernetes native, simplified, multi-tenant scrape configuration

👉🏽 Easy installation & operations for complex, scalable deployments

@bwplotka

@maxamins

12 of 30

Prometheus Operator

https://prometheus-operator.dev/

@bwplotka

@maxamins

@bwplotka

@maxamins

13 of 30

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

14 of 30

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

15 of 30

GMP Operator

https://github.com/GoogleCloudPlatform/prometheus-engine

@bwplotka

@maxamins

@bwplotka

@maxamins

16 of 30

GMP deploys Prometheus as a DaemonSet

@bwplotka

@maxamins

17 of 30

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

18 of 30

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

19 of 30

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

20 of 30

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

21 of 30

Demo Time!

@bwplotka

@maxamins

@bwplotka

@maxamins

22 of 30

TL;DR: Prometheus vs GMP Operator

  • Focus on hashmod deployment (plans for more)
  • Only DaemonSet based deployment
  • Allows HA + query + storage + collection use case
  • Tailored CRDs for collection use case
  • Supports ~all the Prometheus knobs
  • Simpler CRDs (e.g. opinionated, limited relabelling)
  • Service-based monitoring
  • Target status propagation

Simpler stack (also enabled by default on GKE)

More options & useful when you need local query

@bwplotka

@maxamins

23 of 30

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

24 of 30

Demo Reference

@bwplotka

@maxamins

25 of 30

Demo Reference

@bwplotka

@maxamins

26 of 30

Demo Reference

@bwplotka

@maxamins

27 of 30

Demo Reference

@bwplotka

@maxamins

28 of 30

Demo Reference

@bwplotka

@maxamins

29 of 30

Demo Reference

@bwplotka

@maxamins

30 of 30

Demo Reference

@bwplotka

@maxamins