mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/promscrape, vmagent: fix path to files (#2801)
vmagent: respect `-pathPrefix` flag for static files and links
This commit is contained in:
parent
4d9715f5a8
commit
0a8e35835c
4 changed files with 22 additions and 14 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
@ -158,6 +159,11 @@ func main() {
|
|||
}
|
||||
|
||||
func requestHandler(w http.ResponseWriter, r *http.Request) bool {
|
||||
pathPrefix := httpserver.GetPathPrefix()
|
||||
if pathPrefix == "" {
|
||||
pathPrefix = "/"
|
||||
}
|
||||
|
||||
if r.URL.Path == "/" {
|
||||
if r.Method != "GET" {
|
||||
return false
|
||||
|
@ -167,24 +173,24 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool {
|
|||
fmt.Fprintf(w, "See docs at <a href='https://docs.victoriametrics.com/vmagent.html'>https://docs.victoriametrics.com/vmagent.html</a></br>")
|
||||
fmt.Fprintf(w, "Useful endpoints:</br>")
|
||||
httpserver.WriteAPIHelp(w, [][2]string{
|
||||
{"targets", "status for discovered active targets"},
|
||||
{"service-discovery", "labels before and after relabeling for discovered targets"},
|
||||
{"api/v1/targets", "advanced information about discovered targets in JSON format"},
|
||||
{"config", "-promscrape.config contents"},
|
||||
{"metrics", "available service metrics"},
|
||||
{"flags", "command-line flags"},
|
||||
{"-/reload", "reload configuration"},
|
||||
{path.Join(pathPrefix, "targets"), "status for discovered active targets"},
|
||||
{path.Join(pathPrefix, "service-discovery"), "labels before and after relabeling for discovered targets"},
|
||||
{path.Join(pathPrefix, "api/v1/targets"), "advanced information about discovered targets in JSON format"},
|
||||
{path.Join(pathPrefix, "config"), "-promscrape.config contents"},
|
||||
{path.Join(pathPrefix, "metrics"), "available service metrics"},
|
||||
{path.Join(pathPrefix, "flags"), "command-line flags"},
|
||||
{path.Join(pathPrefix, "-/reload"), "reload configuration"},
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
path := strings.Replace(r.URL.Path, "//", "/", -1)
|
||||
if strings.HasPrefix(path, "datadog/") {
|
||||
updatedPath := strings.Replace(r.URL.Path, "//", "/", -1)
|
||||
if strings.HasPrefix(updatedPath, "datadog/") {
|
||||
// Trim suffix from paths starting from /datadog/ in order to support legacy DataDog agent.
|
||||
// See https://github.com/VictoriaMetrics/VictoriaMetrics/pull/2670
|
||||
path = strings.TrimSuffix(path, "/")
|
||||
updatedPath = strings.TrimSuffix(updatedPath, "/")
|
||||
}
|
||||
switch path {
|
||||
switch updatedPath {
|
||||
case "/api/v1/write":
|
||||
prometheusWriteRequests.Inc()
|
||||
if err := promremotewrite.InsertHandler(nil, r); err != nil {
|
||||
|
@ -350,7 +356,7 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool {
|
|||
return true
|
||||
}
|
||||
if remotewrite.MultitenancyEnabled() {
|
||||
return processMultitenantRequest(w, r, path)
|
||||
return processMultitenantRequest(w, r, updatedPath)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ scrape_configs:
|
|||
* BUGFIX: limit max memory occupied by the cache, which stores parsed regular expressions. Previously too long regular expressions passed in [MetricsQL queries](https://docs.victoriametrics.com/MetricsQL.html) could result in big amounts of used memory (e.g. multiple of gigabytes). Now the max cache size for parsed regexps is limited to a a few megabytes.
|
||||
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): make sure that [stale markers](https://docs.victoriametrics.com/vmagent.html#prometheus-staleness-markers) are generated with the actual timestamp when unsuccessful scrape occurs. This should prevent from possible time series overlap on scrape target restart in dynmaic envirnoments such as Kubernetes.
|
||||
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): properly reload changed `-promscrape.config` file when `-promscrape.configCheckInterval` option is set. The changed config file wasn't reloaded in this case since [v1.69.0](#v1690). See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/2786). Thanks to @ttyv for the fix.
|
||||
* BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): respect `-http.pathPrefix` for static and relative links in vmagent's UI. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2799)
|
||||
* BUGFIX: [VictoriaMetrics cluster](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html): assume that the response is complete if `-search.denyPartialResponse` is enabled and up to `-replicationFactor - 1` `vmstorage` nodes are unavailable. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1767).
|
||||
* BUGFIX: [vmselect](https://docs.victoriametrics.com/#vmselect): update `vm_partial_results_total` metric labels to be consistent with `vm_requests_total` labels.
|
||||
|
||||
|
|
|
@ -96,9 +96,10 @@
|
|||
{% endfunc %}
|
||||
|
||||
{% func commonHeader() %}
|
||||
{% code pathPrefix := httpserver.GetPathPrefix() %}
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link href="static/css/bootstrap.min.css" rel="stylesheet" />
|
||||
<link href="{%s pathPrefix %}/static/css/bootstrap.min.css" rel="stylesheet" />
|
||||
{% endfunc %}
|
||||
|
||||
{% func navbar() %}
|
||||
|
|
|
@ -323,7 +323,7 @@ func ServiceDiscoveryResponse(tsr *targetsStatusResult, filter *requestFilter) s
|
|||
//line lib/promscrape/targetstatus.qtpl:98
|
||||
func streamcommonHeader(qw422016 *qt422016.Writer) {
|
||||
//line lib/promscrape/targetstatus.qtpl:98
|
||||
qw422016.N().S(`<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><link href="static/css/bootstrap.min.css" rel="stylesheet" />`)
|
||||
qw422016.N().S(`<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><link href="/static/css/bootstrap.min.css" rel="stylesheet" />`)
|
||||
//line lib/promscrape/targetstatus.qtpl:102
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue