Metrics and Service Mesh
TOC
Using metrics
Monitoring plugin such as Prometheus or VictoriaMetrics should be installed to provide metrics for the Alauda Service Mesh v2 Operator and Istio control plane.
When you have added your application to the mesh, you can monitor the in-cluster health and performance of your applications running on Alauda Container Platform with metrics and customized alerts for CPU and memory usage, network connectivity, and other resource usage.
Configuring Monitoring with Service Mesh
You can integrate Alauda Service Mesh with user-workload monitoring to enable observability in your service mesh. User-workload monitoring provides access to essential built-in tools and is required to run Kiali, the dedicated console for Istio.
Prerequisites
- Alauda Service Mesh is installed.
Procedure
Create a YAML file named servicemonitor.yaml
to monitor the Istio control plane:
Example ServiceMonitor
object
servicemonitor.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: istiod-monitor
namespace: istio-system
spec:
targetLabels:
- app
selector:
matchLabels:
istio: pilot
endpoints:
- port: http-monitoring
interval: 60s
Apply the YAML file by running the following command:
kubectl apply -f servicemonitor.yaml
Create a YAML file named podmonitor.yaml
to collect metrics from the Istio proxies (workloads):
Example PodMonitor object
podmonitor.yaml
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: istio-proxies-monitor
namespace: istio-system
labels:
# monitoring=pods & prometheus=kube-prometheus is required in ACP prometheus.
monitoring: pods
prometheus: kube-prometheus
spec:
selector:
matchExpressions:
- key: istio-prometheus-ignore
operator: DoesNotExist
namespaceSelector:
any: true
jobLabel: envoy-stats
podMetricsEndpoints:
- path: /stats/prometheus
interval: 60s
relabelings:
- action: keep
sourceLabels: [ __meta_kubernetes_pod_container_name ]
regex: "istio-proxy"
- action: keep
sourceLabels: [__meta_kubernetes_pod_annotationpresent_prometheus_io_scrape]
- sourceLabels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
action: replace
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: "$1:$2"
targetLabel: __address__
- sourceLabels: [__meta_kubernetes_pod_label_app_kubernetes_io_name, __meta_kubernetes_pod_label_app]
separator: ";"
targetLabel: "app"
action: replace
regex: "(.+);.*|.*;(.+)"
replacement: "${1}${2}"
- sourceLabels: [__meta_kubernetes_pod_label_app_kubernetes_io_version, __meta_kubernetes_pod_label_version]
separator: ";"
targetLabel: "version"
action: replace
regex: "(.+);.*|.*;(.+)"
replacement: "${1}${2}"
- sourceLabels: [__meta_kubernetes_namespace]
action: replace
targetLabel: namespace
- action: drop
regex: "true"
sourceLabels: [__meta_kubernetes_pod_container_init]
- Specifies that the
PodMonitor
object must be applied in all mesh namespaces, including the Istio control plane namespace, because Alauda Container Platform monitoring ignores the namespaceSelector
spec in ServiceMonitor
and PodMonitor
objects.
Apply the YAML file by running the following command:
kubectl apply -f podmonitor.yaml
Create a YAML file named asm-telemetry.yaml
to configure prometheus metrics to istio proxies (workloads):
Example Istio Telemetry resource
asm-telemetry.yaml
apiVersion: telemetry.istio.io/v1
kind: Telemetry
metadata:
name: asm-default
namespace: istio-system
spec:
metrics:
- providers:
- name: prometheus
overrides:
- tagOverrides:
mesh_id:
value: node.metadata['MESH_ID']
- Add
mesh_id
label to prometheus metrics.
Apply the YAML file by running the following command:
kubectl apply -f asm-telemetry.yaml