From ac09c628078faaff7a5f364fc6044151c91a6550 Mon Sep 17 00:00:00 2001 From: scottzhlin Date: Fri, 9 Dec 2022 16:32:23 +0800 Subject: [PATCH] feat(agent/sd): add support HTTP service discovery --- .../reference-configuration-parameters/index.md | 4 ++++ .../index.template | 4 ++++ pkg/agent/config.go | 6 ++++++ pkg/gen/google/v1/profile.pb.go | 13 +++++++++---- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/docs/sources/operators-guide/configure/reference-configuration-parameters/index.md b/docs/sources/operators-guide/configure/reference-configuration-parameters/index.md index 1d79aa6ec..cd1964fec 100644 --- a/docs/sources/operators-guide/configure/reference-configuration-parameters/index.md +++ b/docs/sources/operators-guide/configure/reference-configuration-parameters/index.md @@ -1246,6 +1246,10 @@ static_configs: kubernetes_sd_configs: [ - ... ] +# List of HTTP service discovery configurations. +http_sd_configs: + [ - ... ] + # Sets the `Authorization` header on every scrape request with the # configured username and password. # password and password_file are mutually exclusive. diff --git a/docs/sources/operators-guide/configure/reference-configuration-parameters/index.template b/docs/sources/operators-guide/configure/reference-configuration-parameters/index.template index 63d01b00d..2f233c522 100644 --- a/docs/sources/operators-guide/configure/reference-configuration-parameters/index.template +++ b/docs/sources/operators-guide/configure/reference-configuration-parameters/index.template @@ -100,6 +100,10 @@ static_configs: kubernetes_sd_configs: [ - ... ] +# List of HTTP service discovery configurations. +http_sd_configs: + [ - ... ] + # Sets the `Authorization` header on every scrape request with the # configured username and password. # password and password_file are mutually exclusive. diff --git a/pkg/agent/config.go b/pkg/agent/config.go index 897db49ce..c2765c004 100644 --- a/pkg/agent/config.go +++ b/pkg/agent/config.go @@ -7,6 +7,8 @@ import ( "path/filepath" "time" + "github.com/prometheus/prometheus/discovery/http" + "github.com/grafana/dskit/flagext" "github.com/parca-dev/parca/pkg/config" parcaconfig "github.com/parca-dev/parca/pkg/config" @@ -139,6 +141,7 @@ func (c *ScrapeConfig) Validate() error { type ServiceDiscoveryConfig struct { StaticConfigs discovery.StaticConfig `yaml:"static_configs"` KubernetesSDConfigs []*kubernetes.SDConfig `yaml:"kubernetes_sd_configs,omitempty"` + HTTPSDConfigs []*http.SDConfig `yaml:"http_sd_configs,omitempty"` } func (cfg ServiceDiscoveryConfig) Configs() (res discovery.Configs) { @@ -148,5 +151,8 @@ func (cfg ServiceDiscoveryConfig) Configs() (res discovery.Configs) { for _, x := range cfg.KubernetesSDConfigs { res = append(res, x) } + for _, x := range cfg.HTTPSDConfigs { + res = append(res, x) + } return res } diff --git a/pkg/gen/google/v1/profile.pb.go b/pkg/gen/google/v1/profile.pb.go index 210814f04..6dfff7cf6 100644 --- a/pkg/gen/google/v1/profile.pb.go +++ b/pkg/gen/google/v1/profile.pb.go @@ -65,9 +65,13 @@ type Profile struct { // A description of the samples associated with each Sample.value. // For a cpu profile this might be: - // [["cpu","nanoseconds"]] or [["wall","seconds"]] or [["syscall","count"]] + // + // [["cpu","nanoseconds"]] or [["wall","seconds"]] or [["syscall","count"]] + // // For a heap profile, this might be: - // [["allocations","count"], ["space","bytes"]], + // + // [["allocations","count"], ["space","bytes"]], + // // If one of the values represents the number of events represented // by the sample, by convention it should be at index 0 and use // sample_type.unit == "count". @@ -602,8 +606,9 @@ type Location struct { // preceding entries were inlined. // // E.g., if memcpy() is inlined into printf: - // line[0].function_name == "memcpy" - // line[1].function_name == "printf" + // + // line[0].function_name == "memcpy" + // line[1].function_name == "printf" Line []*Line `protobuf:"bytes,4,rep,name=line,proto3" json:"line,omitempty"` // Provides an indication that multiple symbols map to this location's // address, for example due to identical code folding by the linker. In that