{{- if and .Values.istio.create .Values.metrics.http }}
# rule to dispatch to handler wavefront-handler
apiVersion: {{ include "wfafi.istio.apiVersion" . }}
kind: rule
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" . }}-wavefront-http-rule
  namespace: {{ .Values.istio.namespace }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
spec:
  match: context.protocol == "http"
  actions:
    - handler: {{ include "common.names.fullname" . }}-wavefront-handler.{{ .Values.istio.namespace }}
      instances:
        - {{ include "common.names.fullname" . }}-requestsize.instance.{{ .Release.Namespace }}
        - {{ include "common.names.fullname" . }}-requestcount.instance.{{ .Release.Namespace }}
        - {{ include "common.names.fullname" . }}-requestduration.instance.{{ .Release.Namespace }}
        - {{ include "common.names.fullname" . }}-responsesize.instance.{{ .Release.Namespace }}
{{- end }}
