<jupyter_start><jupyter_text>Basic Examples with Different Protocols Prerequisites * A kubernetes cluster with kubectl configured * curl * grpcurl * pygmentize  Setup Seldon CoreUse the setup notebook to [Setup Cluster](https://docs.seldon.io/projects/seldon-core/en/latest/examples/seldon_core_setup.html) to setup Seldon Core with an ingress - either Ambassador or Istio.Then port-forward to that ingress on localhost:8003 in a separate terminal either with: * Ambassador: `kubectl port-forward $(kubectl get pods -n seldon -l app.kubernetes.io/name=ambassador -o jsonpath='{.items[0].metadata.name}') -n seldon 8003:8080` * Istio: `kubectl port-forward $(kubectl get pods -l istio=ingressgateway -n istio-system -o jsonpath='{.items[0].metadata.name}') -n istio-system 8003:80`<jupyter_code>!kubectl create namespace seldon
!kubectl config set-context $(kubectl config current-context) --namespace=seldon
import json
import time
%%writefile get-metrics.sh

IP=$(kubectl get pods -l seldon-deployment-id=seldon-model -n seldon -o jsonpath='{.items[0].status.podIP}')
kubectl run --quiet=true -it --rm curlmetrics --image=radial/busyboxplus:curl --restart=Never -- \
    curl -s ${IP}:6000/prometheus | grep mycounter_total<jupyter_output>Overwriting get-metrics.sh<jupyter_text>Custom Metrics<jupyter_code>%%writefile model.yaml
apiVersion: machinelearning.seldon.io/v1
kind: SeldonDeployment
metadata:
  name: seldon-model
spec:
  predictors:
  - componentSpecs:
    - spec:
        containers:
        - image: seldonio/model-with-metrics:0.2
          name: classifier
    graph:
      children: []
      name: classifier
      type: MODEL
    name: example
    replicas: 1
!kubectl apply -f model.yaml
!kubectl rollout status deploy/$(kubectl get deploy -l seldon-deployment-id=seldon-model \
                                 -o jsonpath='{.items[0].metadata.name}')<jupyter_output>Waiting for deployment "seldon-model-example-0-classifier" rollout to finish: 0 of 1 updated replicas are available...
deployment "seldon-model-example-0-classifier" successfully rolled out<jupyter_text>Send REST request<jupyter_code>responseRaw = !curl -s -H "Content-Type: application/json" -d '{"data": {"ndarray":[[1.0, 2.0, 5.0]]}}' http://localhost:8003/seldon/seldon/seldon-model/api/v1.0/predictions
response = json.loads(responseRaw[0])
print(response)
assert len(response["meta"]["metrics"]) == 3
responseRaw = ! bash get-metrics.sh
assert len(responseRaw) == 3<jupyter_output><empty_output><jupyter_text>Send gRPC request<jupyter_code>responseRaw=!cd ../../../executor/proto && grpcurl -d '{"data":{"ndarray":[[1.0,2.0,5.0]]}}' \
         -rpc-header seldon:seldon-model -rpc-header namespace:seldon \
         -plaintext \
         -proto ./prediction.proto  0.0.0.0:8003 seldon.protos.Seldon/Predict
response = json.loads("".join(responseRaw))
print(response)
assert len(response["meta"]["metrics"]) == 3
responseRaw = ! bash get-metrics.sh
assert len(responseRaw) == 6
!kubectl delete -f model.yaml<jupyter_output>seldondeployment.machinelearning.seldon.io "seldon-model" deleted
{'fraction_non_alphanumeric': 0.13372281726712107, 'fraction_numerical': 0.02109704641350211, 'mean_word_length': 4.464539007092198, 'pattern_counts': {'":': 4, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '337249', 'license': 'Apache-2.0', 'n_tokens_mistral': 1100, 'n_tokens_neox': 1034, 'n_words': 234, 'path': 'examples/models/custom_metrics/customMetrics.ipynb', 'repo_name': 'marianobilli/seldon-core', 'size': '3081'}