Metrics
Every kloudease cluster collects the basic metrics of your workloads automatically: CPU, memory, restarts and pod status per namespace. Your application's own metrics are collected once you add a ServiceMonitor or PodMonitor for it. You query both in Perses with the prometheus data source.
Automatic integration with workload-helm
Our Helm Chart workload-helm contains auto configs for metrics and observability.
How to collect metrics#
If you are not using our workload-helm Helm Chart, deploy a ServiceMonitor or PodMonitor with your application.
A monitor may only select targets in its own namespace. It may not set honorLabels: true or change the job or namespace labels, so the cluster refuses relabelings that write, map or drop them.
We use Prometheus Operator and the ServiceMonitor and PodMonitor resources to collect metrics.
Should I use ServiceMonitor or PodMonitor?#
ServiceMonitoruses a KubernetesServiceresource to find the metrics endpointPodMonitoruses KubernetesPodand labels to find the metrics endpoint
A ServiceMonitor makes sense if your application has an Service exposed already.
A PodMonitor makes sense if the application doesn't expose a Service.
ServiceMonitor#
Below is a minimal example, which is often times enough already. For all options, please take a look at the API Reference documentation.
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: my-app
namespace: my-app
spec:
endpoints:
- interval: 60s
path: /metrics
port: http
selector:
matchLabels:
app.kubernetes.io/name: my-app
PodMonitor#
Below is a minimal example, which is often times enough already. For all options, please take a look at the API Reference documentation.
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: my-app
namespace: my-app
spec:
podMetricsEndpoints:
- interval: 60s
port: metrics
selector:
matchLabels:
app.kubernetes.io/name: my-app