Overview
Prometheus collects and stores metrics from all components in the cluster, providing the foundation for monitoring and alerting. It’s deployed as part of thekube-prometheus-stack.
Configuration
Nixidy Module (nixidy/env/local/kube-prometheus-stack.nix)
Access
- URL: http://localhost:30090
- Port: 30090 (NodePort)
Storage
Data Retention
- Retention period: 24 hours
- Storage size: 5Gi persistent volume
- Access mode: ReadWriteOnce
Remote Write Receiver
Prometheus accepts remote write from:- Tempo metrics generator - RED metrics from traces
- External collectors - Can push metrics via remote write API
http://kube-prometheus-stack-prometheus.observability:9090/api/v1/write
Service Discovery
Prometheus automatically discovers targets via:ServiceMonitor
Custom resources that define scrape targets:false, Prometheus scrapes all ServiceMonitors in the cluster, not just those labeled by Helm.
Built-in Targets
The kube-prometheus-stack includes ServiceMonitors for:- Kubernetes components: API server, kubelet, scheduler, controller-manager, etcd
- kube-state-metrics: Cluster state metrics
- node-exporter: Host-level metrics
- Prometheus itself: Self-monitoring
- Alertmanager: Alert metrics
- Grafana: Dashboard metrics
Custom ServiceMonitors
Components define their own ServiceMonitors:- PostgreSQL:
ServiceMonitor-postgresql.yaml - Application services: Defined in microservice-app repo
Integration
Tempo Metrics Generator
Tempo generates RED metrics (Rate, Errors, Duration) from traces and writes them to Prometheus:Grafana Data Source
Prometheus is configured as the default data source in Grafana:Prometheus Operator
The stack includes Prometheus Operator, which manages:- Prometheus - Main time-series database
- Alertmanager - Alert routing and silencing
- ServiceMonitor - Scrape configuration as CRDs
- PodMonitor - Pod-level scrape configuration
- PrometheusRule - Recording and alerting rules
Custom Resource Definitions
The operator installs these CRDs:prometheuses.monitoring.coreos.comalertmanagers.monitoring.coreos.comservicemonitors.monitoring.coreos.compodmonitors.monitoring.coreos.comprometheusrules.monitoring.coreos.comthanosrulers.monitoring.coreos.comscrapeconfigs.monitoring.coreos.comprobes.monitoring.coreos.comalertmanagerconfigs.monitoring.coreos.com
Alerting
PrometheusRule resources define alerts:- Node alerts: CPU, memory, disk usage
- Kubernetes alerts: Pod restarts, deployment issues
- Application alerts: Service-specific thresholds
manifests/kube-prometheus-stack/PrometheusRule-*.yaml.
Query Examples
Container CPU Usage
Pod Memory Usage
HTTP Request Rate
Trace-derived RED Metrics
Performance
- Single replica: Suitable for local development
- In-memory + disk: Recent data cached, older data on PV
- 24h retention: Keeps storage size manageable
Related Components
- Grafana - Visualization
- Alertmanager - Alert routing (part of stack)
- Tempo - Metrics generator integration
- PostgreSQL - ServiceMonitor example