mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-20 23:39:48 +01:00
lib/promscrape/discovery/consul: add __meta_consul_partition
label in the same way as Prometheus does
See https://github.com/prometheus/prometheus/pull/11482
This commit is contained in:
parent
9108a1d33f
commit
abf7e4e72f
@ -15,6 +15,8 @@ The following tip changes can be tested by building VictoriaMetrics components f
|
|||||||
|
|
||||||
## tip
|
## tip
|
||||||
|
|
||||||
|
* FEATURE: [vmagent](https://docs.victoriametrics.com/vmagent.html): expose `__meta_consul_partition` label for targets discovered via [consul_sd_configs](https://docs.victoriametrics.com/sd_configs.html#consul_sd_configs) in the same way as [Prometheus 2.40 does](https://github.com/prometheus/prometheus/pull/11482).
|
||||||
|
|
||||||
* BUGFIX: properly register new time series in per-day inverted index if they were ingested during the last 10 seconds of the day. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3309). Thanks to @lmarszal for the bugreport and for the [initial fix](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/3320).
|
* BUGFIX: properly register new time series in per-day inverted index if they were ingested during the last 10 seconds of the day. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3309). Thanks to @lmarszal for the bugreport and for the [initial fix](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/3320).
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,9 +112,15 @@ scrape_configs:
|
|||||||
# datacenter: "..."
|
# datacenter: "..."
|
||||||
|
|
||||||
# namespace is an optional Consul namespace.
|
# namespace is an optional Consul namespace.
|
||||||
|
# See https://developer.hashicorp.com/consul/docs/enterprise/namespaces
|
||||||
# If the namespace isn't specified, then it is read from CONSUL_NAMESPACE environment var.
|
# If the namespace isn't specified, then it is read from CONSUL_NAMESPACE environment var.
|
||||||
# namespace: "..."
|
# namespace: "..."
|
||||||
|
|
||||||
|
# partition is an optional Consul partition.
|
||||||
|
# See https://developer.hashicorp.com/consul/docs/enterprise/admin-partitions
|
||||||
|
# If partition isn't specified, then the default partition is used.
|
||||||
|
# partition: "..."
|
||||||
|
|
||||||
# scheme is an optional scheme (http or https) to use for connecting to Consul server.
|
# scheme is an optional scheme (http or https) to use for connecting to Consul server.
|
||||||
# By default http scheme is used.
|
# By default http scheme is used.
|
||||||
# scheme: "..."
|
# scheme: "..."
|
||||||
@ -151,7 +157,9 @@ The following meta labels are available on discovered targets during [relabeling
|
|||||||
* `__meta_consul_dc`: the datacenter name for the target
|
* `__meta_consul_dc`: the datacenter name for the target
|
||||||
* `__meta_consul_health`: the health status of the service
|
* `__meta_consul_health`: the health status of the service
|
||||||
* `__meta_consul_metadata_<key>`: each node metadata key value of the target
|
* `__meta_consul_metadata_<key>`: each node metadata key value of the target
|
||||||
|
* `__meta_consul_namespace`: namespace of the service - see [namespace docs](https://developer.hashicorp.com/consul/docs/enterprise/namespaces)
|
||||||
* `__meta_consul_node`: the node name defined for the target
|
* `__meta_consul_node`: the node name defined for the target
|
||||||
|
* `__meta_consul_partition`: partition of the service - see [partition docs](https://developer.hashicorp.com/consul/docs/enterprise/admin-partitions)
|
||||||
* `__meta_consul_service_address`: the service address of the target
|
* `__meta_consul_service_address`: the service address of the target
|
||||||
* `__meta_consul_service_id`: the service ID of the target
|
* `__meta_consul_service_id`: the service ID of the target
|
||||||
* `__meta_consul_service_metadata_<key>`: each service metadata key value of the target
|
* `__meta_consul_service_metadata_<key>`: each service metadata key value of the target
|
||||||
|
@ -14,9 +14,14 @@ type SDConfig struct {
|
|||||||
Server string `yaml:"server,omitempty"`
|
Server string `yaml:"server,omitempty"`
|
||||||
Token *promauth.Secret `yaml:"token"`
|
Token *promauth.Secret `yaml:"token"`
|
||||||
Datacenter string `yaml:"datacenter"`
|
Datacenter string `yaml:"datacenter"`
|
||||||
|
|
||||||
// Namespace only supported at enterprise consul.
|
// Namespace only supported at enterprise consul.
|
||||||
// https://www.consul.io/docs/enterprise/namespaces
|
// https://www.consul.io/docs/enterprise/namespaces
|
||||||
Namespace string `yaml:"namespace,omitempty"`
|
Namespace string `yaml:"namespace,omitempty"`
|
||||||
|
// Partition only supported at enteprise consul.
|
||||||
|
// https://developer.hashicorp.com/consul/docs/enterprise/admin-partitions
|
||||||
|
Partition string `yaml:"partition,omitempty"`
|
||||||
|
|
||||||
Scheme string `yaml:"scheme,omitempty"`
|
Scheme string `yaml:"scheme,omitempty"`
|
||||||
Username string `yaml:"username"`
|
Username string `yaml:"username"`
|
||||||
Password *promauth.Secret `yaml:"password"`
|
Password *promauth.Secret `yaml:"password"`
|
||||||
|
@ -38,6 +38,7 @@ type Service struct {
|
|||||||
Service string
|
Service string
|
||||||
Address string
|
Address string
|
||||||
Namespace string
|
Namespace string
|
||||||
|
Partition string
|
||||||
Port int
|
Port int
|
||||||
Tags []string
|
Tags []string
|
||||||
Meta map[string]string
|
Meta map[string]string
|
||||||
@ -83,6 +84,7 @@ func (sn *ServiceNode) appendTargetLabels(ms []map[string]string, serviceName, t
|
|||||||
"__meta_consul_dc": sn.Node.Datacenter,
|
"__meta_consul_dc": sn.Node.Datacenter,
|
||||||
"__meta_consul_health": aggregatedStatus(sn.Checks),
|
"__meta_consul_health": aggregatedStatus(sn.Checks),
|
||||||
"__meta_consul_namespace": sn.Service.Namespace,
|
"__meta_consul_namespace": sn.Service.Namespace,
|
||||||
|
"__meta_consul_partition": sn.Service.Partition,
|
||||||
"__meta_consul_node": sn.Node.Node,
|
"__meta_consul_node": sn.Node.Node,
|
||||||
"__meta_consul_service": serviceName,
|
"__meta_consul_service": serviceName,
|
||||||
"__meta_consul_service_address": sn.Service.Address,
|
"__meta_consul_service_address": sn.Service.Address,
|
||||||
|
@ -64,7 +64,8 @@ func TestParseServiceNodesSuccess(t *testing.T) {
|
|||||||
"Passing": 10,
|
"Passing": 10,
|
||||||
"Warning": 1
|
"Warning": 1
|
||||||
},
|
},
|
||||||
"Namespace": "ns-dev"
|
"Namespace": "ns-dev",
|
||||||
|
"Partition": "part-foobar"
|
||||||
},
|
},
|
||||||
"Checks": [
|
"Checks": [
|
||||||
{
|
{
|
||||||
@ -120,6 +121,7 @@ func TestParseServiceNodesSuccess(t *testing.T) {
|
|||||||
"__meta_consul_metadata_instance_type": "t2.medium",
|
"__meta_consul_metadata_instance_type": "t2.medium",
|
||||||
"__meta_consul_namespace": "ns-dev",
|
"__meta_consul_namespace": "ns-dev",
|
||||||
"__meta_consul_node": "foobar",
|
"__meta_consul_node": "foobar",
|
||||||
|
"__meta_consul_partition": "part-foobar",
|
||||||
"__meta_consul_service": "redis",
|
"__meta_consul_service": "redis",
|
||||||
"__meta_consul_service_address": "10.1.10.12",
|
"__meta_consul_service_address": "10.1.10.12",
|
||||||
"__meta_consul_service_id": "redis",
|
"__meta_consul_service_id": "redis",
|
||||||
|
@ -49,7 +49,10 @@ func newConsulWatcher(client *discoveryutils.Client, sdc *SDConfig, datacenter,
|
|||||||
baseQueryArgs += "&stale"
|
baseQueryArgs += "&stale"
|
||||||
}
|
}
|
||||||
if namespace != "" {
|
if namespace != "" {
|
||||||
baseQueryArgs += "&ns=" + namespace
|
baseQueryArgs += "&ns=" + url.QueryEscape(namespace)
|
||||||
|
}
|
||||||
|
if sdc.Partition != "" {
|
||||||
|
baseQueryArgs += "&partition=" + url.QueryEscape(sdc.Partition)
|
||||||
}
|
}
|
||||||
for k, v := range sdc.NodeMeta {
|
for k, v := range sdc.NodeMeta {
|
||||||
baseQueryArgs += "&node-meta=" + url.QueryEscape(k+":"+v)
|
baseQueryArgs += "&node-meta=" + url.QueryEscape(k+":"+v)
|
||||||
|
Loading…
Reference in New Issue
Block a user