Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Target labels in probe options #26

Open
manugarg opened this issue Nov 2, 2021 · 2 comments
Open

Target labels in probe options #26

manugarg opened this issue Nov 2, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@manugarg
Copy link
Contributor

manugarg commented Nov 2, 2021

Copied from google/cloudprober#652, originally filed by @xenofree.

Hi,

Is it possible or will it be possible to configure probe option through file_target like this ?

resource {
  name: "10.x.x.x"
  labels {
     key: "hostname"
     value: "xxxxxxxx"
  }
  labels {
     key: "query_type"
     value: A
  }
  labels {
     key: "resolved_domain"
     value: "xxx.xxxxxx.com"
  }
}
probe {
  name: "dns"
  type: DNS
  targets {
    file_targets {
      file_path: "/data/cloudprober/config.d/dns/targets.yml"
      re_eval_sec: 60
    }
  }
  additional_label {
      key: "hostname"
      value: "@target.label.hostname@"
  }
  additional_label {
      key: "resolved_domain"
      value: "@target.label.resolved_domain@"
  }
  dns_probe {
    query_type: @target.label.query_type@
    resolved_domain: "@target.label.resolved_domain@"
  }
  interval_msec: 60000  # 60s
  timeout_msec: 10000   # 10s
}
@manugarg manugarg added the enhancement New feature or request label Nov 2, 2021
@manugarg
Copy link
Contributor Author

manugarg commented Nov 2, 2021

My comment:

It's going to be hard to implement a generic label replacement mechanism.

The way it works in HTTP probe is:

If "relative_url" or "host" is not defined in the probe config, and target has these labels, it automatically uses these labels.
We can do something similar for DNS probe.

@dalvizu
Copy link

dalvizu commented Jul 1, 2022

If "relative_url" or "host" is not defined in the probe config

Correction - it looks like fqdn is the label which the HTTP probe inspects. Additionally the required 'name' field of the target will be used if both the probe and the fqdn label on the target are absent.

func hostHeaderForTarget(target endpoint.Endpoint, probeHostHeader string, port int) string {
if probeHostHeader != "" {
return probeHostHeader
}
if target.Labels["fqdn"] != "" {
return hostWithPort(target.Labels["fqdn"], port)
}
return hostWithPort(target.Name, port)

e.g

    resource { 
      name: "google_homepage"
      labels { 
        key: "fqdn"
        value: "www.google.com"
      }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants