Skip to content

Contribute an Example Probe to perform HTTP with TLS - #1080

Closed
conallob wants to merge 1427 commits into
cloudprober:mainfrom
conallob:add-tls-config-examples
Closed

conallob wants to merge 1427 commits into
cloudprober:mainfrom
conallob:add-tls-config-examples

Conversation

@conallob

@conallob conallob commented May 19, 2025 •

Copy link
Copy Markdown
Contributor
  • Contribute an Example Probe to perform HTTP with TLS

  • Also provide a small cleanup to grpc example by moving the gRPC port out of the targets stanza

This implements #1079

manugarg and others added 30 commits July 24, 2024 15:49
… labels (#810)

* [probes.external] Make external probe labels consistent with additional labels.

- External probe labels are the substituions we do for probe command line or probe
  options. These substituions were added before addtional labels were introduced.
  Make these substituions consistent with additional labels.

- Add more tests and documentation.
* [options] Change how LogMetrics is implemented.

- Make defining LogMetrics completely optional. This simplifies a lot of test code.
This cloning got added in #533, when we tried to standardize handling
of eventmetrics through options.RecordMetrics. It doesn't really serve
any purpose as probes calling this function already provide a clean,
disconnected EventMetrics.
* [homepage] One with the gray flavored image.

* Update homepage image
- Common scheduler creates probe loops per target, while gRPC probe creates probe loops per target per connection. To bridge the gap, we create multiple copies for each target, each copy with a different connection index: so if there 10 targets and we want to have 2 connections per target, scheduler will see 20 targets.
- Made some changes to the common scheduler and endpoint package to support the above behavior.
Allow supplying a filepath glob pattern inside the `include` so that multiple files can be included
using a single statement. Backward compatibility of including a single file is still supported as
the glob match will just return a single file path in the slice.

The glob pattern syntax is that of `filepath.Match()`.
Provide a way to specify more DNS options and improve overall resolver interface.

* Provide an option to specify max cache age for DNS resolution. This value will control for how long we can return a cached IP in case of DNS resolution failure.
* Add an option to specify backend timeout for DNS resolution. This value will control for how long we'll wait for DNS resolver to respond.
* Make resolver package provide an interface - Resolver, instead of the full implementation. Now that we have proper resolver initialization methods, we don't need to expose the implementation anymore. That simplifies resolver passing between targets and other modules like gce.
* Make the backend resolve function take a context, and call it with a context with timeout.
* Earlier we were handling timeouts ourselves through a goroutine because when resolver was implemented there was no LookupIP with context. New method is much better as old method has the potential of leaking goroutine in case of hanging connections.
* Also, create a custom resolver only once, no need to create a new one on each resolve call.
* Export CtxDone from sched. This functionality is used by many probes.
…nse (#841)

This is a big change. It revamps how we create metrics from probe output, making it more generic and supporting more formats.

* Add support for creating metrics from HTTP headers. For example, you can create a content_length metric with a small config change. You can use this to parse custom headers as well, that your target may export.
* Add support for creating metrics from JSON output. This is very useful as JSON is a commonly used format on web today.
- Also make it enabled for all surfacers by default. This was anyway the
  case until now, because of a bug.
- Earlier this option didn't work for FILE and PUBSUB surfacers.
= Move DNSOptions parsing to resolver package so that we can do deeper
testing.
= Test resolver timeout while testing overrides.
- Call resolve multiple times in tests.
- To ensure backend gets called, sleep between calls.
* [probes.external] Factor out command execution.
- Factor out command execution fuctionality into a common package in
preparation for adding the browser probe. (See #848).
- I want to factor it out sooner so that we can test external prober
changes sooner.
…en (#853)

- Go's LookupIP implementation is complex (to make it efficient) and not worth it when DNS server is overridden.
- LookupIP may be buggy or less deterministic when not using system's local resolvers. I am not sure if that's the case, but I think it's okay to skip it to use a simple DNS client to do DNS queries when not using local resolvers.

Go's implementation is here:
https://github.com/golang/go/blob/ab5c22e7ed6bda79f07410c0041e020e52dc9b35/src/net/dnsclient_unix.go#L609
https://github.com/golang/go/blob/ab5c22e7ed6bda79f07410c0041e020e52dc9b35/src/net/dnsclient_unix.go#L297
conallob and others added 27 commits October 3, 2025 21:39
This still needs a lot of work for the full implementation, but this version is already quite useful as it lists all the timestamp directories on the top page (see screenshot in the comment below). It'll now be easy to add other features like filtering by time range.

One drawback of this current design is that it shows all timestamped directories on one page (instead of showing them by days), which may be hard to browse. I'll check this in and follow-up with filtering by date and time in the next PR.

See #958 for more context.
…ime. (#1077)

- Create a separate package for web related files and assets.
- Important: UseUse local time for artifacts directories instead of UTC.
- Add selectors for startTime and endTime. By default endTime is set to "now" and startTime to now-24h.
- Add javascript to handle time window changes.
- Fix a bug in the function to find timestamp directories. Add tests to avoid bug in future.

Note: this work is in continuation to #1074. See #958 for more context.

* - UseUse local time for artifacts directories instead of UTC.
- Improve test coverage.

* Set URL params only when valid.
This still needs a lot of work for the full implementation, but this version is already quite useful as it lists all the timestamp directories on the top page (see screenshot in the comment below). It'll now be easy to add other features like filtering by time range.

One drawback of this current design is that it shows all timestamped directories on one page (instead of showing them by days), which may be hard to browse. I'll check this in and follow-up with filtering by date and time in the next PR.

See #958 for more context.
…ime. (#1077)

- Create a separate package for web related files and assets.
- Important: UseUse local time for artifacts directories instead of UTC.
- Add selectors for startTime and endTime. By default endTime is set to "now" and startTime to now-24h.
- Add javascript to handle time window changes.
- Fix a bug in the function to find timestamp directories. Add tests to avoid bug in future.

Note: this work is in continuation to #1074. See #958 for more context.

* - UseUse local time for artifacts directories instead of UTC.
- Improve test coverage.

* Set URL params only when valid.
This still needs a lot of work for the full implementation, but this version is already quite useful as it lists all the timestamp directories on the top page (see screenshot in the comment below). It'll now be easy to add other features like filtering by time range.

One drawback of this current design is that it shows all timestamped directories on one page (instead of showing them by days), which may be hard to browse. I'll check this in and follow-up with filtering by date and time in the next PR.

See #958 for more context.
…ime. (#1077)

- Create a separate package for web related files and assets.
- Important: UseUse local time for artifacts directories instead of UTC.
- Add selectors for startTime and endTime. By default endTime is set to "now" and startTime to now-24h.
- Add javascript to handle time window changes.
- Fix a bug in the function to find timestamp directories. Add tests to avoid bug in future.

Note: this work is in continuation to #1074. See #958 for more context.

* - UseUse local time for artifacts directories instead of UTC.
- Improve test coverage.

* Set URL params only when valid.
…1094)

- Metrics expiration can be problematic for metrics that are far apart on purpose, e.g. if probe interval is more than 10m.
- We needed metrics expiration primarily because we include timestamp in metrics by default. With this change, if `include_timestamp` is set to false, we'll not expire metrics by default.
…lag. (#1096)

- Control include timestamp behavior through a flag.

- Change "prefix" configuration behavior such that config can override flag value.

- Improve test coverage.
This still needs a lot of work for the full implementation, but this version is already quite useful as it lists all the timestamp directories on the top page (see screenshot in the comment below). It'll now be easy to add other features like filtering by time range.

One drawback of this current design is that it shows all timestamped directories on one page (instead of showing them by days), which may be hard to browse. I'll check this in and follow-up with filtering by date and time in the next PR.

See #958 for more context.
…ime. (#1077)

- Create a separate package for web related files and assets.
- Important: UseUse local time for artifacts directories instead of UTC.
- Add selectors for startTime and endTime. By default endTime is set to "now" and startTime to now-24h.
- Add javascript to handle time window changes.
- Fix a bug in the function to find timestamp directories. Add tests to avoid bug in future.

Note: this work is in continuation to #1074. See #958 for more context.

* - UseUse local time for artifacts directories instead of UTC.
- Improve test coverage.

* Set URL params only when valid.
Implement a single run interface for Cloudprober. You'll be able to ask Cloudprober to run probes just once and print the results.

[Note that interface being introduced in this PR will evolve]

- In probes, add a new interface called ProbeWithRunOnce to identify probe types that implement the RunOnce interface.
- Add RunOnce support to HTTP probe. Note that RunOnce doesn't support multiple requests per HTTP probe.

One part that needs a lot of work still and will evolve with time is how we arrange the results and how we output them.  Most of that code is in the singlerun package. I am thinking of two output formats right now -- text for human operators, and json for machines. JSON still needs to be implemented, but here is how text format looks like right now:

```
[samwise 14:33:33 ~/code/cloudprober-wt/run-once(run-once)]$ go run ./cmd/cloudprober --config_file=$HOME/cloudprober_google.cfg --run_once 2>/dev/null
Probe: google_http
  Target: google87.c2om
    Status: failed
    Error: error creating HTTP request for target: google87.c2om, err: error resolving target: google87.c2om, lookup google87.c2om on 127.0.0.53:53: no such host

Probe: google_http_1.1.1.1
  Target: google.com
    Status: ok (latency: 203.725872ms)
    Metrics:
      1753997640 labels=ptype=http total=1 success=1 latency=200.338 timeouts=0 resp-code=map:code,200:1 dns_latency=13.747 tls_handshake_latency=80.397
      1753997640 labels=ptype=http ssl_earliest_cert_expiry_sec=5137201
```
…ime. (#1077)

- Create a separate package for web related files and assets.
- Important: UseUse local time for artifacts directories instead of UTC.
- Add selectors for startTime and endTime. By default endTime is set to "now" and startTime to now-24h.
- Add javascript to handle time window changes.
- Fix a bug in the function to find timestamp directories. Add tests to avoid bug in future.

Note: this work is in continuation to #1074. See #958 for more context.

* - UseUse local time for artifacts directories instead of UTC.
- Improve test coverage.

* Set URL params only when valid.
…1094)

- Metrics expiration can be problematic for metrics that are far apart on purpose, e.g. if probe interval is more than 10m.
- We needed metrics expiration primarily because we include timestamp in metrics by default. With this change, if `include_timestamp` is set to false, we'll not expire metrics by default.
…lag. (#1096)

- Control include timestamp behavior through a flag.

- Change "prefix" configuration behavior such that config can override flag value.

- Improve test coverage.
…traces (#1103)

Introducing a new trace option that supersedes the old option. `save_traces (bool)` -> `save_trace (enum)`.

I plan to remove the old `save_traces` option in the follow up changes.
@conallob

conallob commented Oct 3, 2025

Copy link
Copy Markdown
Contributor Author

Nuking git repo and starting this PR again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.