dedup.minScrapeInterval: 1ms configures de-duplication for the cluster that de-duplicates data points in the same time series if they fall within the same discrete 1ms bucket. The earliest data point will be kept. In the case of equal timestamps, an arbitrary data point will be kept.
replicationFactor: 2 Replication factor for the ingested data, i.e. how many copies should be made among distinct -storageNode instances. If the replication factor is greater than one, the deduplication must be enabled on the remote storage side.
podAnnotations: prometheus.io/scrape: "true" enables the scraping of metrics from the vmselect, vminsert and vmstorage pods.
podAnnotations:prometheus.io/port: "some_port" enables the scraping of metrics from the vmselect, vminsert and vmstorage pods from corresponding ports.
replicaCount: 3 creates three replicas of vmselect, vminsert and vmstorage.
The expected result of the command execution is the following:
NAME: vmcluster
LAST DEPLOYED: Thu Jul 29 13:33:51 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Write API:
The VictoriaMetrics write api can be accessed via port 8480 via the following DNS name from within your cluster:
vmcluster-victoria-metrics-cluster-vminsert.default.svc.cluster.local
Get the VictoriaMetrics insert service URL by running these commands in the same shell:
export POD_NAME=$(kubectl get pods --namespace default -l "app=vminsert" -o jsonpath="{.items[0].metadata.name}")
kubectl --namespace default port-forward $POD_NAME 8480
You need to update your Prometheus configuration file and add the following lines to it:
prometheus.yml
remote_write:
- url: "http://<insert-service>/insert/0/prometheus/"
for example - inside the Kubernetes cluster:
remote_write:
- url: "http://vmcluster-victoria-metrics-cluster-vminsert.default.svc.cluster.local:8480/insert/0/prometheus/"
Read API:
The VictoriaMetrics read api can be accessed via port 8481 with the following DNS name from within your cluster:
vmcluster-victoria-metrics-cluster-vmselect.default.svc.cluster.local
Get the VictoriaMetrics select service URL by running these commands in the same shell:
export POD_NAME=$(kubectl get pods --namespace default -l "app=vmselect" -o jsonpath="{.items[0].metadata.name}")
kubectl --namespace default port-forward $POD_NAME 8481
You need to specify select service URL into your Grafana:
NOTE: you need to use the Prometheus Data Source
Input this URL field into Grafana
http://<select-service>/select/0/prometheus/
for example - inside the Kubernetes cluster:
http://vmcluster-victoria-metrics-cluster-vmselect.default.svc.cluster.local:8481/select/0/prometheus/"
Verify that the VictoriaMetrics cluster pods are up and running by executing the following command:
To scrape metrics from Kubernetes with a VictoriaMetrics Cluster we will need to install vmagent with some additional configurations. To do so, please run the following command:
To verify that metrics are present in the VictoriaMetrics send a curl request to the vmselect service from kubernetes or setup Grafana and check it via the web interface.
Run the following command to see the list of services:
Query http://127.0.0.1:8481/select/0/prometheus/api/v1/query_range uses VictoriaMetrics querying API to fetch previously stored data points;
Argument query=count(up{kubernetes_pod_name=~".*vmselect.*"}) specifies the query we want to execute. Specifically, we calculate the number of vmselect pods.
Additional arguments start=-10m&step=1m' set requested time range from -10 minutes (10 minutes ago) to now (default value if end argument is omitted) and step (the distance between returned data points) of 1 minute;
By adding | jq we pass the output to the jq utility which outputs information in json format
The expected result of the query count(up{kubernetes_pod_name=~".*vmselect.*"}) should be equal to 3 - the number of replicas we set via replicaCount parameter.
To test via Grafana, we need to install it first. Install and connect Grafana to VictoriaMetrics, login into Grafana and open the metrics explore page at http://127.0.0.1:3000/explore.
Choose victoriametrics from the list of datasources and enter count(up{kubernetes_pod_name=~".*vmselect.*"}) to the Metric browser field as shown on the screenshot, then press Run query button:
Return to Grafana Explore and press the Run query button again.
The expected output is:
As you can see, after we scaled down the vmstorage replicas number from three to two pods, metrics are still available and correct. The response is not partial as it was before scaling. Also we see that query count(up{kubernetes_pod_name=~".*vmselect.*"}) returns the same value as before.
To confirm that the number of vmstorage pods is equivalent to two, execute the following request in Grafana Explore: