Repository: VictoriaMetrics/VictoriaMetrics
Pull request #1613 (2021-09-13 07:24:15)

vmalert: display extra filter labels in UI
![image](https://user-images.githubusercontent.com/2902918/133041089-b25dca9a-f39a-4551-aa98-84c71c694f13.png)


codecov[bot]: # [Codecov](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/1613?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics) Report
> Merging [#1613](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/1613?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics) (f7ca8f2) into [master](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/commit/2814388891fe37b5b94628dd5f197ad0abb9c59c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics) (2814388) will **decrease** coverage by `0.03%`.
> The diff coverage is `0.00%`.

[![Impacted file tree graph](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/1613/graphs/tree.svg?width=650&height=150&src=pr&token=YND8dYVcXn&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics)](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/1613?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics)

```diff
@@            Coverage Diff             @@
##           master    #1613      +/-   ##
==========================================
- Coverage   60.57%   60.53%   -0.04%     
==========================================
  Files         233      233              
  Lines       38603    38610       +7     
==========================================
- Hits        23382    23373       -9     
- Misses      13663    13682      +19     
+ Partials     1558     1555       -3     
```


| [Impacted Files](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/1613?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics) | Coverage Δ | |
|---|---|---|
| [app/vmalert/web.qtpl.go](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/1613/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics#diff-YXBwL3ZtYWxlcnQvd2ViLnF0cGwuZ28=) | `4.76% <0.00%> (-0.14%)` | :arrow_down: |
| [app/vmselect/promql/aggr\_incremental.go](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/1613/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics#diff-YXBwL3Ztc2VsZWN0L3Byb21xbC9hZ2dyX2luY3JlbWVudGFsLmdv) | `82.83% <0.00%> (-2.41%)` | :arrow_down: |
| [lib/bloomfilter/filter.go](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/1613/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics#diff-bGliL2Jsb29tZmlsdGVyL2ZpbHRlci5nbw==) | `98.00% <0.00%> (-2.00%)` | :arrow_down: |
| [lib/mergeset/table.go](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/1613/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics#diff-bGliL21lcmdlc2V0L3RhYmxlLmdv) | `65.85% <0.00%> (-0.68%)` | :arrow_down: |
| [lib/storage/storage.go](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/1613/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics#diff-bGliL3N0b3JhZ2Uvc3RvcmFnZS5nbw==) | `67.48% <0.00%> (-0.07%)` | :arrow_down: |
| [app/vmalert/remotewrite/remotewrite.go](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/1613/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics#diff-YXBwL3ZtYWxlcnQvcmVtb3Rld3JpdGUvcmVtb3Rld3JpdGUuZ28=) | `65.03% <0.00%> (+5.59%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/1613?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/1613?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics). Last update [2814388...f7ca8f2](https://codecov.io/gh/VictoriaMetrics/VictoriaMetrics/pull/1613?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=VictoriaMetrics).


Patch:
diff --git a/app/vmalert/web.qtpl b/app/vmalert/web.qtpl
index 229f5af9f..e135bce8c 100644
--- a/app/vmalert/web.qtpl
+++ b/app/vmalert/web.qtpl
@@ -63,6 +63,13 @@ var navItems = []tpl.NavItem{
                  {% if rNotOk[g.Name] > 0 %}<span class="badge bg-danger" title="Number of rules withs status Error">{%d rNotOk[g.Name] %}</span> {% endif %}
                 <span class="badge bg-success" title="Number of rules withs status Ok">{%d rOk[g.Name] %}</span>
                 <p class="fs-6 fw-lighter">{%s g.File %}</p>
+                {% if len(g.ExtraFilterLabels) > 0 %}
+                    <div class="fs-6 fw-lighter">Extra filter labels
+                    {% for k, v := range g.ExtraFilterLabels %}
+                            <span class="float-left badge bg-primary">{%s k %}={%s v %}</span>
+                    {% endfor %}
+                    </div>
+                {% endif %}
             </div>
             <div class="collapse" id="rules-{%s g.ID %}">
                 <table class="table table-striped table-hover table-sm">
diff --git a/app/vmalert/web.qtpl.go b/app/vmalert/web.qtpl.go
index 363c0cc8f..9cf4d0f90 100644
--- a/app/vmalert/web.qtpl.go
+++ b/app/vmalert/web.qtpl.go
@@ -217,11 +217,42 @@ func StreamListGroups(qw422016 *qt422016.Writer, groups []APIGroup) {
 			qw422016.E().S(g.File)
 //line app/vmalert/web.qtpl:65
 			qw422016.N().S(`</p>
+                `)
+//line app/vmalert/web.qtpl:66
+			if len(g.ExtraFilterLabels) > 0 {
+//line app/vmalert/web.qtpl:66
+				qw422016.N().S(`
+                    <div class="fs-6 fw-lighter">Extra filter labels
+                    `)
+//line app/vmalert/web.qtpl:68
+				for k, v := range g.ExtraFilterLabels {
+//line app/vmalert/web.qtpl:68
+					qw422016.N().S(`
+                            <span class="float-left badge bg-primary">`)
+//line app/vmalert/web.qtpl:69
+					qw422016.E().S(k)
+//line app/vmalert/web.qtpl:69
+					qw422016.N().S(`=`)
+//line app/vmalert/web.qtpl:69
+					qw422016.E().S(v)
+//line app/vmalert/web.qtpl:69
+					qw422016.N().S(`</span>
+                    `)
+//line app/vmalert/web.qtpl:70
+				}
+//line app/vmalert/web.qtpl:70
+				qw422016.N().S(`
+                    </div>
+                `)
+//line app/vmalert/web.qtpl:72
+			}
+//line app/vmalert/web.qtpl:72
+			qw422016.N().S(`
             </div>
             <div class="collapse" id="rules-`)
-//line app/vmalert/web.qtpl:67
+//line app/vmalert/web.qtpl:74
 			qw422016.E().S(g.ID)
-//line app/vmalert/web.qtpl:67
+//line app/vmalert/web.qtpl:74
 			qw422016.N().S(`">
                 <table class="table table-striped table-hover table-sm">
                     <thead>
@@ -234,280 +265,280 @@ func StreamListGroups(qw422016 *qt422016.Writer, groups []APIGroup) {
                     </thead>
                     <tbody>
                     `)
-//line app/vmalert/web.qtpl:78
+//line app/vmalert/web.qtpl:85
 			for _, ar := range g.AlertingRules {
-//line app/vmalert/web.qtpl:78
+//line app/vmalert/web.qtpl:85
 				qw422016.N().S(`
                         <tr`)
-//line app/vmalert/web.qtpl:79
+//line app/vmalert/web.qtpl:86
 				if ar.LastError != "" {
-//line app/vmalert/web.qtpl:79
+//line app/vmalert/web.qtpl:86
 					qw422016.N().S(` class="alert-danger"`)
-//line app/vmalert/web.qtpl:79
+//line app/vmalert/web.qtpl:86
 				}
-//line app/vmalert/web.qtpl:79
+//line app/vmalert/web.qtpl:86
 				qw422016.N().S(`>
                             <td>
                                 <b>alert:</b> `)
-//line app/vmalert/web.qtpl:81
+//line app/vmalert/web.qtpl:88
 				qw422016.E().S(ar.Name)
-//line app/vmalert/web.qtpl:81
+//line app/vmalert/web.qtpl:88
 				qw422016.N().S(` (for: `)
-//line app/vmalert/web.qtpl:81
+//line app/vmalert/web.qtpl:88
 				qw422016.E().V(ar.For)
-//line app/vmalert/web.qtpl:81
+//line app/vmalert/web.qtpl:88
 				qw422016.N().S(`)<br>
                                 <code><pre>`)
-//line app/vmalert/web.qtpl:82
+//line app/vmalert/web.qtpl:89
 				qw422016.E().S(ar.Expression)
-//line app/vmalert/web.qtpl:82
+//line app/vmalert/web.qtpl:89
 				qw422016.N().S(`</pre></code><br>
                                 `)
-//line app/vmalert/web.qtpl:83
+//line app/vmalert/web.qtpl:90
 				if len(ar.Labels) > 0 {
-//line app/vmalert/web.qtpl:83
+//line app/vmalert/web.qtpl:90
 					qw422016.N().S(` <b>Labels:</b>`)
-//line app/vmalert/web.qtpl:83
+//line app/vmalert/web.qtpl:90
 				}
-//line app/vmalert/web.qtpl:83
+//line app/vmalert/web.qtpl:90
 				qw422016.N().S(`
                                 `)
-//line app/vmalert/web.qtpl:84
+//line app/vmalert/web.qtpl:91
 				for k, v := range ar.Labels {
-//line app/vmalert/web.qtpl:84
+//line app/vmalert/web.qtpl:91
 					qw422016.N().S(`
                                         <span class="ms-1 badge bg-primary">`)
-//line app/vmalert/web.qtpl:85
+//line app/vmalert/web.qtpl:92
 					qw422016.E().S(k)
-//line app/vmalert/web.qtpl:85
+//line app/vmalert/web.qtpl:92
 					qw422016.N().S(`=`)
-//line app/vmalert/web.qtpl:85
+//line app/vmalert/web.qtpl:92
 					qw422016.E().S(v)
-//line app/vmalert/web.qtpl:85
+//line app/vmalert/web.qtpl:92
 					qw422016.N().S(`</span>
                                 `)
-//line app/vmalert/web.qtpl:86
+//line app/vmalert/web.qtpl:93
 				}
-//line app/vmalert/web.qtpl:86
+//line app/vmalert/web.qtpl:93
 				qw422016.N().S(`
                             </td>
                             <td><div class="error-cell">`)
-//line app/vmalert/web.qtpl:88
+//line app/vmalert/web.qtpl:95
 				qw422016.E().S(ar.LastError)
-//line app/vmalert/web.qtpl:88
+//line app/vmalert/web.qtpl:95
 				qw422016.N().S(`</div></td>
                             <td>`)
-//line app/vmalert/web.qtpl:89
+//line app/vmalert/web.qtpl:96
 				qw422016.N().D(ar.LastSamples)
-//line app/vmalert/web.qtpl:89
+//line app/vmalert/web.qtpl:96
 				qw422016.N().S(`</td>
                             <td>`)
-//line app/vmalert/web.qtpl:90
+//line app/vmalert/web.qtpl:97
 				qw422016.N().FPrec(time.Since(ar.LastExec).Seconds(), 3)
-//line app/vmalert/web.qtpl:90
+//line app/vmalert/web.qtpl:97
 				qw422016.N().S(`s ago</td>
                         </tr>
                     `)
-//line app/vmalert/web.qtpl:92
+//line app/vmalert/web.qtpl:99
 			}
-//line app/vmalert/web.qtpl:92
+//line app/vmalert/web.qtpl:99
 			qw422016.N().S(`
                     `)
-//line app/vmalert/web.qtpl:93
+//line app/vmalert/web.qtpl:100
 			for _, rr := range g.RecordingRules {
-//line app/vmalert/web.qtpl:93
+//line app/vmalert/web.qtpl:100
 				qw422016.N().S(`
                         <tr>
                             <td>
                                 <b>record:</b> `)
-//line app/vmalert/web.qtpl:96
+//line app/vmalert/web.qtpl:103
 				qw422016.E().S(rr.Name)
-//line app/vmalert/web.qtpl:96
+//line app/vmalert/web.qtpl:103
 				qw422016.N().S(`<br>
                                 <code><pre>`)
-//line app/vmalert/web.qtpl:97
+//line app/vmalert/web.qtpl:104
 				qw422016.E().S(rr.Expression)
-//line app/vmalert/web.qtpl:97
+//line app/vmalert/web.qtpl:104
 				qw422016.N().S(`</pre></code>
                                 `)
-//line app/vmalert/web.qtpl:98
+//line app/vmalert/web.qtpl:105
 				if len(rr.Labels) > 0 {
-//line app/vmalert/web.qtpl:98
+//line app/vmalert/web.qtpl:105
 					qw422016.N().S(` <b>Labels:</b>`)
-//line app/vmalert/web.qtpl:98
+//line app/vmalert/web.qtpl:105
 				}
-//line app/vmalert/web.qtpl:98
+//line app/vmalert/web.qtpl:105
 				qw422016.N().S(`
                                 `)
-//line app/vmalert/web.qtpl:99
+//line app/vmalert/web.qtpl:106
 				for k, v := range rr.Labels {
-//line app/vmalert/web.qtpl:99
+//line app/vmalert/web.qtpl:106
 					qw422016.N().S(`
                                         <span class="ms-1 badge bg-primary">`)
-//line app/vmalert/web.qtpl:100
+//line app/vmalert/web.qtpl:107
 					qw422016.E().S(k)
-//line app/vmalert/web.qtpl:100
+//line app/vmalert/web.qtpl:107
 					qw422016.N().S(`=`)
-//line app/vmalert/web.qtpl:100
+//line app/vmalert/web.qtpl:107
 					qw422016.E().S(v)
-//line app/vmalert/web.qtpl:100
+//line app/vmalert/web.qtpl:107
 					qw422016.N().S(`</span>
                                 `)
-//line app/vmalert/web.qtpl:101
+//line app/vmalert/web.qtpl:108
 				}
-//line app/vmalert/web.qtpl:101
+//line app/vmalert/web.qtpl:108
 				qw422016.N().S(`
                             </td>
                             <td><div class="error-cell">`)
-//line app/vmalert/web.qtpl:103
+//line app/vmalert/web.qtpl:110
 				qw422016.E().S(rr.LastError)
-//line app/vmalert/web.qtpl:103
+//line app/vmalert/web.qtpl:110
 				qw422016.N().S(`</div></td>
                             <td>`)
-//line app/vmalert/web.qtpl:104
+//line app/vmalert/web.qtpl:111
 				qw422016.N().D(rr.LastSamples)
-//line app/vmalert/web.qtpl:104
+//line app/vmalert/web.qtpl:111
 				qw422016.N().S(`</td>
                             <td>`)
-//line app/vmalert/web.qtpl:105
+//line app/vmalert/web.qtpl:112
 				qw422016.N().FPrec(time.Since(rr.LastExec).Seconds(), 3)
-//line app/vmalert/web.qtpl:105
+//line app/vmalert/web.qtpl:112
 				qw422016.N().S(`s ago</td>
                         </tr>
                     `)
-//line app/vmalert/web.qtpl:107
+//line app/vmalert/web.qtpl:114
 			}
-//line app/vmalert/web.qtpl:107
+//line app/vmalert/web.qtpl:114
 			qw422016.N().S(`
                  </tbody>
                 </table>
             </div>
         `)
-//line app/vmalert/web.qtpl:111
+//line app/vmalert/web.qtpl:118
 		}
-//line app/vmalert/web.qtpl:111
+//line app/vmalert/web.qtpl:118
 		qw422016.N().S(`
 
     `)
-//line app/vmalert/web.qtpl:113
+//line app/vmalert/web.qtpl:120
 	} else {
-//line app/vmalert/web.qtpl:113
+//line app/vmalert/web.qtpl:120
 		qw422016.N().S(`
         <div>
             <p>No items...</p>
         </div>
     `)
-//line app/vmalert/web.qtpl:117
+//line app/vmalert/web.qtpl:124
 	}
-//line app/vmalert/web.qtpl:117
+//line app/vmalert/web.qtpl:124
 	qw422016.N().S(`
 
     `)
-//line app/vmalert/web.qtpl:119
+//line app/vmalert/web.qtpl:126
 	tpl.StreamFooter(qw422016)
-//line app/vmalert/web.qtpl:119
+//line app/vmalert/web.qtpl:126
 	qw422016.N().S(`
 
 `)
-//line app/vmalert/web.qtpl:121
+//line app/vmalert/web.qtpl:128
 }
 
-//line app/vmalert/web.qtpl:121
+//line app/vmalert/web.qtpl:128
 func WriteListGroups(qq422016 qtio422016.Writer, groups []APIGroup) {
-//line app/vmalert/web.qtpl:121
+//line app/vmalert/web.qtpl:128
 	qw422016 := qt422016.AcquireWriter(qq422016)
-//line app/vmalert/web.qtpl:121
+//line app/vmalert/web.qtpl:128
 	StreamListGroups(qw422016, groups)
-//line app/vmalert/web.qtpl:121
+//line app/vmalert/web.qtpl:128
 	qt422016.ReleaseWriter(qw422016)
-//line app/vmalert/web.qtpl:121
+//line app/vmalert/web.qtpl:128
 }
 
-//line app/vmalert/web.qtpl:121
+//line app/vmalert/web.qtpl:128
 func ListGroups(groups []APIGroup) string {
-//line app/vmalert/web.qtpl:121
+//line app/vmalert/web.qtpl:128
 	qb422016 := qt422016.AcquireByteBuffer()
-//line app/vmalert/web.qtpl:121
+//line app/vmalert/web.qtpl:128
 	WriteListGroups(qb422016, groups)
-//line app/vmalert/web.qtpl:121
+//line app/vmalert/web.qtpl:128
 	qs422016 := string(qb422016.B)
-//line app/vmalert/web.qtpl:121
+//line app/vmalert/web.qtpl:128
 	qt422016.ReleaseByteBuffer(qb422016)
-//line app/vmalert/web.qtpl:121
+//line app/vmalert/web.qtpl:128
 	return qs422016
-//line app/vmalert/web.qtpl:121
+//line app/vmalert/web.qtpl:128
 }
 
-//line app/vmalert/web.qtpl:124
+//line app/vmalert/web.qtpl:131
 func StreamListAlerts(qw422016 *qt422016.Writer, groupAlerts []GroupAlerts) {
-//line app/vmalert/web.qtpl:124
+//line app/vmalert/web.qtpl:131
 	qw422016.N().S(`
     `)
-//line app/vmalert/web.qtpl:125
+//line app/vmalert/web.qtpl:132
 	tpl.StreamHeader(qw422016, "Alerts", navItems)
-//line app/vmalert/web.qtpl:125
+//line app/vmalert/web.qtpl:132
 	qw422016.N().S(`
     `)
-//line app/vmalert/web.qtpl:126
+//line app/vmalert/web.qtpl:133
 	if len(groupAlerts) > 0 {
-//line app/vmalert/web.qtpl:126
+//line app/vmalert/web.qtpl:133
 		qw422016.N().S(`
          <a class="btn btn-primary" role="button" onclick="collapseAll()">Collapse All</a>
          <a class="btn btn-primary" role="button" onclick="expandAll()">Expand All</a>
          `)
-//line app/vmalert/web.qtpl:129
+//line app/vmalert/web.qtpl:136
 		for _, ga := range groupAlerts {
-//line app/vmalert/web.qtpl:129
+//line app/vmalert/web.qtpl:136
 			qw422016.N().S(`
             `)
-//line app/vmalert/web.qtpl:130
+//line app/vmalert/web.qtpl:137
 			g := ga.Group
 
-//line app/vmalert/web.qtpl:130
+//line app/vmalert/web.qtpl:137
 			qw422016.N().S(`
             <div class="group-heading alert-danger" data-bs-target="rules-`)
-//line app/vmalert/web.qtpl:131
+//line app/vmalert/web.qtpl:138
 			qw422016.E().S(g.ID)
-//line app/vmalert/web.qtpl:131
+//line app/vmalert/web.qtpl:138
 			qw422016.N().S(`">
                 <span class="anchor" id="group-`)
-//line app/vmalert/web.qtpl:132
+//line app/vmalert/web.qtpl:139
 			qw422016.E().S(g.ID)
-//line app/vmalert/web.qtpl:132
+//line app/vmalert/web.qtpl:139
 			qw422016.N().S(`"></span>
                 <a href="#group-`)
-//line app/vmalert/web.qtpl:133
+//line app/vmalert/web.qtpl:140
 			qw422016.E().S(g.ID)
-//line app/vmalert/web.qtpl:133
+//line app/vmalert/web.qtpl:140
 			qw422016.N().S(`">`)
-//line app/vmalert/web.qtpl:133
+//line app/vmalert/web.qtpl:140
 			qw422016.E().S(g.Name)
-//line app/vmalert/web.qtpl:133
+//line app/vmalert/web.qtpl:140
 			if g.Type != "prometheus" {
-//line app/vmalert/web.qtpl:133
+//line app/vmalert/web.qtpl:140
 				qw422016.N().S(` (`)
-//line app/vmalert/web.qtpl:133
+//line app/vmalert/web.qtpl:140
 				qw422016.E().S(g.Type)
-//line app/vmalert/web.qtpl:133
+//line app/vmalert/web.qtpl:140
 				qw422016.N().S(`)`)
-//line app/vmalert/web.qtpl:133
+//line app/vmalert/web.qtpl:140
 			}
-//line app/vmalert/web.qtpl:133
+//line app/vmalert/web.qtpl:140
 			qw422016.N().S(`</a>
                 <span class="badge bg-danger" title="Number of active alerts">`)
-//line app/vmalert/web.qtpl:134
+//line app/vmalert/web.qtpl:141
 			qw422016.N().D(len(ga.Alerts))
-//line app/vmalert/web.qtpl:134
+//line app/vmalert/web.qtpl:141
 			qw422016.N().S(`</span>
                 <br>
                 <p class="fs-6 fw-lighter">`)
-//line app/vmalert/web.qtpl:136
+//line app/vmalert/web.qtpl:143
 			qw422016.E().S(g.File)
-//line app/vmalert/web.qtpl:136
+//line app/vmalert/web.qtpl:143
 			qw422016.N().S(`</p>
             </div>
             `)
-//line app/vmalert/web.qtpl:139
+//line app/vmalert/web.qtpl:146
 			var keys []string
 			alertsByRule := make(map[string][]*APIAlert)
 			for _, alert := range ga.Alerts {
@@ -518,20 +549,20 @@ func StreamListAlerts(qw422016 *qt422016.Writer, groupAlerts []GroupAlerts) {
 			}
 			sort.Strings(keys)
 
-//line app/vmalert/web.qtpl:148
+//line app/vmalert/web.qtpl:155
 			qw422016.N().S(`
             <div class="collapse" id="rules-`)
-//line app/vmalert/web.qtpl:149
+//line app/vmalert/web.qtpl:156
 			qw422016.E().S(g.ID)
-//line app/vmalert/web.qtpl:149
+//line app/vmalert/web.qtpl:156
 			qw422016.N().S(`">
                 `)
-//line app/vmalert/web.qtpl:150
+//line app/vmalert/web.qtpl:157
 			for _, ruleID := range keys {
-//line app/vmalert/web.qtpl:150
+//line app/vmalert/web.qtpl:157
 				qw422016.N().S(`
                     `)
-//line app/vmalert/web.qtpl:152
+//line app/vmalert/web.qtpl:159
 				defaultAR := alertsByRule[ruleID][0]
 				var labelKeys []string
 				for k := range defaultAR.Labels {
@@ -539,22 +570,22 @@ func StreamListAlerts(qw422016 *qt422016.Writer, groupAlerts []GroupAlerts) {
 				}
 				sort.Strings(labelKeys)
 
-//line app/vmalert/web.qtpl:158
+//line app/vmalert/web.qtpl:165
 				qw422016.N().S(`
                     <br>
                     <b>alert:</b> `)
-//line app/vmalert/web.qtpl:160
+//line app/vmalert/web.qtpl:167
 				qw422016.E().S(defaultAR.Name)
-//line app/vmalert/web.qtpl:160
+//line app/vmalert/web.qtpl:167
 				qw422016.N().S(` (`)
-//line app/vmalert/web.qtpl:160
+//line app/vmalert/web.qtpl:167
 				qw422016.N().D(len(alertsByRule[ruleID]))
-//line app/vmalert/web.qtpl:160
+//line app/vmalert/web.qtpl:167
 				qw422016.N().S(`)<br>
                     <b>expr:</b><code><pre>`)
-//line app/vmalert/web.qtpl:161
+//line app/vmalert/web.qtpl:168
 				qw422016.E().S(defaultAR.Expression)
-//line app/vmalert/web.qtpl:161
+//line app/vmalert/web.qtpl:168
 				qw422016.N().S(`</pre></code>
                     <table class="table table-striped table-hover table-sm">
                         <thead>
@@ -568,152 +599,152 @@ func StreamListAlerts(qw422016 *qt422016.Writer, groupAlerts []GroupAlerts) {
                         </thead>
                         <tbody>
                         `)
-//line app/vmalert/web.qtpl:173
+//line app/vmalert/web.qtpl:180
 				for _, ar := range alertsByRule[ruleID] {
-//line app/vmalert/web.qtpl:173
+//line app/vmalert/web.qtpl:180
 					qw422016.N().S(`
                             <tr>
                                 <td>
                                     `)
-//line app/vmalert/web.qtpl:176
+//line app/vmalert/web.qtpl:183
 					for _, k := range labelKeys {
-//line app/vmalert/web.qtpl:176
+//line app/vmalert/web.qtpl:183
 						qw422016.N().S(`
                                         <span class="ms-1 badge bg-primary">`)
-//line app/vmalert/web.qtpl:177
+//line app/vmalert/web.qtpl:184
 						qw422016.E().S(k)
-//line app/vmalert/web.qtpl:177
+//line app/vmalert/web.qtpl:184
 						qw422016.N().S(`=`)
-//line app/vmalert/web.qtpl:177
+//line app/vmalert/web.qtpl:184
 						qw422016.E().S(ar.Labels[k])
-//line app/vmalert/web.qtpl:177
+//line app/vmalert/web.qtpl:184
 						qw422016.N().S(`</span>
                                     `)
-//line app/vmalert/web.qtpl:178
+//line app/vmalert/web.qtpl:185
 					}
-//line app/vmalert/web.qtpl:178
+//line app/vmalert/web.qtpl:185
 					qw422016.N().S(`
                                 </td>
                                 <td><span class="badge `)
-//line app/vmalert/web.qtpl:180
+//line app/vmalert/web.qtpl:187
 					if ar.State == "firing" {
-//line app/vmalert/web.qtpl:180
+//line app/vmalert/web.qtpl:187
 						qw422016.N().S(`bg-danger`)
-//line app/vmalert/web.qtpl:180
+//line app/vmalert/web.qtpl:187
 					} else {
-//line app/vmalert/web.qtpl:180
+//line app/vmalert/web.qtpl:187
 						qw422016.N().S(` bg-warning text-dark`)
-//line app/vmalert/web.qtpl:180
+//line app/vmalert/web.qtpl:187
 					}
-//line app/vmalert/web.qtpl:180
+//line app/vmalert/web.qtpl:187
 					qw422016.N().S(`">`)
-//line app/vmalert/web.qtpl:180
+//line app/vmalert/web.qtpl:187
 					qw422016.E().S(ar.State)
-//line app/vmalert/web.qtpl:180
+//line app/vmalert/web.qtpl:187
 					qw422016.N().S(`</span></td>
                                 <td>`)
-//line app/vmalert/web.qtpl:181
+//line app/vmalert/web.qtpl:188
 					qw422016.E().S(ar.ActiveAt.Format("2006-01-02T15:04:05Z07:00"))
-//line app/vmalert/web.qtpl:181
+//line app/vmalert/web.qtpl:188
 					qw422016.N().S(`</td>
                                 <td>`)
-//line app/vmalert/web.qtpl:182
+//line app/vmalert/web.qtpl:189
 					qw422016.E().S(ar.Value)
-//line app/vmalert/web.qtpl:182
+//line app/vmalert/web.qtpl:189
 					qw422016.N().S(`</td>
                                 <td>
                                     <a href="/`)
-//line app/vmalert/web.qtpl:184
+//line app/vmalert/web.qtpl:191
 					qw422016.E().S(g.ID)
-//line app/vmalert/web.qtpl:184
+//line app/vmalert/web.qtpl:191
 					qw422016.N().S(`/`)
-//line app/vmalert/web.qtpl:184
+//line app/vmalert/web.qtpl:191
 					qw422016.E().S(ar.ID)
-//line app/vmalert/web.qtpl:184
+//line app/vmalert/web.qtpl:191
 					qw422016.N().S(`/status">Details</a>
                                 </td>
                             </tr>
                         `)
-//line app/vmalert/web.qtpl:187
+//line app/vmalert/web.qtpl:194
 				}
-//line app/vmalert/web.qtpl:187
+//line app/vmalert/web.qtpl:194
 				qw422016.N().S(`
                      </tbody>
                     </table>
                 `)
-//line app/vmalert/web.qtpl:190
+//line app/vmalert/web.qtpl:197
 			}
-//line app/vmalert/web.qtpl:190
+//line app/vmalert/web.qtpl:197
 			qw422016.N().S(`
             </div>
             <br>
         `)
-//line app/vmalert/web.qtpl:193
+//line app/vmalert/web.qtpl:200
 		}
-//line app/vmalert/web.qtpl:193
+//line app/vmalert/web.qtpl:200
 		qw422016.N().S(`
 
     `)
-//line app/vmalert/web.qtpl:195
+//line app/vmalert/web.qtpl:202
 	} else {
-//line app/vmalert/web.qtpl:195
+//line app/vmalert/web.qtpl:202
 		qw422016.N().S(`
         <div>
             <p>No items...</p>
         </div>
     `)
-//line app/vmalert/web.qtpl:199
+//line app/vmalert/web.qtpl:206
 	}
-//line app/vmalert/web.qtpl:199
+//line app/vmalert/web.qtpl:206
 	qw422016.N().S(`
 
     `)
-//line app/vmalert/web.qtpl:201
+//line app/vmalert/web.qtpl:208
 	tpl.StreamFooter(qw422016)
-//line app/vmalert/web.qtpl:201
+//line app/vmalert/web.qtpl:208
 	qw422016.N().S(`
 
 `)
-//line app/vmalert/web.qtpl:203
+//line app/vmalert/web.qtpl:210
 }
 
-//line app/vmalert/web.qtpl:203
+//line app/vmalert/web.qtpl:210
 func WriteListAlerts(qq422016 qtio422016.Writer, groupAlerts []GroupAlerts) {
-//line app/vmalert/web.qtpl:203
+//line app/vmalert/web.qtpl:210
 	qw422016 := qt422016.AcquireWriter(qq422016)
-//line app/vmalert/web.qtpl:203
+//line app/vmalert/web.qtpl:210
 	StreamListAlerts(qw422016, groupAlerts)
-//line app/vmalert/web.qtpl:203
+//line app/vmalert/web.qtpl:210
 	qt422016.ReleaseWriter(qw422016)
-//line app/vmalert/web.qtpl:203
+//line app/vmalert/web.qtpl:210
 }
 
-//line app/vmalert/web.qtpl:203
+//line app/vmalert/web.qtpl:210
 func ListAlerts(groupAlerts []GroupAlerts) string {
-//line app/vmalert/web.qtpl:203
+//line app/vmalert/web.qtpl:210
 	qb422016 := qt422016.AcquireByteBuffer()
-//line app/vmalert/web.qtpl:203
+//line app/vmalert/web.qtpl:210
 	WriteListAlerts(qb422016, groupAlerts)
-//line app/vmalert/web.qtpl:203
+//line app/vmalert/web.qtpl:210
 	qs422016 := string(qb422016.B)
-//line app/vmalert/web.qtpl:203
+//line app/vmalert/web.qtpl:210
 	qt422016.ReleaseByteBuffer(qb422016)
-//line app/vmalert/web.qtpl:203
+//line app/vmalert/web.qtpl:210
 	return qs422016
-//line app/vmalert/web.qtpl:203
+//line app/vmalert/web.qtpl:210
 }
 
-//line app/vmalert/web.qtpl:205
+//line app/vmalert/web.qtpl:212
 func StreamAlert(qw422016 *qt422016.Writer, alert *APIAlert) {
-//line app/vmalert/web.qtpl:205
+//line app/vmalert/web.qtpl:212
 	qw422016.N().S(`
     `)
-//line app/vmalert/web.qtpl:206
+//line app/vmalert/web.qtpl:213
 	tpl.StreamHeader(qw422016, "", navItems)
-//line app/vmalert/web.qtpl:206
+//line app/vmalert/web.qtpl:213
 	qw422016.N().S(`
     `)
-//line app/vmalert/web.qtpl:208
+//line app/vmalert/web.qtpl:215
 	var labelKeys []string
 	for k := range alert.Labels {
 		labelKeys = append(labelKeys, k)
@@ -726,28 +757,28 @@ func StreamAlert(qw422016 *qt422016.Writer, alert *APIAlert) {
 	}
 	sort.Strings(annotationKeys)
 
-//line app/vmalert/web.qtpl:219
+//line app/vmalert/web.qtpl:226
 	qw422016.N().S(`
     <div class="display-6 pb-3 mb-3">`)
-//line app/vmalert/web.qtpl:220
+//line app/vmalert/web.qtpl:227
 	qw422016.E().S(alert.Name)
-//line app/vmalert/web.qtpl:220
+//line app/vmalert/web.qtpl:227
 	qw422016.N().S(`<span class="ms-2 badge `)
-//line app/vmalert/web.qtpl:220
+//line app/vmalert/web.qtpl:227
 	if alert.State == "firing" {
-//line app/vmalert/web.qtpl:220
+//line app/vmalert/web.qtpl:227
 		qw422016.N().S(`bg-danger`)
-//line app/vmalert/web.qtpl:220
+//line app/vmalert/web.qtpl:227
 	} else {
-//line app/vmalert/web.qtpl:220
+//line app/vmalert/web.qtpl:227
 		qw422016.N().S(` bg-warning text-dark`)
-//line app/vmalert/web.qtpl:220
+//line app/vmalert/web.qtpl:227
 	}
-//line app/vmalert/web.qtpl:220
+//line app/vmalert/web.qtpl:227
 	qw422016.N().S(`">`)
-//line app/vmalert/web.qtpl:220
+//line app/vmalert/web.qtpl:227
 	qw422016.E().S(alert.State)
-//line app/vmalert/web.qtpl:220
+//line app/vmalert/web.qtpl:227
 	qw422016.N().S(`</span></div>
     <div class="container border-bottom p-2">
       <div class="row">
@@ -756,9 +787,9 @@ func StreamAlert(qw422016 *qt422016.Writer, alert *APIAlert) {
         </div>
         <div class="col">
           `)
-//line app/vmalert/web.qtpl:227
+//line app/vmalert/web.qtpl:234
 	qw422016.E().S(alert.ActiveAt.Format("2006-01-02T15:04:05Z07:00"))
-//line app/vmalert/web.qtpl:227
+//line app/vmalert/web.qtpl:234
 	qw422016.N().S(`
         </div>
       </div>
@@ -770,9 +801,9 @@ func StreamAlert(qw422016 *qt422016.Writer, alert *APIAlert) {
         </div>
         <div class="col">
           <code><pre>`)
-//line app/vmalert/web.qtpl:237
+//line app/vmalert/web.qtpl:244
 	qw422016.E().S(alert.Expression)
-//line app/vmalert/web.qtpl:237
+//line app/vmalert/web.qtpl:244
 	qw422016.N().S(`</pre></code>
         </div>
       </div>
@@ -784,23 +815,23 @@ func StreamAlert(qw422016 *qt422016.Writer, alert *APIAlert) {
         </div>
         <div class="col">
            `)
-//line app/vmalert/web.qtpl:247
+//line app/vmalert/web.qtpl:254
 	for _, k := range labelKeys {
-//line app/vmalert/web.qtpl:247
+//line app/vmalert/web.qtpl:254
 		qw422016.N().S(`
                 <span class="m-1 badge bg-primary">`)
-//line app/vmalert/web.qtpl:248
+//line app/vmalert/web.qtpl:255
 		qw422016.E().S(k)
-//line app/vmalert/web.qtpl:248
+//line app/vmalert/web.qtpl:255
 		qw422016.N().S(`=`)
-//line app/vmalert/web.qtpl:248
+//line app/vmalert/web.qtpl:255
 		qw422016.E().S(alert.Labels[k])
-//line app/vmalert/web.qtpl:248
+//line app/vmalert/web.qtpl:255
 		qw422016.N().S(`</span>
           `)
-//line app/vmalert/web.qtpl:249
+//line app/vmalert/web.qtpl:256
 	}
-//line app/vmalert/web.qtpl:249
+//line app/vmalert/web.qtpl:256
 	qw422016.N().S(`
         </div>
       </div>
@@ -812,24 +843,24 @@ func StreamAlert(qw422016 *qt422016.Writer, alert *APIAlert) {
         </div>
         <div class="col">
            `)
-//line app/vmalert/web.qtpl:259
+//line app/vmalert/web.qtpl:266
 	for _, k := range annotationKeys {
-//line app/vmalert/web.qtpl:259
+//line app/vmalert/web.qtpl:266
 		qw422016.N().S(`
                 <b>`)
-//line app/vmalert/web.qtpl:260
+//line app/vmalert/web.qtpl:267
 		qw422016.E().S(k)
-//line app/vmalert/web.qtpl:260
+//line app/vmalert/web.qtpl:267
 		qw422016.N().S(`:</b><br>
                 <p>`)
-//line app/vmalert/web.qtpl:261
+//line app/vmalert/web.qtpl:268
 		qw422016.E().S(alert.Annotations[k])
-//line app/vmalert/web.qtpl:261
+//line app/vmalert/web.qtpl:268
 		qw422016.N().S(`</p>
           `)
-//line app/vmalert/web.qtpl:262
+//line app/vmalert/web.qtpl:269
 	}
-//line app/vmalert/web.qtpl:262
+//line app/vmalert/web.qtpl:269
 	qw422016.N().S(`
         </div>
       </div>
@@ -841,49 +872,49 @@ func StreamAlert(qw422016 *qt422016.Writer, alert *APIAlert) {
         </div>
         <div class="col">
            <a target="_blank" href="/groups#group-`)
-//line app/vmalert/web.qtpl:272
+//line app/vmalert/web.qtpl:279
 	qw422016.E().S(alert.GroupID)
-//line app/vmalert/web.qtpl:272
+//line app/vmalert/web.qtpl:279
 	qw422016.N().S(`">`)
-//line app/vmalert/web.qtpl:272
+//line app/vmalert/web.qtpl:279
 	qw422016.E().S(alert.GroupID)
-//line app/vmalert/web.qtpl:272
+//line app/vmalert/web.qtpl:279
 	qw422016.N().S(`</a>
         </div>
       </div>
     </div>
     `)
-//line app/vmalert/web.qtpl:276
+//line app/vmalert/web.qtpl:283
 	tpl.StreamFooter(qw422016)
-//line app/vmalert/web.qtpl:276
+//line app/vmalert/web.qtpl:283
 	qw422016.N().S(`
 
 `)
-//line app/vmalert/web.qtpl:278
+//line app/vmalert/web.qtpl:285
 }
 
-//line app/vmalert/web.qtpl:278
+//line app/vmalert/web.qtpl:285
 func WriteAlert(qq422016 qtio422016.Writer, alert *APIAlert) {
-//line app/vmalert/web.qtpl:278
+//line app/vmalert/web.qtpl:285
 	qw422016 := qt422016.AcquireWriter(qq422016)
-//line app/vmalert/web.qtpl:278
+//line app/vmalert/web.qtpl:285
 	StreamAlert(qw422016, alert)
-//line app/vmalert/web.qtpl:278
+//line app/vmalert/web.qtpl:285
 	qt422016.ReleaseWriter(qw422016)
-//line app/vmalert/web.qtpl:278
+//line app/vmalert/web.qtpl:285
 }
 
-//line app/vmalert/web.qtpl:278
+//line app/vmalert/web.qtpl:285
 func Alert(alert *APIAlert) string {
-//line app/vmalert/web.qtpl:278
+//line app/vmalert/web.qtpl:285
 	qb422016 := qt422016.AcquireByteBuffer()
-//line app/vmalert/web.qtpl:278
+//line app/vmalert/web.qtpl:285
 	WriteAlert(qb422016, alert)
-//line app/vmalert/web.qtpl:278
+//line app/vmalert/web.qtpl:285
 	qs422016 := string(qb422016.B)
-//line app/vmalert/web.qtpl:278
+//line app/vmalert/web.qtpl:285
 	qt422016.ReleaseByteBuffer(qb422016)
-//line app/vmalert/web.qtpl:278
+//line app/vmalert/web.qtpl:285
 	return qs422016
-//line app/vmalert/web.qtpl:278
+//line app/vmalert/web.qtpl:285
 }
diff --git a/app/vmselect/promql/aggr.go b/app/vmselect/promql/aggr.go
index 627eaef90..78f549fb7 100644
--- a/app/vmselect/promql/aggr.go
+++ b/app/vmselect/promql/aggr.go
@@ -576,7 +576,7 @@ func aggrFuncCountValues(afa *aggrFuncArg) ([]*timeseries, error) {
 			var dst timeseries
 			dst.CopyFromShallowTimestamps(tss[0])
 			dst.MetricName.RemoveTag(dstLabel)
-			dst.MetricName.AddTag(dstLabel, strconv.FormatFloat(v, 'g', -1, 64))
+			dst.MetricName.AddTag(dstLabel, strconv.FormatFloat(v, 'f', -1, 64))
 			for i := range dst.Values {
 				count := 0
 				for _, ts := range tss {
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 405b28902..09d2a7df4 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -20,6 +20,9 @@ sort: 15
 * BUGFIX: properly handle queries with multiple filters matching empty labels such as `metric{label1=~"foo|",label2="bar|"}`. This filter must match the following series: `metric`, `metric{label1="foo"}`, `metric{label2="bar"}` and `metric{label1="foo",label2="bar"}`. Previously it was matching only `metric{label1="foo",label2="bar"}`. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1601).
 * BUGFIX: vmselect: reset connection timeouts after each request to `vmstorage`. This should prevent from `cannot read data in 0.000 seconds: unexpected EOF` warning in logs. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1562). Thanks to @mxlxm .
 * BUGFIX: keep metric name for time series returned from [rollup_candlestick](https://docs.victoriametrics.com/MetricsQL.html#rollup_candlestick) function, since the returned series don't change the meaning of the original series. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1600).
+* BUGFIX: use Prometheus-compatible label value formatting for [count_values](https://docs.victoriametrics.com/MetricsQL.html#count_values) function. Previously big values could be improperly formatted, which could break query results, which rely on label value such as `... on(label) count_values("label", ...)`.
+* BUGFIX: vmagent: properly use `https` scheme for wildcard TLS certificates for `role: ingress` targets in Kubernetes service discovery. See [this issue](https://github.com/prometheus/prometheus/issues/8902).
+* BUGFIX: vmagent: support host networking mode for `docker_sd_config`. See [this issue](https://github.com/prometheus/prometheus/issues/9116).
 
 
 ## [v1.65.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.65.0)
diff --git a/lib/promscrape/discovery/docker/api.go b/lib/promscrape/discovery/docker/api.go
index f2c76be3b..e09d063ab 100644
--- a/lib/promscrape/discovery/docker/api.go
+++ b/lib/promscrape/discovery/docker/api.go
@@ -13,8 +13,9 @@ import (
 var configMap = discoveryutils.NewConfigMap()
 
 type apiConfig struct {
-	client *discoveryutils.Client
-	port   int
+	client             *discoveryutils.Client
+	port               int
+	hostNetworkingHost string
 
 	// filtersQueryArg contains escaped `filters` query arg to add to each request to Docker Swarm API.
 	filtersQueryArg string
@@ -29,9 +30,14 @@ func getAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
 }
 
 func newAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
+	hostNetworkingHost := sdc.HostNetworkingHost
+	if hostNetworkingHost == "" {
+		hostNetworkingHost = "localhost"
+	}
 	cfg := &apiConfig{
-		port:            sdc.Port,
-		filtersQueryArg: getFiltersQueryArg(sdc.Filters),
+		port:               sdc.Port,
+		hostNetworkingHost: hostNetworkingHost,
+		filtersQueryArg:    getFiltersQueryArg(sdc.Filters),
 	}
 	if cfg.port == 0 {
 		cfg.port = 80
diff --git a/lib/promscrape/discovery/docker/container.go b/lib/promscrape/discovery/docker/container.go
index fd727f259..a8ff92f8b 100644
--- a/lib/promscrape/discovery/docker/container.go
+++ b/lib/promscrape/discovery/docker/container.go
@@ -39,7 +39,7 @@ func getContainersLabels(cfg *apiConfig) ([]map[string]string, error) {
 	if err != nil {
 		return nil, err
 	}
-	return addContainersLabels(containers, networkLabels, cfg.port), nil
+	return addContainersLabels(containers, networkLabels, cfg.port, cfg.hostNetworkingHost), nil
 }
 
 func getContainers(cfg *apiConfig) ([]container, error) {
@@ -58,7 +58,7 @@ func parseContainers(data []byte) ([]container, error) {
 	return containers, nil
 }
 
-func addContainersLabels(containers []container, networkLabels map[string]map[string]string, defaultPort int) []map[string]string {
+func addContainersLabels(containers []container, networkLabels map[string]map[string]string, defaultPort int, hostNetworkingHost string) []map[string]string {
 	var ms []map[string]string
 	for i := range containers {
 		c := &containers[i]
@@ -86,8 +86,12 @@ func addContainersLabels(containers []container, networkLabels map[string]map[st
 			}
 			if !added {
 				// Use fallback port when no exposed ports are available or if all are non-TCP
+				addr := hostNetworkingHost
+				if c.HostConfig.NetworkMode != "host" {
+					addr = discoveryutils.JoinHostPort(n.IPAddress, defaultPort)
+				}
 				m := map[string]string{
-					"__address__":              discoveryutils.JoinHostPort(n.IPAddress, defaultPort),
+					"__address__":              addr,
 					"__meta_docker_network_ip": n.IPAddress,
 				}
 				addCommonLabels(m, c, networkLabels[n.NetworkID])
diff --git a/lib/promscrape/discovery/docker/docker.go b/lib/promscrape/discovery/docker/docker.go
index e0589abb3..70fe913be 100644
--- a/lib/promscrape/discovery/docker/docker.go
+++ b/lib/promscrape/discovery/docker/docker.go
@@ -18,9 +18,10 @@ var SDCheckInterval = flag.Duration("promscrape.dockerSDCheckInterval", 30*time.
 //
 // See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#docker_sd_config
 type SDConfig struct {
-	Host    string   `yaml:"host"`
-	Port    int      `yaml:"port,omitempty"`
-	Filters []Filter `yaml:"filters,omitempty"`
+	Host               string   `yaml:"host"`
+	Port               int      `yaml:"port,omitempty"`
+	Filters            []Filter `yaml:"filters,omitempty"`
+	HostNetworkingHost string   `yaml:"host_networking_host,omitempty"`
 
 	HTTPClientConfig  promauth.HTTPClientConfig  `yaml:",inline"`
 	ProxyURL          proxy.URL                  `yaml:"proxy_url,omitempty"`
diff --git a/lib/promscrape/discovery/kubernetes/ingress.go b/lib/promscrape/discovery/kubernetes/ingress.go
index deedd32f2..71b398bd4 100644
--- a/lib/promscrape/discovery/kubernetes/ingress.go
+++ b/lib/promscrape/discovery/kubernetes/ingress.go
@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"fmt"
 	"io"
+	"strings"
 )
 
 func (ig *Ingress) key() string {
@@ -88,19 +89,10 @@ type HTTPIngressPath struct {
 //
 // See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#ingress
 func (ig *Ingress) getTargetLabels(gw *groupWatcher) []map[string]string {
-	tlsHosts := make(map[string]bool)
-	for _, tls := range ig.Spec.TLS {
-		for _, host := range tls.Hosts {
-			tlsHosts[host] = true
-		}
-	}
 	var ms []map[string]string
 	for _, r := range ig.Spec.Rules {
 		paths := getIngressRulePaths(r.HTTP.Paths)
-		scheme := "http"
-		if tlsHosts[r.Host] {
-			scheme = "https"
-		}
+		scheme := getSchemeForHost(r.Host, ig.Spec.TLS)
 		for _, path := range paths {
 			m := getLabelsForIngressPath(ig, scheme, r.Host, path)
 			ms = append(ms, m)
@@ -109,6 +101,33 @@ func (ig *Ingress) getTargetLabels(gw *groupWatcher) []map[string]string {
 	return ms
 }
 
+func getSchemeForHost(host string, tlss []IngressTLS) string {
+	for _, tls := range tlss {
+		for _, hostPattern := range tls.Hosts {
+			if matchesHostPattern(hostPattern, host) {
+				return "https"
+			}
+		}
+	}
+	return "http"
+}
+
+func matchesHostPattern(pattern, host string) bool {
+	if pattern == host {
+		return true
+	}
+	if !strings.HasPrefix(pattern, "*.") {
+		return false
+	}
+	pattern = pattern[len("*."):]
+	n := strings.IndexByte(host, '.')
+	if n < 0 {
+		return false
+	}
+	host = host[n+1:]
+	return pattern == host
+}
+
 func getLabelsForIngressPath(ig *Ingress, scheme, host, path string) map[string]string {
 	m := map[string]string{
 		"__address__":                      host,


Test patch:
diff --git a/app/vmselect/promql/exec_test.go b/app/vmselect/promql/exec_test.go
index 16e7ebadf..25f2613d3 100644
--- a/app/vmselect/promql/exec_test.go
+++ b/app/vmselect/promql/exec_test.go
@@ -6662,6 +6662,37 @@ func TestExecSuccess(t *testing.T) {
 		resultExpected := []netstorage.Result{r1, r2, r3, r4}
 		f(q, resultExpected)
 	})
+	t.Run(`count_values_big_numbers`, func(t *testing.T) {
+		t.Parallel()
+		q := `sort_by_label(
+			count_values("xxx", (alias(772424014, "first"), alias(772424230, "second"))),
+			"xxx"
+		)`
+		r1 := netstorage.Result{
+			MetricName: metricNameExpected,
+			Values:     []float64{1, 1, 1, 1, 1, 1},
+			Timestamps: timestampsExpected,
+		}
+		r1.MetricName.Tags = []storage.Tag{
+			{
+				Key:   []byte("xxx"),
+				Value: []byte("772424014"),
+			},
+		}
+		r2 := netstorage.Result{
+			MetricName: metricNameExpected,
+			Values:     []float64{1, 1, 1, 1, 1, 1},
+			Timestamps: timestampsExpected,
+		}
+		r2.MetricName.Tags = []storage.Tag{
+			{
+				Key:   []byte("xxx"),
+				Value: []byte("772424230"),
+			},
+		}
+		resultExpected := []netstorage.Result{r1, r2}
+		f(q, resultExpected)
+	})
 	t.Run(`count_values`, func(t *testing.T) {
 		t.Parallel()
 		q := `count_values("xxx", label_set(10, "foo", "bar") or label_set(time()/100, "foo", "bar", "baz", "xx"))`
diff --git a/lib/promscrape/discovery/docker/container_test.go b/lib/promscrape/discovery/docker/container_test.go
index 62fe342d9..95785a841 100644
--- a/lib/promscrape/discovery/docker/container_test.go
+++ b/lib/promscrape/discovery/docker/container_test.go
@@ -317,6 +317,118 @@ func Test_addContainerLabels(t *testing.T) {
 		want    []map[string]string
 		wantErr bool
 	}{
+		{
+			name: "NetworkMode!=host",
+			c: container{
+				ID:    "90bc3b31aa13da5c0b11af2e228d54b38428a84e25d4e249ae9e9c95e51a0700",
+				Names: []string{"/crow-server"},
+				Labels: map[string]string{
+					"com.docker.compose.config-hash":      "c9f0bd5bb31921f94cff367d819a30a0cc08d4399080897a6c5cd74b983156ec",
+					"com.docker.compose.container-number": "1",
+					"com.docker.compose.oneoff":           "False",
+					"com.docker.compose.project":          "crowserver",
+					"com.docker.compose.service":          "crow-server",
+					"com.docker.compose.version":          "1.11.2",
+				},
+				HostConfig: struct {
+					NetworkMode string
+				}{
+					NetworkMode: "bridge",
+				},
+				NetworkSettings: struct {
+					Networks map[string]struct {
+						IPAddress string
+						NetworkID string
+					}
+				}{
+					Networks: map[string]struct {
+						IPAddress string
+						NetworkID string
+					}{
+						"host": {
+							IPAddress: "172.17.0.2",
+							NetworkID: "1dd8d1a8bef59943345c7231d7ce8268333ff5a8c5b3c94881e6b4742b447634",
+						},
+					},
+				},
+			},
+			want: []map[string]string{
+				{
+					"__address__":                "172.17.0.2:8012",
+					"__meta_docker_container_id": "90bc3b31aa13da5c0b11af2e228d54b38428a84e25d4e249ae9e9c95e51a0700",
+					"__meta_docker_container_label_com_docker_compose_config_hash":      "c9f0bd5bb31921f94cff367d819a30a0cc08d4399080897a6c5cd74b983156ec",
+					"__meta_docker_container_label_com_docker_compose_container_number": "1",
+					"__meta_docker_container_label_com_docker_compose_oneoff":           "False",
+					"__meta_docker_container_label_com_docker_compose_project":          "crowserver",
+					"__meta_docker_container_label_com_docker_compose_service":          "crow-server",
+					"__meta_docker_container_label_com_docker_compose_version":          "1.11.2",
+					"__meta_docker_container_name":                                      "/crow-server",
+					"__meta_docker_container_network_mode":                              "bridge",
+					"__meta_docker_network_id":                                          "1dd8d1a8bef59943345c7231d7ce8268333ff5a8c5b3c94881e6b4742b447634",
+					"__meta_docker_network_ingress":                                     "false",
+					"__meta_docker_network_internal":                                    "false",
+					"__meta_docker_network_ip":                                          "172.17.0.2",
+					"__meta_docker_network_name":                                        "bridge",
+					"__meta_docker_network_scope":                                       "local",
+				},
+			},
+		},
+		{
+			name: "NetworkMode=host",
+			c: container{
+				ID:    "90bc3b31aa13da5c0b11af2e228d54b38428a84e25d4e249ae9e9c95e51a0700",
+				Names: []string{"/crow-server"},
+				Labels: map[string]string{
+					"com.docker.compose.config-hash":      "c9f0bd5bb31921f94cff367d819a30a0cc08d4399080897a6c5cd74b983156ec",
+					"com.docker.compose.container-number": "1",
+					"com.docker.compose.oneoff":           "False",
+					"com.docker.compose.project":          "crowserver",
+					"com.docker.compose.service":          "crow-server",
+					"com.docker.compose.version":          "1.11.2",
+				},
+				HostConfig: struct {
+					NetworkMode string
+				}{
+					NetworkMode: "host",
+				},
+				NetworkSettings: struct {
+					Networks map[string]struct {
+						IPAddress string
+						NetworkID string
+					}
+				}{
+					Networks: map[string]struct {
+						IPAddress string
+						NetworkID string
+					}{
+						"host": {
+							IPAddress: "172.17.0.2",
+							NetworkID: "1dd8d1a8bef59943345c7231d7ce8268333ff5a8c5b3c94881e6b4742b447634",
+						},
+					},
+				},
+			},
+			want: []map[string]string{
+				{
+					"__address__":                "foobar",
+					"__meta_docker_container_id": "90bc3b31aa13da5c0b11af2e228d54b38428a84e25d4e249ae9e9c95e51a0700",
+					"__meta_docker_container_label_com_docker_compose_config_hash":      "c9f0bd5bb31921f94cff367d819a30a0cc08d4399080897a6c5cd74b983156ec",
+					"__meta_docker_container_label_com_docker_compose_container_number": "1",
+					"__meta_docker_container_label_com_docker_compose_oneoff":           "False",
+					"__meta_docker_container_label_com_docker_compose_project":          "crowserver",
+					"__meta_docker_container_label_com_docker_compose_service":          "crow-server",
+					"__meta_docker_container_label_com_docker_compose_version":          "1.11.2",
+					"__meta_docker_container_name":                                      "/crow-server",
+					"__meta_docker_container_network_mode":                              "host",
+					"__meta_docker_network_id":                                          "1dd8d1a8bef59943345c7231d7ce8268333ff5a8c5b3c94881e6b4742b447634",
+					"__meta_docker_network_ingress":                                     "false",
+					"__meta_docker_network_internal":                                    "false",
+					"__meta_docker_network_ip":                                          "172.17.0.2",
+					"__meta_docker_network_name":                                        "bridge",
+					"__meta_docker_network_scope":                                       "local",
+				},
+			},
+		},
 		{
 			name: "get labels from a container",
 			c: container{
@@ -391,7 +503,7 @@ func Test_addContainerLabels(t *testing.T) {
 
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			labelsMap := addContainersLabels([]container{tt.c}, networkLabels, 80)
+			labelsMap := addContainersLabels([]container{tt.c}, networkLabels, 8012, "foobar")
 			if (err != nil) != tt.wantErr {
 				t.Errorf("addContainersLabels() error = %v, wantErr %v", err, tt.wantErr)
 				return
diff --git a/lib/promscrape/discovery/kubernetes/ingress_test.go b/lib/promscrape/discovery/kubernetes/ingress_test.go
index 149660b80..87a734d05 100644
--- a/lib/promscrape/discovery/kubernetes/ingress_test.go
+++ b/lib/promscrape/discovery/kubernetes/ingress_test.go
@@ -8,6 +8,26 @@ import (
 	"github.com/VictoriaMetrics/VictoriaMetrics/lib/promscrape/discoveryutils"
 )
 
+func TestMatchesHostPattern(t *testing.T) {
+	f := func(pattern, host string, resultExpected bool) {
+		t.Helper()
+		result := matchesHostPattern(pattern, host)
+		if result != resultExpected {
+			t.Fatalf("unexpected result for matchesHostPattern(%q, %q); got %v; want %v", pattern, host, result, resultExpected)
+		}
+	}
+	f("", "", true)
+	f("", "foo", false)
+	f("foo", "", false)
+	f("localhost", "localhost", true)
+	f("localhost", "localhost2", false)
+	f("*.foo", "bar", false)
+	f("foo.bar", "foo.bar", true)
+	f("foo.baz", "foo.bar", false)
+	f("a.x.yyy", "b.x.yyy", false)
+	f("*.x.yyy", "b.x.yyy", true)
+}
+
 func TestParseIngressListFailure(t *testing.T) {
 	f := func(s string) {
 		t.Helper()