# istio_telemetry-selector.yaml
apiVersion: v1
kind: Pod
metadata:
  labels:
    app: productpage
  name: productpage
  namespace: default
---
apiVersion: v1
kind: Pod
metadata:
  labels:
    app: productpage
  name: productpage-other
  namespace: other
---
apiVersion: v1
kind: Pod
metadata:
  labels:
    app: reviews
  name: reviews
  namespace: default
---
apiVersion: v1
kind: Pod
metadata:
  labels:
    app: ratings-app
    myapp: ratings-myapp
  name: ratings
  namespace: default
---
apiVersion: telemetry.istio.io/v1
kind: Telemetry
metadata:
  name: maps-correctly-no-conflicts
  namespace: default
spec:
  selector:
    matchLabels:
      app: productpage # Maps to an existing workload without conflicts in the same ns, no error
  metrics:
    - providers:
        - name: prometheus
      overrides:
        - match:
            metric: ALL_METRICS
          disabled: false
---
apiVersion: telemetry.istio.io/v1
kind: Telemetry
metadata:
  name: maps-to-nonexistent
  namespace: default
spec:
  selector:
    matchLabels:
      app: bogus # This doesn't exist, and should generate an error
  metrics:
    - providers:
        - name: prometheus
      overrides:
        - match:
            metric: ALL_METRICS
          disabled: false
---
apiVersion: telemetry.istio.io/v1
kind: Telemetry
metadata:
  name: maps-to-different-ns
  namespace: other
spec:
  selector:
    matchLabels:
      app: reviews # This doesn't exist in the current namespace, and should generate an error
  metrics:
    - providers:
        - name: prometheus
      overrides:
        - match:
            metric: ALL_METRICS
          disabled: false
---
apiVersion: telemetry.istio.io/v1
kind: Telemetry
metadata:
  name: dupe-1
  namespace: default
spec:
  selector:
    matchLabels:
      app: reviews # Multiple telemetries have the same selector, should generate errors for both
  metrics:
    - providers:
        - name: prometheus
      overrides:
        - match:
            metric: ALL_METRICS
          disabled: false
---
apiVersion: telemetry.istio.io/v1
kind: Telemetry
metadata:
  name: dupe-2
  namespace: default
spec:
  selector:
    matchLabels:
      app: reviews # Multiple telemetries have the same selector, should generate errors for both
  metrics:
    - providers:
        - name: prometheus
      overrides:
        - match:
            metric: ALL_METRICS
          disabled: false
---
apiVersion: telemetry.istio.io/v1
kind: Telemetry
metadata:
  name: overlap-1
  namespace: default
spec:
  selector:
    matchLabels:
      app: ratings-app # Multiple telemetries select overlapping workloads, should generate errors for both
  metrics:
    - providers:
        - name: prometheus
      overrides:
        - match:
            metric: ALL_METRICS
          disabled: false
---
apiVersion: telemetry.istio.io/v1
kind: Telemetry
metadata:
  name: overlap-2
  namespace: default
spec:
  selector:
    matchLabels:
      myapp: ratings-myapp # Multiple telemetries select overlapping workloads, should generate errors for both
  metrics:
    - providers:
        - name: prometheus
      overrides:
        - match:
            metric: ALL_METRICS
          disabled: false