From 9404e2f30ae5ab9ede8f53530f600d5cc440de8e Mon Sep 17 00:00:00 2001 From: Erik Baranowski <39704712+erikbaranowski@users.noreply.github.com> Date: Fri, 29 Sep 2023 10:05:25 -0400 Subject: [PATCH] wire up scrape_classic_histogram for the prometheus converter (#5336) * wire up scrape_classic_histogram for the prometheus converter Signed-off-by: erikbaranowski <39704712+erikbaranowski@users.noreply.github.com> --------- Signed-off-by: erikbaranowski <39704712+erikbaranowski@users.noreply.github.com> --- .../internal/prometheusconvert/scrape.go | 44 +++++++++---------- .../testdata/unsupported.diags | 1 - .../testdata/unsupported.river | 5 ++- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/converter/internal/prometheusconvert/scrape.go b/converter/internal/prometheusconvert/scrape.go index 120ebf8cd9fd..533c86458f4d 100644 --- a/converter/internal/prometheusconvert/scrape.go +++ b/converter/internal/prometheusconvert/scrape.go @@ -28,10 +28,6 @@ func appendPrometheusScrape(pb *prometheusBlocks, scrapeConfig *prom_config.Scra func validatePrometheusScrape(scrapeConfig *prom_config.ScrapeConfig) diag.Diagnostics { var diags diag.Diagnostics - if scrapeConfig.ScrapeClassicHistograms { - diags.Add(diag.SeverityLevelError, "unsupported scrape_classic_histograms for scrape_configs") - } - if scrapeConfig.NativeHistogramBucketLimit != 0 { diags.Add(diag.SeverityLevelError, "unsupported native_histogram_bucket_limit for scrape_configs") } @@ -47,25 +43,27 @@ func toScrapeArguments(scrapeConfig *prom_config.ScrapeConfig, forwardTo []stora } return &scrape.Arguments{ - Targets: targets, - ForwardTo: forwardTo, - JobName: scrapeConfig.JobName, - HonorLabels: scrapeConfig.HonorLabels, - HonorTimestamps: scrapeConfig.HonorTimestamps, - Params: scrapeConfig.Params, - ScrapeInterval: time.Duration(scrapeConfig.ScrapeInterval), - ScrapeTimeout: time.Duration(scrapeConfig.ScrapeTimeout), - MetricsPath: scrapeConfig.MetricsPath, - Scheme: scrapeConfig.Scheme, - BodySizeLimit: scrapeConfig.BodySizeLimit, - SampleLimit: scrapeConfig.SampleLimit, - TargetLimit: scrapeConfig.TargetLimit, - LabelLimit: scrapeConfig.LabelLimit, - LabelNameLengthLimit: scrapeConfig.LabelNameLengthLimit, - LabelValueLengthLimit: scrapeConfig.LabelValueLengthLimit, - HTTPClientConfig: *ToHttpClientConfig(&scrapeConfig.HTTPClientConfig), - ExtraMetrics: false, - Clustering: scrape.Clustering{Enabled: false}, + Targets: targets, + ForwardTo: forwardTo, + JobName: scrapeConfig.JobName, + HonorLabels: scrapeConfig.HonorLabels, + HonorTimestamps: scrapeConfig.HonorTimestamps, + Params: scrapeConfig.Params, + ScrapeClassicHistograms: scrapeConfig.ScrapeClassicHistograms, + ScrapeInterval: time.Duration(scrapeConfig.ScrapeInterval), + ScrapeTimeout: time.Duration(scrapeConfig.ScrapeTimeout), + MetricsPath: scrapeConfig.MetricsPath, + Scheme: scrapeConfig.Scheme, + BodySizeLimit: scrapeConfig.BodySizeLimit, + SampleLimit: scrapeConfig.SampleLimit, + TargetLimit: scrapeConfig.TargetLimit, + LabelLimit: scrapeConfig.LabelLimit, + LabelNameLengthLimit: scrapeConfig.LabelNameLengthLimit, + LabelValueLengthLimit: scrapeConfig.LabelValueLengthLimit, + HTTPClientConfig: *ToHttpClientConfig(&scrapeConfig.HTTPClientConfig), + ExtraMetrics: false, + EnableProtobufNegotiation: false, + Clustering: scrape.Clustering{Enabled: false}, } } diff --git a/converter/internal/prometheusconvert/testdata/unsupported.diags b/converter/internal/prometheusconvert/testdata/unsupported.diags index 83757cd5c64f..3efc82ee60ab 100644 --- a/converter/internal/prometheusconvert/testdata/unsupported.diags +++ b/converter/internal/prometheusconvert/testdata/unsupported.diags @@ -4,7 +4,6 @@ (Error) unsupported rule_files config was provided (Error) unsupported HTTP Client config no_proxy was provided (Error) unsupported service discovery nomad was provided -(Error) unsupported scrape_classic_histograms for scrape_configs (Error) unsupported native_histogram_bucket_limit for scrape_configs (Error) unsupported storage config was provided (Error) unsupported tracing config was provided diff --git a/converter/internal/prometheusconvert/testdata/unsupported.river b/converter/internal/prometheusconvert/testdata/unsupported.river index 5c0f43c0ba65..e275ee15edb3 100644 --- a/converter/internal/prometheusconvert/testdata/unsupported.river +++ b/converter/internal/prometheusconvert/testdata/unsupported.river @@ -19,8 +19,9 @@ prometheus.scrape "prometheus2" { targets = [{ __address__ = "localhost:9091", }] - forward_to = [prometheus.remote_write.default.receiver] - job_name = "prometheus2" + forward_to = [prometheus.remote_write.default.receiver] + job_name = "prometheus2" + scrape_classic_histogram = true } prometheus.remote_write "default" {