mirror of
https://github.com/zalando-incubator/kube-metrics-adapter.git
synced 2024-12-22 19:16:06 +00:00
fixes for ZMON client
Changes: - only add group_by "key" if key is provided - remove deprecated aggregators "dev" and "first" - add X-Attribution header for query attribution Signed-off-by: ☃ pitr <peter.vernigorov@zalando.de>
This commit is contained in:
parent
eefd5ef512
commit
1d4beab7a4
@ -15,9 +15,7 @@ var (
|
|||||||
// https://kairosdb.github.io/docs/build/html/restapi/Aggregators.html
|
// https://kairosdb.github.io/docs/build/html/restapi/Aggregators.html
|
||||||
validAggregators = map[string]struct{}{
|
validAggregators = map[string]struct{}{
|
||||||
"avg": struct{}{},
|
"avg": struct{}{},
|
||||||
"dev": struct{}{},
|
|
||||||
"count": struct{}{},
|
"count": struct{}{},
|
||||||
"first": struct{}{},
|
|
||||||
"last": struct{}{},
|
"last": struct{}{},
|
||||||
"max": struct{}{},
|
"max": struct{}{},
|
||||||
"min": struct{}{},
|
"min": struct{}{},
|
||||||
@ -112,17 +110,10 @@ func (c *Client) Query(checkID int, key string, tags map[string]string, aggregat
|
|||||||
StartRelative: durationToSampling(duration),
|
StartRelative: durationToSampling(duration),
|
||||||
Metrics: []metric{
|
Metrics: []metric{
|
||||||
{
|
{
|
||||||
Name: fmt.Sprintf("zmon.check.%d", checkID),
|
Name: fmt.Sprintf("zmon.check.%d", checkID),
|
||||||
Limit: 10000, // maximum limit of ZMON
|
Limit: 10000, // maximum limit of ZMON
|
||||||
Tags: tagsSlice,
|
Tags: tagsSlice,
|
||||||
GroupBy: []tagGroup{
|
GroupBy: []tagGroup{},
|
||||||
{
|
|
||||||
Name: "tag",
|
|
||||||
Tags: []string{
|
|
||||||
"key",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Aggregators: make([]aggregator, 0, len(aggregators)),
|
Aggregators: make([]aggregator, 0, len(aggregators)),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -142,6 +133,10 @@ func (c *Client) Query(checkID int, key string, tags map[string]string, aggregat
|
|||||||
// add key to query if defined
|
// add key to query if defined
|
||||||
if key != "" {
|
if key != "" {
|
||||||
query.Metrics[0].Tags["key"] = []string{key}
|
query.Metrics[0].Tags["key"] = []string{key}
|
||||||
|
query.Metrics[0].GroupBy = append(query.Metrics[0].GroupBy, tagGroup{
|
||||||
|
Name: "tag",
|
||||||
|
Tags: []string{"key"},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := json.Marshal(&query)
|
body, err := json.Marshal(&query)
|
||||||
@ -158,6 +153,7 @@ func (c *Client) Query(checkID int, key string, tags map[string]string, aggregat
|
|||||||
|
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
req.Header.Set("Accept", "application/json")
|
req.Header.Set("Accept", "application/json")
|
||||||
|
req.Header.Set("X-Attribution", fmt.Sprintf("kube-metrics-adapter/%d", checkID))
|
||||||
|
|
||||||
resp, err := c.http.Do(req)
|
resp, err := c.http.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user