Skip to content

Starlark probe: support explicit proxy configuration (parity with HTTP probe) #1505

Closed

Description

@aholden85

Describe the feature you'd like and the problem it will solve

probes/http (ProbeConf.proxy_url / proxy_connect_header, fields 16/23 in probes/http/proto/config.proto) lets an HTTP probe route its request through an explicit, per-probe HTTP/HTTPS proxy. The Starlark probe (probes/starlark/proto/config.proto) has no equivalent: there is no proxy_url-style config field, and the http builtin's get/post/put/ patch/delete functions have no proxy= kwarg.

Today, the only way a Starlark script's HTTP calls end up going through a proxy at all is if the cloudprober process happens to have HTTP_PROXY/HTTPS_PROXY set in its OS environment (picked up implicitly via http.DefaultTransport's ProxyFromEnvironment, since newHTTPClient in probes/starlark/runtime.go never overrides Transport.Proxy). That's not a real substitute for explicit configuration:

  • Not configurable per probe, only per process - every Starlark probe hosted by the same cloudprober instance shares the same proxy behavior, with no way to give one probe a proxy and another direct access.
  • Not configurable per call/per host within a single script execution - unlike TLS, where tls_configs (a named map, selected in-script via tls="name" on each http.* call) already lets one script apply different TLS behavior to different hosts in the same run. There's no proxy analogue of that pattern, even though a single Starlark probe execution routinely makes calls to several different hosts that may need different proxy treatment (or none at all).
  • Entirely implicit - nothing in the probe's own config declares or documents that a proxy is in use, unlike http_probe.proxy_url being an explicit, visible part of the probe definition.

This makes Starlark probes impractical as an HTTP-based probe type in any environment where egress is only permitted through an explicit proxy (a common setup in locked-down enterprise networks), even though the HTTP probe type already supports exactly this scenario.

I'd like to add a named proxy_configs map to starlark.ProbeConf, mirroring the existing tls_configs map / tls= kwarg design, plus a proxy= kwarg on the http builtin's call functions, so a script can select a named proxy per call:

starlark_probe {
  source_file: "probe.star"
  proxy_configs {
    key: "corp"
    value { proxy_url: "http://proxy.internal:3128" }
  }
}
def probe(target):
    r = http.get(url = "https://example.com/healthz", proxy = "corp")
    assert.http_status(r, 200)

A named map (rather than a single probe-wide proxy_url, as the HTTP probe type uses) is deliberate: one Starlark probe execution can issue calls to multiple distinct hosts, unlike the HTTP probe type where one execution is always exactly one request to one target - so a single proxy field wouldn't cover the same range of use cases tls_configs already does for TLS.

I have a working prototype of this (proto field, runtime client-selection plumbing, proxy= kwarg, and tests covering named-config selection, direct connection when omitted, mutual exclusion with an unrelated TLS name, unknown proxy name, and no proxy_configs configured at all) and I'm happy to open a PR against this issue. Cloudprober version tested against: v0.14.5 (also present on main, commit 58ba587e).

Activity

  1. added
    enhancement
    on Sep 28, 2026
  2. manugarg commented on Sep 29, 2026

    @manugarg
    Contributor

    Thanks for the detailed write-up, @aholden85. I agree this is a real gap. Relying on the process's HTTPS_PROXY is implicit, and it's the same for every probe in the process.

    I'd like to go a bit simpler than a named proxy_configs map, though.

    Why not mirror tls_configs? Per-call TLS selection exists because TLS settings are genuinely per host: ca_cert_file replaces the system CA pool, server_name is an override for one host, and so on. Proxies don't really work that way. In locked-down networks there's almost always one egress proxy, and the per-host question is "proxy or direct" (internal hosts usually need to skip it), not "which proxy".

    There's also an implementation cost. The proxy and the TLS config both live on the http.Transport, which owns the connection pool. With independent tls= and proxy= selectors, we'd need a client for every (tls, proxy) combination to keep them composable, and composability matters: an internal host with a private CA behind the corporate proxy is exactly the case we want to cover.

    Proposal: one probe-level proxy, with a no_proxy exclusion list.

    starlark_probe {
      source_file: "probe.star"
      proxy_url: "http://proxy.internal:3128"
      proxy_connect_header { key: "Proxy-Authorization" value: "Basic ..." }
      no_proxy: "*.corp.internal,10.0.0.0/8"
    }
    
    • proxy_url and proxy_connect_header work the same way as in the HTTP probe.
    • no_proxy uses the standard NO_PROXY syntax. It's needed here because a script talks to many hosts, while an HTTP probe only talks to its target.
    • Implementation: build the proxy function once with golang.org/x/net/http/httpproxy.Config{HTTPProxy: u, HTTPSProxy: u, NoProxy: ...}.ProxyFunc(), and set it (plus ProxyConnectHeader) on the default client's transport and on every tls_configs transport. The number of clients doesn't change, and tls= works with the proxy automatically.
    • Parse and validate proxy_url when the probe is initialized, not on the first call.
    • If proxy_url is unset, behavior stays exactly as it is today (ProxyFromEnvironment). The Starlark probe has shipped, so existing setups that rely on HTTPS_PROXY shouldn't change.
    • No script-side changes: no proxy= kwarg.

    If a real need for several different proxies in one probe comes up later, we can add a named map then. I'd rather not design for it up front.

  3. aholden85 commented on Oct 14, 2026

    @aholden85
    ContributorAuthor

    Hi @manugarg - just checking if you've had a chance to review the PR yet? I'm running into more situations where we could really use this kind of configuration in our environment.

  4. manugarg commented on Oct 14, 2026

    @manugarg
    Contributor

    @aholden85 Apologies for the delay. I'll review it in a couple of days.

  5. added a commit that references this issue on Nov 3, 2026
    e1c792f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions