{{- if and .Values.istio.create .Values.metrics.tcp }}
# tcpsentbytes instance for template metric
apiVersion: {{ include "wfafi.istio.apiVersion" . }}
kind: instance
metadata:
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    app.kubernetes.io/component: wavefront-adapter-for-istio
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  name: {{ include "common.names.fullname" . }}-tcpsentbytes
  namespace: {{ .Release.Namespace }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
spec:
  template: {{ include "common.names.fullname" . }}-metric
  params:
    value: connection.sent.bytes | 0
    dimensions:
      reporter: conditional((context.reporter.kind | "inbound") == "outbound", "client", "server")
      source_service: source.workload.name | "unknown"
      source_service_namespace: source.workload.namespace | "unknown"
      source_version: source.labels["version"] | "unknown"
      destination_service: destination.service.name | "unknown"
      destination_service_namespace: destination.service.namespace | "unknown"
      destination_version: destination.labels["version"] | "unknown"
      response_code: response.code | 200
    monitored_resource_type: '"UNSPECIFIED"'
---
# tcpreceivedbytes instance for template metric
apiVersion: {{ include "wfafi.istio.apiVersion" . }}
kind: instance
metadata:
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    app.kubernetes.io/component: wavefront-adapter-for-istio
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  name: {{ include "common.names.fullname" . }}-tcpreceivedbytes
  namespace: {{ .Release.Namespace }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
spec:
  template: {{ include "common.names.fullname" . }}-metric
  params:
    value: connection.received.bytes | 0
    dimensions:
      reporter: conditional((context.reporter.kind | "inbound") == "outbound", "client", "server")
      source_service: source.workload.name | "unknown"
      source_service_namespace: source.workload.namespace | "unknown"
      source_version: source.labels["version"] | "unknown"
      destination_service: destination.service.name | "unknown"
      destination_service_namespace: destination.service.namespace | "unknown"
      destination_version: destination.labels["version"] | "unknown"
      response_code: response.code | 200
    monitored_resource_type: '"UNSPECIFIED"'
---
# tcpconnectionsopened instance for template metric
apiVersion: {{ include "wfafi.istio.apiVersion" . }}
kind: instance
metadata:
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    app.kubernetes.io/component: wavefront-adapter-for-istio
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  name: {{ include "common.names.fullname" . }}-tcpconnectionsopened
  namespace: {{ .Release.Namespace }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
spec:
  template: {{ include "common.names.fullname" . }}-metric
  params:
    value: 1
    dimensions:
      reporter: conditional((context.reporter.kind | "inbound") == "outbound", "client", "server")
      source_service: source.workload.name | "unknown"
      source_service_namespace: source.workload.namespace | "unknown"
      source_version: source.labels["version"] | "unknown"
      destination_service: destination.service.name | "unknown"
      destination_service_namespace: destination.service.namespace | "unknown"
      destination_version: destination.labels["version"] | "unknown"
      response_code: response.code | 200
    monitored_resource_type: '"UNSPECIFIED"'
---
# tcpconnectionsclosed instance for template metric
apiVersion: {{ include "wfafi.istio.apiVersion" . }}
kind: instance
metadata:
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    app.kubernetes.io/component: wavefront-adapter-for-istio
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  name: {{ include "common.names.fullname" . }}-tcpconnectionsclosed
  namespace: {{ .Release.Namespace }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
spec:
  template: {{ include "common.names.fullname" . }}-metric
  params:
    value: 1
    dimensions:
      reporter: conditional((context.reporter.kind | "inbound") == "outbound", "client", "server")
      source_service: source.workload.name | "unknown"
      source_service_namespace: source.workload.namespace | "unknown"
      source_version: source.labels["version"] | "unknown"
      destination_service: destination.service.name | "unknown"
      destination_service_namespace: destination.service.namespace | "unknown"
      destination_version: destination.labels["version"] | "unknown"
      response_code: response.code | 200
    monitored_resource_type: '"UNSPECIFIED"'
{{- end }}
