Repository: VictoriaMetrics/VictoriaMetrics
Pull request #4223 (2023-04-28 10:03:52)

vmselect: exit early from queue on context cancel
When `-search.maxConcurrentRequests` is reached, vmselect puts request in the queue. It is expected, that requests in the queue will be processed as soon as it would be enough capacity to do so.

However, it could happen that while request was waiting its turn, the client could have already cancel it (close the connection, or just close the tab with UI). In this case, we should de-queue such requests to avoid spending extra resources on them.

codecov[bot]: ## [Codecov](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/4223?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics) Report
Patch coverage has no change and project coverage change: **`+0.01`** :tada:
> Comparison is base [(`eb746a4`)](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/commit/eb746a4dab4e688dce163b476457bace6494c689?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics) 61.59% compared to head [(`81344da`)](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/4223?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics) 61.61%.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #4223      +/-   ##
==========================================
+ Coverage   61.59%   61.61%   +0.01%     
==========================================
  Files         325      325              
  Lines       58577    58578       +1     
==========================================
+ Hits        36081    36091      +10     
+ Misses      20523    20516       -7     
+ Partials     1973     1971       -2     
```


[see 5 files with indirect coverage changes](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/4223/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics)


</details>

[:umbrella: View full report in Codecov by Sentry](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/4223?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics).


Patch:
diff --git a/README.md b/README.md
index a2738ccbc..8524cbc42 100644
--- a/README.md
+++ b/README.md
@@ -572,7 +572,8 @@ The `/api/v1/export` endpoint should return the following response:
 ```
 
 Note that InfluxDB line protocol expects [timestamps in *nanoseconds* by default](https://docs.influxdata.com/influxdb/v1.7/write_protocols/line_protocol_tutorial/#timestamp),
-while VictoriaMetrics stores them with *milliseconds* precision.
+while VictoriaMetrics stores them with *milliseconds* precision. It is allowed to ingest timestamps with seconds,
+microseconds or nanoseconds precision - VictoriaMetrics will automatically convert them to milliseconds.
 
 Extra labels may be added to all the written time series by passing `extra_label=name=value` query args.
 For example, `/write?extra_label=foo=bar` would add `{foo="bar"}` label to all the ingested metrics.
diff --git a/app/vmselect/main.go b/app/vmselect/main.go
index 0c05ec94f..71c2c00b1 100644
--- a/app/vmselect/main.go
+++ b/app/vmselect/main.go
@@ -115,6 +115,13 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool {
 			timerpool.Put(t)
 			qt.Printf("wait in queue because -search.maxConcurrentRequests=%d concurrent requests are executed", *maxConcurrentRequests)
 			defer func() { <-concurrencyLimitCh }()
+		case <-r.Context().Done():
+			timerpool.Put(t)
+			remoteAddr := httpserver.GetQuotedRemoteAddr(r)
+			requestURI := httpserver.GetRequestURI(r)
+			logger.Infof("client has cancelled the request after %.3f seconds: remoteAddr=%s, requestURI: %q",
+				d.Seconds(), remoteAddr, requestURI)
+			return true
 		case <-t.C:
 			timerpool.Put(t)
 			concurrencyLimitTimeout.Inc()
diff --git a/deployment/docker/alerts-health.yml b/deployment/docker/alerts-health.yml
index 551e5d1df..63f66c8c2 100644
--- a/deployment/docker/alerts-health.yml
+++ b/deployment/docker/alerts-health.yml
@@ -6,7 +6,7 @@ groups:
     # note the `job` filter and update accordingly to your setup
     rules:
       - alert: TooManyRestarts
-        expr: changes(process_start_time_seconds{job=~"victoriametrics.*|vmselect.*|vminsert.*|vmstorage.*|vmagent.*|vmalert.*"}[15m]) > 2
+        expr: changes(process_start_time_seconds{job=~"victoriametrics.*|vmselect.*|vminsert.*|vmstorage.*|vmagent.*|vmalert.*|vmsingle.*"}[15m]) > 2
         labels:
           severity: critical
         annotations:
@@ -15,7 +15,7 @@ groups:
             It might be crashlooping."
 
       - alert: ServiceDown
-        expr: up{job=~"victoriametrics.*|vmselect.*|vminsert.*|vmstorage.*|vmagent.*|vmalert.*"} == 0
+        expr: up{job=~"victoriametrics.*|vmselect.*|vminsert.*|vmstorage.*|vmagent.*|vmalert.*|vmsingle.*"} == 0
         for: 2m
         labels:
           severity: critical
diff --git a/docs/Articles.md b/docs/Articles.md
index deed6888a..abf00eb64 100644
--- a/docs/Articles.md
+++ b/docs/Articles.md
@@ -1,5 +1,13 @@
 ---
 sort: 17
+weight: 17
+title: Articles
+menu:
+  docs:
+    parent: "victoriametrics"
+    weight: 17
+aliases:
+- /Articles.html
 ---
 
 # Articles
diff --git a/docs/BestPractices.md b/docs/BestPractices.md
index 066c664ac..e911778be 100644
--- a/docs/BestPractices.md
+++ b/docs/BestPractices.md
@@ -1,5 +1,13 @@
 ---
 sort: 20
+weight: 20
+title: VictoriaMetrics best practices
+menu:
+  docs:
+    parent: "victoriametrics"
+    weight: 20
+aliases:
+- /BestPractices.html
 ---
 
 # VictoriaMetrics best practices
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index f08c2f155..6e3601a5c 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -1,5 +1,13 @@
 ---
 sort: 16
+weight: 16
+title: CHANGELOG
+menu:
+  docs:
+    parent: "victoriametrics"
+    weight: 16
+aliases:
+- /CHANGELOG.html
 ---
 
 # CHANGELOG
@@ -18,7 +26,6 @@ The following tip changes can be tested by building VictoriaMetrics components f
 
 * SECURITY: serve `/robots.txt` content to disallow indexing of the exposed instances by search engines. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4128) for details.
 
-* FEATURE: open source [Graphite Render API](https://docs.victoriametrics.com/#graphite-render-api-usage). This API allows using VictoriaMetrics as a drop-in replacement for Graphite at both data ingestion and querying sides and reducing infrastructure costs by up to 10x comparing to Graphite. See [this case study](https://docs.victoriametrics.com/CaseStudies.html#grammarly) as an example.
 * FEATURE: [vmbackup](https://docs.victoriametrics.com/vmbackup.html): store backup creation and completion time in `backup_complete.ignore` file of backup contents. This is useful to determine point in time when backup was created and completed.
 * FEATURE: [vmbackupmanager](https://docs.victoriametrics.com/vmbackupmanager.html): add `created_at` field to the output of `/api/v1/backups` API and `vmbackupmanager backup list` command. See this [doc](https://docs.victoriametrics.com/vmbackupmanager.html#api-methods) for data format details.
 * FEATURE: deprecate `-bigMergeConcurrency` command-line flag, since improper configuration for this flag frequently led to uncontrolled growth of unmerged parts, which, in turn, could lead to queries slowdown and increased CPU usage. The concurrency for [background merges](https://docs.victoriametrics.com/#storage) can be controlled via `-smallMergeConcurrency` command-line flag, though it isn't recommended to do in general case.
@@ -40,7 +47,8 @@ The following tip changes can be tested by building VictoriaMetrics components f
 * BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): fix the display of the tenant selector. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4160).
 * BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): fix issue where vmui would freeze when adding a query that returned regular rows alongside a heatmap query.
 * BUGFIX: [vmalert](https://docs.victoriametrics.com/vmalert.html): properly display an error when using `query` function for templating value of `-external.alert.source` flag. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4181).
-* BUGFIX: [vmalert](https://docs.victoriametrics.com/vmalert.html): properly return empty slices instead of nil for `/api/v1/rules` and `/api/v1/alerts` API handlers. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4221). 
+* BUGFIX: [vmalert](https://docs.victoriametrics.com/vmalert.html): properly return empty slices instead of nil for `/api/v1/rules` and `/api/v1/alerts` API handlers. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4221).
+* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): add `__meta_kubernetes_endpoints_name` label for all ports discovered from endpoint. Previously, ports not matched by `Service` did not have this label. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4154) for details.
 
 ## [v1.90.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.90.0)
 
diff --git a/docs/CaseStudies.md b/docs/CaseStudies.md
index a42926ec7..db7b74558 100644
--- a/docs/CaseStudies.md
+++ b/docs/CaseStudies.md
@@ -1,5 +1,13 @@
 ---
 sort: 12
+weight: 12
+title: Case studies and talks
+menu:
+  docs:
+    parent: "victoriametrics"
+    weight: 12
+aliases:
+- /CaseStudies.html
 ---
 
 # Case studies and talks
diff --git a/docs/Cluster-VictoriaMetrics.md b/docs/Cluster-VictoriaMetrics.md
index bf722d8fd..76f2be147 100644
--- a/docs/Cluster-VictoriaMetrics.md
+++ b/docs/Cluster-VictoriaMetrics.md
@@ -1,5 +1,13 @@
 ---
 sort: 2
+weight: 2
+title: Cluster version
+menu:
+  docs:
+    parent: "victoriametrics"
+    weight: 2
+aliases:
+  - /Cluster-VictoriaMetrics.html
 ---
 
 # Cluster version
diff --git a/docs/ExtendedPromQL.md b/docs/ExtendedPromQL.md
index cb0e106cb..80208247a 100644
--- a/docs/ExtendedPromQL.md
+++ b/docs/ExtendedPromQL.md
@@ -1,5 +1,6 @@
 ---
 sort: 100
+weight: 100
 ---
 
 # MetricsQL old page
diff --git a/docs/FAQ.md b/docs/FAQ.md
index 520e533e6..a3c70cfae 100644
--- a/docs/FAQ.md
+++ b/docs/FAQ.md
@@ -1,5 +1,13 @@
 ---
 sort: 15
+weight: 15
+title: FAQ
+menu:
+  docs:
+    parent: "victoriametrics"
+    weight: 15
+aliases:
+- /FAQ.html
 ---
 
 # FAQ
diff --git a/docs/MetricsQL.md b/docs/MetricsQL.md
index 0e972be8c..0647fa7c7 100644
--- a/docs/MetricsQL.md
+++ b/docs/MetricsQL.md
@@ -1,5 +1,14 @@
 ---
 sort: 14
+weight: 14
+title: MetricsQL
+menu:
+  docs:
+    parent: "victoriametrics"
+    weight: 14
+aliases:
+- /ExtendedPromQL.html
+- /MetricsQL.html
 ---
 
 # MetricsQL
diff --git a/docs/PerTenantStatistic.md b/docs/PerTenantStatistic.md
index deb50c5dd..9b279d40d 100644
--- a/docs/PerTenantStatistic.md
+++ b/docs/PerTenantStatistic.md
@@ -1,5 +1,13 @@
 ---
 sort: 19
+weight: 19
+title: VictoriaMetrics Cluster Per Tenant Statistic
+menu:
+  docs:
+    parent: "victoriametrics"
+    weight: 19
+aliases:
+- /PerTenantStatistic.html
 ---
 
 # VictoriaMetrics Cluster Per Tenant Statistic
diff --git a/docs/Quick-Start.md b/docs/Quick-Start.md
index ffef573f4..7c610ece7 100644
--- a/docs/Quick-Start.md
+++ b/docs/Quick-Start.md
@@ -1,5 +1,13 @@
 ---
 sort: 13
+weight: 13
+title: Quick start
+menu:
+  docs:
+    parent: "victoriametrics"
+    weight: 13
+aliases:
+- /Quick-Start.html
 ---
 
 # Quick start
diff --git a/docs/README.md b/docs/README.md
index e83b65020..5ca518a5f 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -1,4 +1,3 @@
-
 # VictoriaMetrics
 
 [![Latest Release](https://img.shields.io/github/release/VictoriaMetrics/VictoriaMetrics.svg?style=flat-square)](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/latest)
@@ -573,7 +572,8 @@ The `/api/v1/export` endpoint should return the following response:
 ```
 
 Note that InfluxDB line protocol expects [timestamps in *nanoseconds* by default](https://docs.influxdata.com/influxdb/v1.7/write_protocols/line_protocol_tutorial/#timestamp),
-while VictoriaMetrics stores them with *milliseconds* precision.
+while VictoriaMetrics stores them with *milliseconds* precision. It is allowed to ingest timestamps with seconds,
+microseconds or nanoseconds precision - VictoriaMetrics will automatically convert them to milliseconds.
 
 Extra labels may be added to all the written time series by passing `extra_label=name=value` query args.
 For example, `/write?extra_label=foo=bar` would add `{foo="bar"}` label to all the ingested metrics.
diff --git a/docs/Release-Guide.md b/docs/Release-Guide.md
index 07860788c..dd1c99828 100644
--- a/docs/Release-Guide.md
+++ b/docs/Release-Guide.md
@@ -1,5 +1,13 @@
 ---
 sort: 18
+weight: 18
+title: Release process guidance
+menu:
+  docs:
+    parent: "victoriametrics"
+    weight: 18
+aliases:
+- /Release-Guide.html
 ---
 
 # Release process guidance
diff --git a/docs/Single-server-VictoriaMetrics.md b/docs/Single-server-VictoriaMetrics.md
index 6c062c948..ddd83641b 100644
--- a/docs/Single-server-VictoriaMetrics.md
+++ b/docs/Single-server-VictoriaMetrics.md
@@ -576,7 +576,8 @@ The `/api/v1/export` endpoint should return the following response:
 ```
 
 Note that InfluxDB line protocol expects [timestamps in *nanoseconds* by default](https://docs.influxdata.com/influxdb/v1.7/write_protocols/line_protocol_tutorial/#timestamp),
-while VictoriaMetrics stores them with *milliseconds* precision.
+while VictoriaMetrics stores them with *milliseconds* precision. It is allowed to ingest timestamps with seconds,
+microseconds or nanoseconds precision - VictoriaMetrics will automatically convert them to milliseconds.
 
 Extra labels may be added to all the written time series by passing `extra_label=name=value` query args.
 For example, `/write?extra_label=foo=bar` would add `{foo="bar"}` label to all the ingested metrics.
diff --git a/docs/Troubleshooting.md b/docs/Troubleshooting.md
index 695ba48d2..ec5dce237 100644
--- a/docs/Troubleshooting.md
+++ b/docs/Troubleshooting.md
@@ -1,5 +1,13 @@
 ---
 sort: 23
+weight: 23
+title: Troubleshooting
+menu:
+  docs:
+    parent: "victoriametrics"
+    weight: 23
+aliases:
+- /Troubleshooting.html
 ---
 
 # Troubleshooting
diff --git a/docs/enterprise.md b/docs/enterprise.md
index cfadb77f1..1ee1c014c 100644
--- a/docs/enterprise.md
+++ b/docs/enterprise.md
@@ -1,5 +1,13 @@
 ---
 sort: 99
+weight: 99
+title: VictoriaMetrics Enterprise
+menu:
+  docs:
+    parent: "victoriametrics"
+    weight: 99
+aliases:
+- /enterprise.html
 ---
 
 # VictoriaMetrics enterprise
diff --git a/docs/guides/README.md b/docs/guides/README.md
index 64925ad5d..2f0d3a832 100644
--- a/docs/guides/README.md
+++ b/docs/guides/README.md
@@ -1,5 +1,11 @@
 ---
 sort: 26
+weight: 01
+disableToc: true
+menu:
+  docs:
+    parent: "guides"
+    weight: 01
 ---
 
 # Guides
diff --git a/docs/guides/getting-started-with-vm-operator.md b/docs/guides/getting-started-with-vm-operator.md
index 57d2b7c6a..b5926b2da 100644
--- a/docs/guides/getting-started-with-vm-operator.md
+++ b/docs/guides/getting-started-with-vm-operator.md
@@ -1,3 +1,13 @@
+---
+weight: 4
+title: Getting started with VM Operator
+menu:
+  docs:
+    parent: "guides"
+    weight: 4
+aliases:
+- /guides/getting-started-with-vm-operator.html
+---
 # Getting started with VM Operator
 
 **The guide covers:**
diff --git a/docs/guides/grafana-vmgateway-openid-configuration.md b/docs/guides/grafana-vmgateway-openid-configuration.md
index a8f462643..5e505b779 100644
--- a/docs/guides/grafana-vmgateway-openid-configuration.md
+++ b/docs/guides/grafana-vmgateway-openid-configuration.md
@@ -1,3 +1,13 @@
+---
+weight: 5
+title: How to configure vmgateway for multi-tenant access using Grafana and OpenID Connect
+menu:
+  docs:
+    parent: "guides"
+    weight: 5
+aliases:
+- /guides/grafana-vmgateway-openid-configuration.html
+---
 # How to configure vmgateway for multi-tenant access using Grafana and OpenID Connect
 
 Using [Grafana](https://grafana.com/) with [vmgateway](https://docs.victoriametrics.com/vmgateway.html) is a great way to provide [multi-tenant](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#multitenancy) access to your metrics.
diff --git a/docs/guides/guide-delete-or-replace-metrics.md b/docs/guides/guide-delete-or-replace-metrics.md
index edce40e58..544c42dc9 100644
--- a/docs/guides/guide-delete-or-replace-metrics.md
+++ b/docs/guides/guide-delete-or-replace-metrics.md
@@ -1,3 +1,13 @@
+---
+weight: 7
+title: How to delete or replace metrics in VictoriaMetrics
+menu:
+  docs:
+    parent: "guides"
+    weight: 7
+aliases:
+- /guides/guide-delete-or-replace-metrics.html
+---
 # How to delete or replace metrics in VictoriaMetrics 
 
 Data deletion is an operation people expect a database to have. [VictoriaMetrics](https://victoriametrics.com) supports 
diff --git a/docs/guides/guide-vmanomaly-vmalert.md b/docs/guides/guide-vmanomaly-vmalert.md
index a9f443fc4..704f7846a 100644
--- a/docs/guides/guide-vmanomaly-vmalert.md
+++ b/docs/guides/guide-vmanomaly-vmalert.md
@@ -1,3 +1,13 @@
+---
+weight: 6
+title: Getting started with vmanomaly
+menu:
+  docs:
+    parent: "guides"
+    weight: 6
+aliases:
+- /guides/guide-vmanomaly-vmalert.html
+---
 # Getting started with vmanomaly
 
 **Prerequisites**
diff --git a/docs/guides/guide-vmcluster-multiple-retention-setup.md b/docs/guides/guide-vmcluster-multiple-retention-setup.md
index cf3ca24ed..841453a57 100644
--- a/docs/guides/guide-vmcluster-multiple-retention-setup.md
+++ b/docs/guides/guide-vmcluster-multiple-retention-setup.md
@@ -1,3 +1,13 @@
+---
+weight: 10
+title: Multi Retention Setup within VictoriaMetrics Cluster
+menu:
+  docs:
+    parent: "guides"
+    weight: 10
+aliases:
+- /guides/guide-vmcluster-multiple-retention-setup.html
+---
 # Multi Retention Setup within VictoriaMetrics Cluster
 
 
diff --git a/docs/guides/k8s-ha-monitoring-via-vm-cluster.md b/docs/guides/k8s-ha-monitoring-via-vm-cluster.md
index 9d1f98a67..aac293af8 100644
--- a/docs/guides/k8s-ha-monitoring-via-vm-cluster.md
+++ b/docs/guides/k8s-ha-monitoring-via-vm-cluster.md
@@ -1,3 +1,13 @@
+---
+weight: 9
+title: HA monitoring setup in Kubernetes via VictoriaMetrics Cluster
+menu:
+  docs:
+    parent: "guides"
+    weight: 9
+aliases:
+- /guides/k8s-ha-monitoring-via-vm-cluster.html
+---
 # HA monitoring setup in Kubernetes via VictoriaMetrics Cluster
 
 
diff --git a/docs/guides/k8s-monitoring-via-vm-cluster.md b/docs/guides/k8s-monitoring-via-vm-cluster.md
index 4cbee6c0d..b8370b927 100644
--- a/docs/guides/k8s-monitoring-via-vm-cluster.md
+++ b/docs/guides/k8s-monitoring-via-vm-cluster.md
@@ -1,3 +1,13 @@
+---
+weight: 3
+title: Kubernetes monitoring with VictoriaMetrics Cluster
+menu:
+  docs:
+    parent: "guides"
+    weight: 3
+aliases:
+- /guides/k8s-monitoring-via-vm-cluster.html
+---
 # Kubernetes monitoring with VictoriaMetrics Cluster
 
 
diff --git a/docs/guides/k8s-monitoring-via-vm-single.md b/docs/guides/k8s-monitoring-via-vm-single.md
index 166c6700b..8be446b7a 100644
--- a/docs/guides/k8s-monitoring-via-vm-single.md
+++ b/docs/guides/k8s-monitoring-via-vm-single.md
@@ -1,3 +1,13 @@
+---
+weight: 2
+title: Kubernetes monitoring via VictoriaMetrics Single
+menu:
+  docs:
+    parent: "guides"
+    weight: 2
+aliases:
+- /guides/k8s-monitoring-via-vm-single.html
+---
 # Kubernetes monitoring via VictoriaMetrics Single
 
 
diff --git a/docs/guides/migrate-from-influx.md b/docs/guides/migrate-from-influx.md
index bd998675a..2deaa9aef 100644
--- a/docs/guides/migrate-from-influx.md
+++ b/docs/guides/migrate-from-influx.md
@@ -1,3 +1,13 @@
+---
+title: Migrate from InfluxDB to VictoriaMetrics
+weight: 8
+menu:
+  docs:
+    parent: "guides"
+    weight: 8
+aliases:
+- /guides/migrate-from-influx.html
+---
 # Migrate from InfluxDB to VictoriaMetrics
 
 InfluxDB is a well-known time series database built for
diff --git a/docs/guides/multi-regional-setup-dedicated-regions.md b/docs/guides/multi-regional-setup-dedicated-regions.md
index 669e14d88..100982ebc 100644
--- a/docs/guides/multi-regional-setup-dedicated-regions.md
+++ b/docs/guides/multi-regional-setup-dedicated-regions.md
@@ -1,3 +1,13 @@
+---
+weight: 11
+title: Multi-regional setup with VictoriaMetrics: Dedicated regions for monitoring
+menu:
+  docs:
+    parent: "guides"
+    weight: 11
+aliases:
+- /guides/multi-regional-setup-dedicated-regions.html
+---
 # Multi-regional setup with VictoriaMetrics: Dedicated regions for monitoring
 
 ### Scenario
diff --git a/docs/guides/understand-your-setup-size.md b/docs/guides/understand-your-setup-size.md
index e428f6859..e3e67c530 100644
--- a/docs/guides/understand-your-setup-size.md
+++ b/docs/guides/understand-your-setup-size.md
@@ -1,3 +1,13 @@
+---
+weight: 9
+title: Understand Your Setup Size
+menu:
+  docs:
+    parent: "guides"
+    weight: 9
+aliases:
+- /guides/understand-your-setup-size.html
+---
 # Understand Your Setup Size
 
 The docs provide a simple and high-level overview of Ingestion Rate, Active Time Series, and Query per Second. These terms are a part of capacity planning ([Single-Node](https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#capacity-planning), [Cluster](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#capacity-planning)) and [Managed VictoriaMetrics](https://docs.victoriametrics.com/managed_victoriametrics/) pricing.
diff --git a/docs/keyConcepts.md b/docs/keyConcepts.md
index d4d13aabc..ae4f124fe 100644
--- a/docs/keyConcepts.md
+++ b/docs/keyConcepts.md
@@ -1,5 +1,13 @@
 ---
 sort: 22
+weight: 22
+title: Key concepts
+menu:
+  docs:
+    parent: "victoriametrics"
+    weight: 22
+aliases:
+- /keyConcepts.html
 ---
 
 # Key concepts
diff --git a/docs/managed-victoriametrics/README.md b/docs/managed-victoriametrics/README.md
index 26dbf11bc..0f1aa62b3 100644
--- a/docs/managed-victoriametrics/README.md
+++ b/docs/managed-victoriametrics/README.md
@@ -1,5 +1,8 @@
 ---
 sort: 28
+title: Managed VictoriaMetrics
+weight: 01
+disableToc: true
 ---
 
 # Managed VictoriaMetrics
diff --git a/docs/managed-victoriametrics/alerting-vmalert-managed-victoria-metrics.md b/docs/managed-victoriametrics/alerting-vmalert-managed-victoria-metrics.md
index c05fc1b9e..a2240828a 100644
--- a/docs/managed-victoriametrics/alerting-vmalert-managed-victoria-metrics.md
+++ b/docs/managed-victoriametrics/alerting-vmalert-managed-victoria-metrics.md
@@ -6,6 +6,8 @@ menu:
   docs:
     parent: "managed"
     weight: 4
+aliases:
+- /managed-victoriametrics/alerting-vmalert-managed-victoria-metrics.html
 ---
 # Alerting with vmalert and Managed VictoriaMetrics
 
diff --git a/docs/managed-victoriametrics/how-to-monitor-k8s.md b/docs/managed-victoriametrics/how-to-monitor-k8s.md
index 11fa37a4d..0254e1333 100644
--- a/docs/managed-victoriametrics/how-to-monitor-k8s.md
+++ b/docs/managed-victoriametrics/how-to-monitor-k8s.md
@@ -6,6 +6,8 @@ menu:
   docs:
     parent: "managed"
     weight: 3
+aliases:
+- /managed-victoriametrics/how-to-monitor-k8s.html
 ---
 # Kubernetes Monitoring with Managed VictoriaMetrics
 
diff --git a/docs/managed-victoriametrics/overview.md b/docs/managed-victoriametrics/overview.md
index 101324896..23163dd54 100644
--- a/docs/managed-victoriametrics/overview.md
+++ b/docs/managed-victoriametrics/overview.md
@@ -6,6 +6,9 @@ menu:
   docs:
     parent: "managed"
     weight: 1
+aliases:
+- /managed-victoriametrics/overview.html
+- 
 ---
 
 # Overview of Managed VictoriaMetrics 
diff --git a/docs/managed-victoriametrics/quickstart.md b/docs/managed-victoriametrics/quickstart.md
index e3d0f213e..7c72c411a 100644
--- a/docs/managed-victoriametrics/quickstart.md
+++ b/docs/managed-victoriametrics/quickstart.md
@@ -6,6 +6,8 @@ menu:
   docs:
     parent: "managed"
     weight: 2
+aliases:
+- /managed-victoriametrics/quickstart.html
 ---
 # Quick Start in Managed VictoriaMetrics
 
diff --git a/docs/managed-victoriametrics/setup-notifications.md b/docs/managed-victoriametrics/setup-notifications.md
index 8560af6cb..bcb8adec2 100644
--- a/docs/managed-victoriametrics/setup-notifications.md
+++ b/docs/managed-victoriametrics/setup-notifications.md
@@ -6,6 +6,8 @@ menu:
   docs:
     parent: "managed"
     weight: 6
+aliases:
+- /managed-victoriametrics/setup-notifications.html
 ---
 # Notifications in Managed VictoriaMetrics
 
diff --git a/docs/managed-victoriametrics/user-managment.md b/docs/managed-victoriametrics/user-managment.md
index c4001e0d0..2800f0468 100644
--- a/docs/managed-victoriametrics/user-managment.md
+++ b/docs/managed-victoriametrics/user-managment.md
@@ -6,6 +6,8 @@ menu:
   docs:
     parent: "managed"
     weight: 5
+aliases:
+- /managed-victoriametrics/user-managment.html
 ---
 # User Management in Managed VictoriaMetrics 
 
diff --git a/docs/relabeling.md b/docs/relabeling.md
index a3832f875..b5a513888 100644
--- a/docs/relabeling.md
+++ b/docs/relabeling.md
@@ -1,5 +1,13 @@
 ---
 sort: 25
+weight: 25
+title: Relabeling cookbook
+menu:
+  docs:
+    parent: "victoriametrics"
+    weight: 25
+aliases:
+- /relabeling.html
 ---
 
 # Relabeling cookbook
diff --git a/docs/sd_configs.md b/docs/sd_configs.md
index a535169d1..cc4250706 100644
--- a/docs/sd_configs.md
+++ b/docs/sd_configs.md
@@ -1,5 +1,13 @@
 ---
 sort: 24
+weight: 24
+title: Prometheus service discovery
+menu:
+  docs:
+    parent: "victoriametrics"
+    weight: 24
+aliases:
+- /sd_configs.html
 ---
 
 # Prometheus service discovery
diff --git a/docs/stream-aggregation.md b/docs/stream-aggregation.md
index 6067b5d7b..2ccb69508 100644
--- a/docs/stream-aggregation.md
+++ b/docs/stream-aggregation.md
@@ -1,5 +1,13 @@
 ---
 sort: 98
+weight: 98
+title: streaming aggregation
+menu:
+  docs:
+    parent: "victoriametrics"
+    weight: 98
+aliases:
+- /stream-aggregation.html
 ---
 
 # streaming aggregation
diff --git a/docs/url-examples.md b/docs/url-examples.md
index 186dab381..ab35d978d 100644
--- a/docs/url-examples.md
+++ b/docs/url-examples.md
@@ -1,5 +1,11 @@
 ---
 sort: 21
+weight: 21
+title: VictoriaMetrics API examples
+menu:
+  docs:
+    parent: "victoriametrics"
+    weight: 21
 ---
 
 # VictoriaMetrics API examples
diff --git a/docs/vmanomaly.md b/docs/vmanomaly.md
index 02a246b76..3472ebc85 100644
--- a/docs/vmanomaly.md
+++ b/docs/vmanomaly.md
@@ -1,5 +1,13 @@
 ---
 sort: 11
+weight: 11
+title: vmanomaly
+menu:
+  docs:
+    parent: "victoriametrics"
+    weight: 11
+aliases:
+- /vmanomaly.html
 ---
 
 # vmanomaly
diff --git a/lib/promscrape/discovery/kubernetes/endpoints.go b/lib/promscrape/discovery/kubernetes/endpoints.go
index f83526ed0..25497f4f0 100644
--- a/lib/promscrape/discovery/kubernetes/endpoints.go
+++ b/lib/promscrape/discovery/kubernetes/endpoints.go
@@ -114,6 +114,10 @@ func (eps *Endpoints) getTargetLabels(gw *groupWatcher) []*promutils.Labels {
 		logger.Warnf(`the number of targets for "role: endpoints" %q exceeds 1000 and will be truncated in the next k8s releases; please use "role: endpointslice" instead`, eps.Metadata.key())
 	}
 
+	// Prometheus sets endpoints_name and namespace labels for all endpoints
+	// Even if port is not matching service port.
+	// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4154
+	commonEpLabels := eps.getCommonLabels()
 	// Append labels for skipped ports on seen pods.
 	portSeen := func(port int, ports []int) bool {
 		for _, p := range ports {
@@ -134,6 +138,7 @@ func (eps *Endpoints) getTargetLabels(gw *groupWatcher) []*promutils.Labels {
 				m.Add("__address__", addr)
 				p.appendCommonLabels(m, gw)
 				p.appendContainerLabels(m, c, &cp)
+				m.AddFrom(commonEpLabels)
 				if svc != nil {
 					svc.appendCommonLabels(m)
 				}
@@ -146,6 +151,13 @@ func (eps *Endpoints) getTargetLabels(gw *groupWatcher) []*promutils.Labels {
 	return ms
 }
 
+func (eps *Endpoints) getCommonLabels() *promutils.Labels {
+	m := promutils.GetLabels()
+	m.Add("__meta_kubernetes_namespace", eps.Metadata.Namespace)
+	m.Add("__meta_kubernetes_endpoints_name", eps.Metadata.Name)
+	return m
+}
+
 func appendEndpointLabelsForAddresses(ms []*promutils.Labels, gw *groupWatcher, podPortsSeen map[*Pod][]int, eps *Endpoints,
 	eas []EndpointAddress, epp EndpointPort, svc *Service, ready string) []*promutils.Labels {
 	for _, ea := range eas {


Test patch:
diff --git a/lib/promscrape/discovery/kubernetes/endpoints_test.go b/lib/promscrape/discovery/kubernetes/endpoints_test.go
index 402bb18ed..bb6b9e8ac 100644
--- a/lib/promscrape/discovery/kubernetes/endpoints_test.go
+++ b/lib/promscrape/discovery/kubernetes/endpoints_test.go
@@ -293,6 +293,7 @@ func TestGetEndpointsLabels(t *testing.T) {
 			}),
 			promutils.NewLabelsFromMap(map[string]string{
 				"__address__":                                    "192.168.15.1:8428",
+				"__meta_kubernetes_endpoints_name":               "test-eps",
 				"__meta_kubernetes_namespace":                    "default",
 				"__meta_kubernetes_node_label_node_label":        "xyz",
 				"__meta_kubernetes_node_labelpresent_node_label": "true",