{{- $ctx := dict "helm" . "style" "plain" "kindOverride" "vmauth" }}
{{- $fullname := include "vm.plain.fullname" $ctx }}
{{- $ns := include "vm.namespace" $ctx }}
Write API:

The Victoria Metrics Auth can be accessed via port {{ .Values.service.servicePort | default (include "vm.port.from.flag" (dict "flag" (include "vm.addr.primary" .Values.http) "default" "8427")) }} on the following DNS name from within your cluster:
{{ $fullname }}

Get the Victoria Metrics Auth service URL by running these commands in the same shell:
{{- if contains "NodePort" .Values.service.type }}
  export NODE_PORT=$(kubectl get --namespace {{ $ns }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ $fullname }})
  export NODE_IP=$(kubectl get nodes --namespace {{ $ns }} -o jsonpath="{.items[0].status.addresses[0].address}")
  echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        You can watch the status of by running 'kubectl get svc --namespace {{ $ns }} -w {{ $fullname }}'

  export SERVICE_IP=$(kubectl get svc --namespace {{ $ns }} {{ $fullname }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
  echo http://$SERVICE_IP:{{ .Values.service.servicePort | default (include "vm.port.from.flag" (dict "flag" (include "vm.addr.primary" .Values.http) "default" "8427")) }}
{{- else if contains "ClusterIP"  .Values.service.type }}
  export POD_NAME=$(kubectl get pods --namespace {{ $ns }} -l "{{ include "vm.keyValue" (fromYaml (include "vm.selectorLabels" $ctx)) }}" -o jsonpath="{.items[0].metadata.name}")
  kubectl --namespace {{ $ns }} port-forward $POD_NAME {{ .Values.service.servicePort | default (include "vm.port.from.flag" (dict "flag" (include "vm.addr.primary" .Values.http) "default" "8427")) }}
{{- end }}

You need to update your prometheus configuration file and add next lines into it:

prometheus.yml
```yaml
remote_write:
  - url: "http://<insert-service>/insert/0/prometheus/"
```

for e.g. inside the kubernetes cluster:
```yaml
remote_write:
  - url: {{ include "vm.url" $ctx }}/insert/0/prometheus/
```

Read API:

You need to update specify select service URL in your Grafana:
 NOTE: you need to use Prometheus Data Source

Input for URL field in Grafana

```
http://<select-service>:{{ .Values.service.servicePort | default (include "vm.port.from.flag" (dict "flag" (include "vm.addr.primary" .Values.http) "default" "8427")) }}/select/0/prometheus/
```

for e.g. inside the kubernetes cluster:
```
{{ include "vm.url" $ctx }}/select/0/prometheus/"
```
