Skip to content

Commit

Permalink
fix metrics for k8s setup (#2473)
Browse files Browse the repository at this point in the history
* fix metrics for k8s setup

Signed-off-by: jagadeesh <[email protected]>

* fix lint error

---------

Signed-off-by: jagadeesh <[email protected]>
Co-authored-by: Geeta Chauhan <[email protected]>
  • Loading branch information
Jagadeesh J and chauhang authored Aug 24, 2023
1 parent 921f423 commit b37296d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ repos:
- id: check-json
- id: check-toml
- id: check-yaml
args: [--allow-multiple-documents, --unsafe]
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
Expand Down
2 changes: 2 additions & 0 deletions kubernetes/EKS/config.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
inference_address=http://0.0.0.0:8080
management_address=http://0.0.0.0:8081
metrics_address=http://0.0.0.0:8082
enable_metrics_api=true
metrics_mode=prometheus
NUM_WORKERS=1
number_of_gpu=1
number_of_netty_threads=32
Expand Down
2 changes: 2 additions & 0 deletions kubernetes/GKE/config.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
inference_address=http://0.0.0.0:8080
management_address=http://0.0.0.0:8081
metrics_address=http://0.0.0.0:8082
enable_metrics_api=true
metrics_mode=prometheus
NUM_WORKERS=1
number_of_gpu=1
number_of_netty_threads=32
Expand Down
5 changes: 3 additions & 2 deletions kubernetes/Helm/templates/torchserve.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ metadata:
labels:
app: torchserve
annotations:
prometheus.io/scrape: 'true'
prometheus.io/scrape: "true"
prometheus.io/path: /metrics
prometheus.io/port: '8082'
spec:
ports:
- name: preds
port: {{ .Values.torchserve.inference_port }}
targetPort: ts
targetPort: ts
- name: mdl
port: {{ .Values.torchserve.management_port }}
targetPort: ts-management
Expand Down
29 changes: 18 additions & 11 deletions kubernetes/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Torchserve on Kubernetes

## Overview

This page demonstrates a Torchserve deployment in Kubernetes using Helm Charts. It uses the DockerHub Torchserve Image for the pods and a PersistentVolume for storing config / model files.
Expand Down Expand Up @@ -66,7 +66,7 @@ persitant_volume:
size: 1Gi
```
To install Torchserve run ```helm install ts .```
To install Torchserve run ```helm install ts .```

```bash
ubuntu@ip-172-31-50-36:~/serve/kubernetes/Helm$ helm install ts .
Expand Down Expand Up @@ -207,12 +207,6 @@ helm repo add grafana https://grafana.github.io/helm-charts
helm install grafana grafana/grafana
```

Get admin user password by running:

```bash
kubectl get secret --namespace default grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
```

## Add prometheus as data source in grafana

```bash
Expand All @@ -233,8 +227,6 @@ kubectl get pod prometheus-server-f8677599b-xmjbt -o jsonpath='{.status.podIPs[0
192.168.52.141
```

![Add data source](images/grafana_datasource.png)

## Expose grafana with loadbalancer

```bash
Expand All @@ -243,9 +235,24 @@ kubectl patch service grafana -p '{"spec": {"type": "LoadBalancer"}}'
kubectl get svc grafana -o jsonpath='{.status.loadBalancer.ingress[0].hostname}'
```

Get admin user password by running:

```bash
kubectl get secret --namespace default grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
```

## Login to grafana

`<http://your.grafana.loadbalancer.address:3000>`
<b>Username:</b> admin
<b>Password:</b> <--The password got from previous step-->

Open Grafana in browser with the url - `<http://your.grafana.loadbalancer.address:3000>`

Add Prometheus data source

![Add data source](images/grafana_datasource.png)

The TS metrics will be available in Prometheus for Grafana dashboards.

## Logging

Expand Down

0 comments on commit b37296d

Please sign in to comment.