Project: Weave Net (Runtime / Cloud Native Network)
File: metrics.md

title: Monitoring Weave Net with Prometheus menu_order: 90 search_type: Documentation Two endpoints are exposed: one for the Weave Net router, and, when deployed as a , one for the [network policy controller](/site/kubernetes/kube-addon.md#npc). `weave_connections` - Number of peer-to-peer connections. `weaveconnectionterminations_total` - Number of peer-to-peer connections terminated. `weave_ips` - Number of IP addresses. `weavemaxips` - Size of IP address space used by allocator. `weavednsentries` - Number of DNS entries. `weave_flows` - Number of FastDP flows. `weaveipamunreachable_count` - Number of unreachable peers that own IPAM addresses. `weaveipamunreachable_percentage` - Percentage of all IP addresses owned by unreachable peers. `weaveipampending_allocates` - Number of pending allocates. `weaveipampending_claims` - Number of pending claims. The following metric is exposed: `weavenpcblockedconnections_total` - Connection attempts blocked by policy controller. When installed as a Kubernetes Addon, the router listens for metrics requests on 0.0.0.0:6782 and the Network Policy Controller listens on 0.0.0.0:6781. No other requests are served on these endpoints. Note: If your Kubernetes hosts are exposed to the public internet then these metrics endpoints will also be exposed. When started via `weave launch`, by default weave listens on its local interface to serve metrics and other read-only status requests. To publish your metrics throughout your cluster, you can set `WEAVESTATUSADDR`: `WEAVESTATUSADDR=X.X.X.X:PORT` Set it to an empty string to disable. You can also pass the parameter `--metrics-addr=X.X.X.X:PORT` to `weave launch` to specify an address to listen for metrics only. Weave Net monitoring can be setup in Kubernetes using the kube-prometheus for Weave Net. You can read about the example document . Let's setup weave monitoring using . Follow this ``` go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb ``` Follow this ``` go get github.com/brancz/gojsontoyaml ``` ``` jb update ``` Note: Some alert configurations are environment specific and may require modifications of alert thresholds. ``` cat << EOF > weave-net.jsonnet local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + (import 'kube-prometheus/kube-prometheus-weave-net.libsonnet') + { _config+:: { namespace: 'monitoring', }, prometheusAlerts+:: { groups: std.map( function(group) if group.name == 'weave-net' then group { rules: std.map(function(rule) if rule.alert == "WeaveNetFastDPFlowsLow" then rule { expr: "sum(weave_flows) < 20000" } else if rule.alert == "WeaveNetIPAMUnreachable" then rule { expr: "weaveipamunreachable_percentage > 25" } else rule , group.rules ) } else group, super.groups ), }, }; { ['00namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } + { ['0prometheus-operator-' + name]: kp.prometheusOperator[name] for name in std.objectFields(kp.prometheusOperator) } + { ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } + { ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } + { ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } + { ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } + { ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } EOF ``` ``` jsonnet -J vendor -m manifests weave-net.jsonnet | xargs -I{} sh -c 'cat $1 | gojsontoyaml > $1.yaml; rm -f $1' -- {} ``` Applying the created manifests will install the following components in your Kubernetes cluster: "monitoring" Operator to manage prometheus Dashboards on top of Prometheus metrics. ServiceMonitor brings the weave net metrics to prometheus. Weave Net Service which the ServiceMonitor scrapes. ``` cd manifests ls *.yaml | grep -e ^prometheus -e ^node -e ^grafana -e ^kube | xargs -I {} kubectl create -f {} -n monitoring kubectl create -f prometheus-serviceWeaveNet.yaml -n kube-system kubectl create -f prometheus-serviceMonitorWeaveNet.yaml -n monitoring ``` Note: If you want to make changes to the created yamls, please modify the weave-net.jsonnet and recreate the manifests before applying.