mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-27 22:49:40 -08:00
Merge pull request #1033 from dln/serverset-shard
serverset discovery: extract shard number from serverset data
This commit is contained in:
commit
facf60e033
|
@ -17,6 +17,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -36,12 +37,14 @@ const (
|
||||||
serversetStatusLabel = serversetLabelPrefix + "status"
|
serversetStatusLabel = serversetLabelPrefix + "status"
|
||||||
serversetPathLabel = serversetLabelPrefix + "path"
|
serversetPathLabel = serversetLabelPrefix + "path"
|
||||||
serversetEndpointLabelPrefix = serversetLabelPrefix + "endpoint"
|
serversetEndpointLabelPrefix = serversetLabelPrefix + "endpoint"
|
||||||
|
serversetShardLabel = serversetLabelPrefix + "shard"
|
||||||
)
|
)
|
||||||
|
|
||||||
type serversetMember struct {
|
type serversetMember struct {
|
||||||
ServiceEndpoint serversetEndpoint
|
ServiceEndpoint serversetEndpoint
|
||||||
AdditionalEndpoints map[string]serversetEndpoint
|
AdditionalEndpoints map[string]serversetEndpoint
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
Shard int `json:"shard"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type serversetEndpoint struct {
|
type serversetEndpoint struct {
|
||||||
|
@ -168,6 +171,7 @@ func parseServersetMember(data []byte, path string) (*model.LabelSet, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
labels[serversetStatusLabel] = model.LabelValue(member.Status)
|
labels[serversetStatusLabel] = model.LabelValue(member.Status)
|
||||||
|
labels[serversetShardLabel] = model.LabelValue(strconv.Itoa(member.Shard))
|
||||||
|
|
||||||
return &labels, nil
|
return &labels, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue