mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmalert/datasource/graphite: allow overriding "from" parameter for datasource queries (#4687)
* app/vmalert/datasource/graphite: allow overriding "from" parameter for datasource queries Fixes construction of URL parameters for graphite render to allow overriding "from" parameter. See: https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4685 Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com> * app/vmalert/datasource/graphite: update flow for building URL parameters Makes flow of building URL parameters same as Prometheus datasource has: 1) Setting all default values 2) Merging those values with provided `extraParams` Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com> * Update docs/CHANGELOG.md Co-authored-by: Roman Khavronenko <roman@victoriametrics.com> --------- Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com> Co-authored-by: Roman Khavronenko <roman@victoriametrics.com>
This commit is contained in:
parent
1a864b60c2
commit
866b150f0f
3 changed files with 26 additions and 9 deletions
|
@ -54,6 +54,16 @@ func (s *VMStorage) setGraphiteReqParams(r *http.Request, query string, timestam
|
||||||
}
|
}
|
||||||
r.URL.Path += graphitePath
|
r.URL.Path += graphitePath
|
||||||
q := r.URL.Query()
|
q := r.URL.Query()
|
||||||
|
from := "-5min"
|
||||||
|
if s.lookBack > 0 {
|
||||||
|
lookBack := timestamp.Add(-s.lookBack)
|
||||||
|
from = strconv.FormatInt(lookBack.Unix(), 10)
|
||||||
|
}
|
||||||
|
q.Set("from", from)
|
||||||
|
q.Set("format", "json")
|
||||||
|
q.Set("target", query)
|
||||||
|
q.Set("until", "now")
|
||||||
|
|
||||||
for k, vs := range s.extraParams {
|
for k, vs := range s.extraParams {
|
||||||
if q.Has(k) { // extraParams are prior to params in URL
|
if q.Has(k) { // extraParams are prior to params in URL
|
||||||
q.Del(k)
|
q.Del(k)
|
||||||
|
@ -62,14 +72,6 @@ func (s *VMStorage) setGraphiteReqParams(r *http.Request, query string, timestam
|
||||||
q.Add(k, v)
|
q.Add(k, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
q.Set("format", "json")
|
|
||||||
q.Set("target", query)
|
|
||||||
from := "-5min"
|
|
||||||
if s.lookBack > 0 {
|
|
||||||
lookBack := timestamp.Add(-s.lookBack)
|
|
||||||
from = strconv.FormatInt(lookBack.Unix(), 10)
|
|
||||||
}
|
|
||||||
q.Set("from", from)
|
|
||||||
q.Set("until", "now")
|
|
||||||
r.URL.RawQuery = q.Encode()
|
r.URL.RawQuery = q.Encode()
|
||||||
}
|
}
|
||||||
|
|
|
@ -611,6 +611,20 @@ func TestRequestParams(t *testing.T) {
|
||||||
checkEqualString(t, exp, r.URL.RawQuery)
|
checkEqualString(t, exp, r.URL.RawQuery)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"graphite extra params allows to override from",
|
||||||
|
false,
|
||||||
|
&VMStorage{
|
||||||
|
dataSourceType: datasourceGraphite,
|
||||||
|
extraParams: url.Values{
|
||||||
|
"from": {"-10m"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
func(t *testing.T, r *http.Request) {
|
||||||
|
exp := fmt.Sprintf("format=json&from=-10m&target=%s&until=now", query)
|
||||||
|
checkEqualString(t, exp, r.URL.RawQuery)
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
|
|
|
@ -47,6 +47,7 @@ The following `tip` changes can be tested by building VictoriaMetrics components
|
||||||
* FEATUTE: [vmalert](https://docs.victoriametrics.com/vmalert.html): allow disabling of `step` param attached to [instant queries](https://docs.victoriametrics.com/keyConcepts.html#instant-query). This might be useful for using vmalert with datasources that to not support this param, unlike VictoriaMetrics. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4573) for details.
|
* FEATUTE: [vmalert](https://docs.victoriametrics.com/vmalert.html): allow disabling of `step` param attached to [instant queries](https://docs.victoriametrics.com/keyConcepts.html#instant-query). This might be useful for using vmalert with datasources that to not support this param, unlike VictoriaMetrics. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4573) for details.
|
||||||
* FEATUTE: [vmalert](https://docs.victoriametrics.com/vmalert.html): support option for "blackholing" alerting notifications if `-notifier.blackhole` cmd-line flag is set. Enable this flag if you want vmalert to evaluate alerting rules without sending any notifications to external receivers (eg. alertmanager). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4122) for details. Thanks to @venkatbvc for [the pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4639).
|
* FEATUTE: [vmalert](https://docs.victoriametrics.com/vmalert.html): support option for "blackholing" alerting notifications if `-notifier.blackhole` cmd-line flag is set. Enable this flag if you want vmalert to evaluate alerting rules without sending any notifications to external receivers (eg. alertmanager). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4122) for details. Thanks to @venkatbvc for [the pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4639).
|
||||||
* FEATURE: [vmalert](https://docs.victoriametrics.com/vmalert.html): add unit test for alerting and recording rules, see more [details](https://docs.victoriametrics.com/vmalert.html#unit-testing-for-rules) here. Thanks to @Haleygo for [the pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4596).
|
* FEATURE: [vmalert](https://docs.victoriametrics.com/vmalert.html): add unit test for alerting and recording rules, see more [details](https://docs.victoriametrics.com/vmalert.html#unit-testing-for-rules) here. Thanks to @Haleygo for [the pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4596).
|
||||||
|
* FEATURE: [vmalert](https://docs.victoriametrics.com/vmalert.html): allow overriding default GET params for rules with `graphite` datasource type, in the same way as it happens for `prometheus` type. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4685).
|
||||||
* FEATURE: [vmauth](https://docs.victoriametrics.com/vmauth.html): expose `vmauth_user_request_duration_seconds` and `vmauth_unauthorized_user_request_duration_seconds` summary metrics for measuring requests latency per user.
|
* FEATURE: [vmauth](https://docs.victoriametrics.com/vmauth.html): expose `vmauth_user_request_duration_seconds` and `vmauth_unauthorized_user_request_duration_seconds` summary metrics for measuring requests latency per user.
|
||||||
* FEATURE: [vmbackup](https://docs.victoriametrics.com/vmbackup.html): show backup progress percentage in log during backup uploading. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4460).
|
* FEATURE: [vmbackup](https://docs.victoriametrics.com/vmbackup.html): show backup progress percentage in log during backup uploading. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4460).
|
||||||
* FEATURE: [vmrestore](https://docs.victoriametrics.com/vmrestore.html): show restoring progress percentage in log during backup downloading. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4460).
|
* FEATURE: [vmrestore](https://docs.victoriametrics.com/vmrestore.html): show restoring progress percentage in log during backup downloading. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4460).
|
||||||
|
|
Loading…
Reference in a new issue