Skip to content

Commit

Permalink
Antrea Prometheus integration (antrea-io#236)
Browse files Browse the repository at this point in the history
Integrate with Prometheus monitoring solution.
Integration of the Prometheus client into Antrea controller and agent
allows the exposure of various metrics to Prometheus server.
In addition to Antrea's own set of metrics, Prometheus client will also
expose metrics which are defined by various components which are part of
the Antrea ecosystem, e.g golang, Prometheus itself etc.
  • Loading branch information
ksamoray committed Mar 16, 2020
1 parent 8ce25bb commit 2844f1e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
40 changes: 39 additions & 1 deletion build/yamls/antrea-ipsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,21 @@ data:
# Underlying network must be capable of supporting Pod traffic across IP subnet.
# hybrid: noEncap if worker Nodes on same subnet, otherwise encap.
#trafficEncapMode: encap
# Enable metrics exposure via Prometheus. Initializes Prometheus metrics listener
#enablePrometheusMetrics: false
# Enable golang metrics exposure via Prometheus
#enablePrometheusGoMetrics: false
# Enable process metrics exposure via Prometheus.
#enablePrometheusProcessMetrics: false
# Prometheus metrics hostname.
#prometheusHost:
# Prometheus listener port.
#prometheusPort: 9092
antrea-cni.conf: |
{
"cniVersion":"0.3.0",
Expand All @@ -290,7 +305,21 @@ data:
"type": "host-local"
}
}
antrea-controller.conf: ""
antrea-controller.conf: |
# Enable metrics exposure via Prometheus. Initializes Prometheus metrics listener
#enablePrometheusMetrics: false
# Enable golang metrics exposure via Prometheus
#enablePrometheusGoMetrics: false
# Enable process metrics exposure via Prometheus.
#enablePrometheusProcessMetrics: false
# Prometheus metrics hostname.
#prometheusHost:
# Prometheus listener port.
#prometheusPort: 9093
kind: ConfigMap
metadata:
annotations: {}
Expand Down Expand Up @@ -320,6 +349,9 @@ spec:
- port: 443
protocol: TCP
targetPort: 443
- port: 9093
protocol: TCP
targetPort: 9093
selector:
app: antrea
component: antrea-controller
Expand Down Expand Up @@ -371,6 +403,8 @@ spec:
ports:
- containerPort: 443
protocol: TCP
- containerPort: 9093
protocol: TCP
readinessProbe:
failureThreshold: 5
httpGet:
Expand Down Expand Up @@ -510,6 +544,10 @@ spec:
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 5
ports:
- containerPort: 9092
hostPort: 9092
protocol: TCP
securityContext:
privileged: true
volumeMounts:
Expand Down
2 changes: 1 addition & 1 deletion cmd/antrea-controller/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

const (
defaultPrometheusPort = 9093
defaultPrometheusPort = 9093
)

type Options struct {
Expand Down
6 changes: 3 additions & 3 deletions pkg/agent/metrics/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

type OVSStatManager struct {
ofClient openflow.Client
ofClient openflow.Client
OVSBridge string
OVSTableDesc *prometheus.Desc
}
Expand All @@ -38,7 +38,7 @@ func (c *OVSStatManager) OVSGetStatistics() (
ovsFlowsByTable map[string]float64,
) {
ovsFlowsByTable = make(map[string]float64)
flowTableStatus :=c.ofClient.GetFlowTableStatus()
flowTableStatus := c.ofClient.GetFlowTableStatus()
for _, tableStatus := range flowTableStatus {
ovsFlowsByTable[strconv.Itoa(int(tableStatus.ID))] = float64(tableStatus.FlowCount)
}
Expand Down Expand Up @@ -84,7 +84,7 @@ func StartListener(
ofClient openflow.Client) {
hostname, err := os.Hostname()
if err != nil {
klog.Error("Failed to retrieve agent node name, %v", err)
klog.Errorf("Failed to retrieve agent node name, %v", err)
}
klog.Info("Binding antrea_local_pod_count")
if err := prometheus.Register(prometheus.NewGaugeFunc(
Expand Down

0 comments on commit 2844f1e

Please sign in to comment.