Skip to content

Commit

Permalink
Use separate port for serving activator metrics (knative#2043)
Browse files Browse the repository at this point in the history
Activator will continue serving data on port 8080, but will now serve
metrics on port 9090.

Fixes knative#2043
  • Loading branch information
tanzeeb committed Sep 24, 2018
1 parent 2002f7c commit b190088
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
11 changes: 7 additions & 4 deletions cmd/activator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,11 @@ func main() {
}

// Start the endpoint for Prometheus scraping
mux := http.NewServeMux()
mux.HandleFunc("/", ah.ServeHTTP)
mux.Handle("/metrics", promExporter)
h2c.ListenAndServe(":8080", mux)
go func() {
mux := http.NewServeMux()
mux.Handle("/metrics", promExporter)
http.ListenAndServe(":9090", mux)
}()

h2c.ListenAndServe(":8080", ah)
}
4 changes: 4 additions & 0 deletions config/400-activator-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ spec:
protocol: TCP
port: 80
targetPort: 8080
- name: metrics
protocol: TCP
port: 9090
targetPort: 9090
type: NodePort
2 changes: 2 additions & 0 deletions config/activator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ spec:
ports:
- name: activator-port
containerPort: 8080
- name: metrics-port
containerPort: 9090
args:
# Disable glog writing into stderr. Our code doesn't use glog
# and seeing k8s logs in addition to ours is not useful.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ data:
# Scrape only the the targets matching the following metadata
- source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_pod_label_app, __meta_kubernetes_pod_container_port_name]
action: keep
regex: knative-serving;activator;activator-port
regex: knative-serving;activator;metrics-port
# Rename metadata labels to be reader friendly
- source_labels: [__meta_kubernetes_namespace]
action: replace
Expand Down

0 comments on commit b190088

Please sign in to comment.