Monitoring & Observability
The PipeOps Kubernetes Agent includes a comprehensive monitoring and observability stack built on industry-standard open-source tools. This guide covers setup, configuration, and usage of the monitoring components.
Overview
The agent's monitoring stack provides complete visibility into your Kubernetes cluster and workloads through:
- Prometheus — Metrics collection, storage, and alerting
- Grafana — Visualization, dashboards, and analysis
- Loki — Log aggregation and querying
- OpenCost — Kubernetes cost monitoring and optimization
- Node Exporter — Node-level system metrics
- kube-state-metrics — Kubernetes object metrics
Architecture
┌─────────────────────────────────────────────────────┐
│ Grafana Dashboard │
│ (Visualization & Analysis) │
└─────────────────────────────────────────────────────┘
│
┌───────────────┼───────────────┐
│ │ │
┌─────────▼────────┐ ┌───▼────────┐ ┌────▼──────┐
│ Prometheus │ │ Loki │ │ OpenCost │
│ (Metrics DB) │ │ (Logs DB) │ │ (Costs) │
└─────────┬────────┘ └───┬────────┘ └────┬──────┘
│ │ │
┌─────┴──────┬───────┴──────┬────────┴─────┐
│ │ │ │
┌───▼──────┐ ┌──▼────────┐ ┌───▼────────┐ ┌───▼─────┐
│ K8s API │ │ Nodes │ │ Pods │ │ Kubelet │
└──────────┘ └───────────┘ └────────────┘ └─────────┘
Installation
Enable Monitoring During Initial Setup
Intelligent Installer:
export PIPEOPS_TOKEN="your-api-token"
curl -fsSL https://get.pipeops.dev/k8-install.sh | bash
The monitoring stack (Prometheus, Grafana, Loki, OpenCost) is installed by default.
Helm Installation:
helm install pipeops-agent oci://ghcr.io/pipeopshq/pipeops-agent \
--set agent.pipeops.token="your-api-token" \
--set monitoring.enabled=true \
--set monitoring.prometheus.enabled=true \
--set monitoring.grafana.enabled=true \
--set monitoring.loki.enabled=true \
--namespace pipeops-system \
--create-namespace
Add Monitoring to Existing Installation
If you initially installed without monitoring:
helm upgrade pipeops-agent oci://ghcr.io/pipeopshq/pipeops-agent \
--set monitoring.enabled=true \
--namespace pipeops-system \
--reuse-values
Prometheus Configuration
Prometheus collects and stores time-series metrics from your cluster.
Basic Setup
monitoring:
prometheus:
enabled: true
port: 9090
# Metric retention period
retention: "15d"
# Storage configuration
persistence:
enabled: true
storageClass: "standard"
size: "10Gi"
# Scrape interval
scrape_interval: "30s"
# Resource limits
resources:
requests:
cpu: "250m"
memory: "512Mi"
limits:
cpu: "500m"
memory: "1Gi"
Custom Scrape Configurations
Add custom scrape targets:
monitoring:
prometheus:
additionalScrapeConfigs:
- job_name: 'custom-app'
kubernetes_sd_configs:
- role: pod
namespaces:
names:
- my-app-namespace
relabel_configs:
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
action: keep
regex: true
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
action: replace
target_label: __metrics_path__
regex: (.+)
- source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
action: replace
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: $1:$2
target_label: __address__
Accessing Prometheus
Port Forward (Local Access):
kubectl port-forward svc/prometheus-server 9090:9090 -n pipeops-monitoring
Then open http://localhost:9090
Ingress (Production):
monitoring:
prometheus:
ingress:
enabled: true
className: "nginx"
annotations:
cert-manager.io/cluster-issuer: "letsencrypt-prod"
hosts:
- host: prometheus.example.com
paths:
- path: /
pathType: Prefix
tls:
- secretName: prometheus-tls
hosts:
- prometheus.example.com
Common Prometheus Queries
CPU Usage by Pod:
sum(rate(container_cpu_usage_seconds_total{namespace="default"}[5m])) by (pod)
Memory Usage by Namespace:
sum(container_memory_working_set_bytes{namespace!=""}) by (namespace)
Pod Restart Count:
kube_pod_container_status_restarts_total
Node CPU Usage:
100 - (avg by (instance) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)
Grafana Configuration
Grafana provides powerful visualization and dashboarding capabilities.
Basic Setup
monitoring:
grafana:
enabled: true
port: 3000
# Admin credentials
adminUser: "admin"
adminPassword: "changeme" # Change in production!
# Persistence for dashboards
persistence:
enabled: true
storageClass: "standard"
size: "5Gi"
# Resource limits
resources:
requests:
cpu: "100m"
memory: "128Mi"
limits:
cpu: "200m"
memory: "256Mi"
Accessing Grafana
Port Forward (Local Access):
kubectl port-forward svc/grafana 3000:3000 -n pipeops-monitoring
Then open http://localhost:3000
Default credentials:
- Username:
admin - Password:
pipeops(or as configured)
Ingress (Production):
monitoring:
grafana:
ingress:
enabled: true
className: "nginx"
annotations:
cert-manager.io/cluster-issuer: "letsencrypt-prod"
nginx.ingress.kubernetes.io/rewrite-target: /
hosts:
- host: grafana.example.com
paths:
- path: /
pathType: Prefix
tls:
- secretName: grafana-tls
hosts:
- grafana.example.com
Pre-configured Dashboards
The agent includes several pre-configured Grafana dashboards:
Kubernetes Cluster Overview
- ID:
kubernetes-cluster-overview - Metrics: Node status, pod counts, resource usage
- Use Case: High-level cluster health monitoring
Node Metrics
- ID:
node-exporter-full - Metrics: CPU, memory, disk, network per node
- Use Case: Node-level performance analysis
Pod Resources
- ID:
kubernetes-pod-resources - Metrics: CPU, memory, network per pod
- Use Case: Application resource monitoring