Skip to content

Commit

Permalink
fix(prometheus_scrape): federate query match url building
Browse files Browse the repository at this point in the history
  • Loading branch information
sainad2222 committed Dec 27, 2024
1 parent 029a2ff commit 1474e59
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/sources/prometheus/scrape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,16 @@ impl GenerateConfig for PrometheusScrapeConfig {
#[typetag::serde(name = "prometheus_scrape")]
impl SourceConfig for PrometheusScrapeConfig {
async fn build(&self, cx: SourceContext) -> Result<sources::Source> {
// replace the key match with match[], if present
let mut query: HashMap<String, Vec<String>> = self.query.clone();
if let Some(values) = query.remove("match") {
query.insert("match[]".to_string(), values);
}
let urls = self
.endpoints
.iter()
.map(|s| s.parse::<Uri>().context(sources::UriParseSnafu))
.map(|r| r.map(|uri| build_url(&uri, &self.query)))
.map(|r| r.map(|uri| build_url(&uri, &query)))
.collect::<std::result::Result<Vec<Uri>, sources::BuildError>>()?;
let tls = TlsSettings::from_options(&self.tls)?;

Expand Down

0 comments on commit 1474e59

Please sign in to comment.