From 2ea26ebaaba08718bf6b3c5311cef62dc3df3253 Mon Sep 17 00:00:00 2001 From: Lun-Kai Hsu Date: Thu, 15 Nov 2018 15:38:33 -0800 Subject: [PATCH] Add prometheus annotation to tf serving service (#1958) --- kubeflow/tf-serving/prototypes/tf-serving-service.jsonnet | 1 + kubeflow/tf-serving/tf-serving-service-template.libsonnet | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/kubeflow/tf-serving/prototypes/tf-serving-service.jsonnet b/kubeflow/tf-serving/prototypes/tf-serving-service.jsonnet index f70ba6ecd94..186825557d0 100644 --- a/kubeflow/tf-serving/prototypes/tf-serving-service.jsonnet +++ b/kubeflow/tf-serving/prototypes/tf-serving-service.jsonnet @@ -7,6 +7,7 @@ // @optionalParam modelName string null The model name // @optionalParam trafficRule string v1:100 The traffic rule, in the format of version:percentage,version:percentage,.. // @optionalParam injectIstio string false Whether to inject istio sidecar; should be true or false. +// @optionalParam enablePrometheus string true Whether to enable prometheus endpoint (requires TF 1.11) local k = import "k.libsonnet"; local tfservingService = import "kubeflow/tf-serving/tf-serving-service-template.libsonnet"; diff --git a/kubeflow/tf-serving/tf-serving-service-template.libsonnet b/kubeflow/tf-serving/tf-serving-service-template.libsonnet index 3df92b5c2ea..387fbdeee57 100644 --- a/kubeflow/tf-serving/tf-serving-service-template.libsonnet +++ b/kubeflow/tf-serving/tf-serving-service-template.libsonnet @@ -40,7 +40,11 @@ "method: GET", "service: " + name + "." + namespace + ":8500", ]), - }, //annotations + } + if util.toBool(params.enablePrometheus) then { + "prometheus.io/scrape": "true", + "prometheus.io/path": "/monitoring/prometheus/metrics", + "prometheus.io/port": "8500", + } else {}, //annotations }, spec: { ports: [