Skip to content

feat: de-couple --log.prober to be an independent logger#1461

Merged
electron0zero merged 6 commits into
prometheus:masterfrom
tjhop:feat/make-scrape-logger-independent
Sep 23, 2025
Merged

feat: de-couple --log.prober to be an independent logger#1461
electron0zero merged 6 commits into
prometheus:masterfrom
tjhop:feat/make-scrape-logger-independent

Conversation

@tjhop
Copy link
Copy Markdown
Contributor

@tjhop tjhop commented Sep 4, 2025

This is the beginning of the changes in architecture/behavior for the
scrape probe logger as described here:
#1377 (comment)

Currently, the scrape probe logger is a weird transforming-wrapper
around the primary logger, that comes with unconventional behavior -- it
hijacks log calls and forces them to a pre-set level. This both
confusing to users (see #1377, #1411, #1401, potentially others), as
well as very inflexible; by forcing logs to a specific level, we lose
the ability to do more nuanced logging like using debug to increase
verbosity or writing errors at error level instead of $configuredLevel.

This commit converts the scrape probe logger to be it's own
full/independent logger via promslog, same as the primary logger. Rather
than wrapping and munging the log entries, we use the primary
promslog.Config as the basis of the config for the new scrape probe
logger. We override the level field to reflect the level var that
corresponds to the --log.prober flag, and then use that config to
create the scrape probe logger.

NOTES:

  • This intentionally leaves the --log.prober flag default to debug
    for now -- most probers write logs at info level, which would result
    in more log spamming for users. In order for the blackbox exporter to
    truly take advantage of these changes, the probers will need to be
    updated to correctly use leveled logging.
    Edit: This has been updated in later commits. The --log.prober flag now defaults to info like a normal logger, and the probers have been updated to better use leveled logging.
  • Since we now use v0.65.0 for prometheus/common, I removed the
    getSlogLevel helper func in favor of getting the level directly from
    the config.

Example debug output for a scrape:

~/go/src/github.com/prometheus/prometheus (main [  ]) -> curl -sL "http://localhost:9115/probe?target=prometheus.io&module=http_2xx&debug=true" | head -20
Logs for the probe:
time=2025-09-04T12:07:05.573-04:00 level=INFO source=handler.go:116 msg="Beginning probe" module=http_2xx target=prometheus.io probe=http timeout_seconds=119.5
time=2025-09-04T12:07:05.574-04:00 level=INFO source=utils.go:61 msg="Resolving target address" module=http_2xx target=prometheus.io target=prometheus.io ip_protocol=ip4
time=2025-09-04T12:07:05.574-04:00 level=INFO source=utils.go:96 msg="Resolved target address" module=http_2xx target=prometheus.io target=prometheus.io ip=172.67.201.240
time=2025-09-04T12:07:05.574-04:00 level=INFO source=http.go:209 msg="Making HTTP request" module=http_2xx target=prometheus.io url=http://172.67.201.240 host=prometheus.io
time=2025-09-04T12:07:05.787-04:00 level=INFO source=http.go:490 msg="Received redirect" module=http_2xx target=prometheus.io location=https://prometheus.io/
time=2025-09-04T12:07:05.787-04:00 level=INFO source=http.go:209 msg="Making HTTP request" module=http_2xx target=prometheus.io url=https://prometheus.io/ host=""
time=2025-09-04T12:07:05.787-04:00 level=INFO source=http.go:224 msg="Address does not match first address, not sending TLS ServerName" module=http_2xx target=prometheus.io first=172.67.201.240 address=prometheus.io
time=2025-09-04T12:07:06.216-04:00 level=INFO source=http.go:590 msg="Received HTTP response" module=http_2xx target=prometheus.io status_code=200
time=2025-09-04T12:07:06.507-04:00 level=INFO source=http.go:721 msg="Response timings for roundtrip" module=http_2xx target=prometheus.io roundtrip=0 start=2025-09-04T12:07:05.574-04:00 dnsDone=2025-09-04T12:07:05.574-04:00 connectDone=2025-09-04T12:07:05.679-04:00 gotConn=2025-09-04T12:07:05.679-04:00 responseStart=2025-09-04T12:07:05.787-04:00 tlsStart=0001-01-01T00:00:00.000Z tlsDone=0001-01-01T00:00:00.000Z end=0001-01-01T00:00:00.000Z
time=2025-09-04T12:07:06.507-04:00 level=INFO source=http.go:721 msg="Response timings for roundtrip" module=http_2xx target=prometheus.io roundtrip=1 start=2025-09-04T12:07:05.787-04:00 dnsDone=2025-09-04T12:07:05.788-04:00 connectDone=2025-09-04T12:07:05.912-04:00 gotConn=2025-09-04T12:07:06.043-04:00 responseStart=2025-09-04T12:07:06.215-04:00 tlsStart=2025-09-04T12:07:05.912-04:00 tlsDone=2025-09-04T12:07:06.043-04:00 end=2025-09-04T12:07:06.507-04:00
time=2025-09-04T12:07:06.507-04:00 level=INFO source=handler.go:127 msg="Probe succeeded" module=http_2xx target=prometheus.io duration_seconds=0.933592996

Metrics that would have been returned:
probe_dns_lookup_time_seconds 0.000605565

Signed-off-by: TJ Hoplock t.hoplock@gmail.com

This is the beginning of the changes in architecture/behavior for the
scrape probe logger as described here:
prometheus#1377 (comment)

Currently, the scrape probe logger is a weird transforming-wrapper
around the primary logger, that comes with unconventional behavior -- it
hijacks log calls and forces them to a pre-set level. This both
confusing to users (see prometheus#1377, prometheus#1411, prometheus#1401, potentially others), as
well as very inflexible; by forcing logs to a specific level, we lose
the ability to do more nuanced logging like using debug to increase
verbosity or writing errors at error level instead of $configuredLevel.

This commit converts the scrape probe logger to be it's own
full/independent logger via promslog, same as the primary logger. Rather
than wrapping and munging the log entries, we use the primary
promslog.Config as the basis of the config for the new scrape probe
logger. We override the level field to reflect the level var that
corresponds to the `--log.prober` flag, and then use that config to
create the scrape probe logger.

**NOTES**:
- This intentionally leaves the `--log.prober` flag default to `debug`
  for now -- most probers write logs at `info` level, which would result
in more log spamming for users. In order for the blackbox exporter to
truly take advantage of these changes, the probers will need to be
updated to correctly use leveled logging.
- Since we now use v0.65.0 for prometheus/common, I removed the
  `getSlogLevel` helper func in favor of getting the level directly from
the config.

Example debug output for a scrape:

```
~/go/src/github.com/prometheus/prometheus (main [  ]) -> curl -sL "http://localhost:9115/probe?target=prometheus.io&module=http_2xx&debug=true" | head -20
Logs for the probe:
time=2025-09-04T12:07:05.573-04:00 level=INFO source=handler.go:116 msg="Beginning probe" module=http_2xx target=prometheus.io probe=http timeout_seconds=119.5
time=2025-09-04T12:07:05.574-04:00 level=INFO source=utils.go:61 msg="Resolving target address" module=http_2xx target=prometheus.io target=prometheus.io ip_protocol=ip4
time=2025-09-04T12:07:05.574-04:00 level=INFO source=utils.go:96 msg="Resolved target address" module=http_2xx target=prometheus.io target=prometheus.io ip=172.67.201.240
time=2025-09-04T12:07:05.574-04:00 level=INFO source=http.go:209 msg="Making HTTP request" module=http_2xx target=prometheus.io url=http://172.67.201.240 host=prometheus.io
time=2025-09-04T12:07:05.787-04:00 level=INFO source=http.go:490 msg="Received redirect" module=http_2xx target=prometheus.io location=https://prometheus.io/
time=2025-09-04T12:07:05.787-04:00 level=INFO source=http.go:209 msg="Making HTTP request" module=http_2xx target=prometheus.io url=https://prometheus.io/ host=""
time=2025-09-04T12:07:05.787-04:00 level=INFO source=http.go:224 msg="Address does not match first address, not sending TLS ServerName" module=http_2xx target=prometheus.io first=172.67.201.240 address=prometheus.io
time=2025-09-04T12:07:06.216-04:00 level=INFO source=http.go:590 msg="Received HTTP response" module=http_2xx target=prometheus.io status_code=200
time=2025-09-04T12:07:06.507-04:00 level=INFO source=http.go:721 msg="Response timings for roundtrip" module=http_2xx target=prometheus.io roundtrip=0 start=2025-09-04T12:07:05.574-04:00 dnsDone=2025-09-04T12:07:05.574-04:00 connectDone=2025-09-04T12:07:05.679-04:00 gotConn=2025-09-04T12:07:05.679-04:00 responseStart=2025-09-04T12:07:05.787-04:00 tlsStart=0001-01-01T00:00:00.000Z tlsDone=0001-01-01T00:00:00.000Z end=0001-01-01T00:00:00.000Z
time=2025-09-04T12:07:06.507-04:00 level=INFO source=http.go:721 msg="Response timings for roundtrip" module=http_2xx target=prometheus.io roundtrip=1 start=2025-09-04T12:07:05.787-04:00 dnsDone=2025-09-04T12:07:05.788-04:00 connectDone=2025-09-04T12:07:05.912-04:00 gotConn=2025-09-04T12:07:06.043-04:00 responseStart=2025-09-04T12:07:06.215-04:00 tlsStart=2025-09-04T12:07:05.912-04:00 tlsDone=2025-09-04T12:07:06.043-04:00 end=2025-09-04T12:07:06.507-04:00
time=2025-09-04T12:07:06.507-04:00 level=INFO source=handler.go:127 msg="Probe succeeded" module=http_2xx target=prometheus.io duration_seconds=0.933592996

Metrics that would have been returned:
probe_dns_lookup_time_seconds 0.000605565
```

Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
@tjhop
Copy link
Copy Markdown
Contributor Author

tjhop commented Sep 4, 2025

cc: @electron0zero for when you have time -- I still plan to follow up on this PR with another commit to audit the probers and improve the log leveling so they're not writing at info level in-code

Not gonna go into in-depth tests of the logger here, this is already
sufficient to validate both that leveling works and that logs no longer
all get coerced to the same level as they were previously.

Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
Now that the scrape probe logger is an independent logger and can do
proper leveling, this does a bunch of updates to the various prober
types to improve the actual leveling of the probe logs.

General patterns/concepts applied:
- if it's within an error check, log at error level by default.
- if the error is non-fatal, appropriate for a warning level message,
  and similar bits of code also use warning level instead of error, log
at warning level
- if the log is verbose/granular, information dense, and targeted at
  primarily at us as developers for troubleshooting the flow of a probe,
then it's logged at debug level. Since the probe logger is an
independent logger now, we can be stricter about what events qualify as
general info level events useful to both operators and developers.

Example of an `http_2xx` probe against `prometheus.io` with
`--log.prober=info`:

```
~/go/src/github.com/prometheus/prometheus (main [  ]) -> curl -sL "http://localhost:9115/probe?target=prometheus.io&module=http_2xx&debug=true" | sed '/Metrics that would have been returned/q'
Logs for the probe:
time=2025-09-08T18:22:23.217-04:00 level=WARN source=http.go:490 msg="Received redirect" module=http_2xx target=prometheus.io location=https://prometheus.io/

Metrics that would have been returned:
```

And here is an example of an `http_2xx` probe against `prometheus.io`
with `--log.prober=debug`:

```
~/go/src/github.com/prometheus/prometheus (main [  ]) -> curl -sL "http://localhost:9115/probe?target=prometheus.io&module=http_2xx&debug=true" | sed '/Metrics that would have been returned/q'
Logs for the probe:
time=2025-09-08T18:22:40.401-04:00 level=DEBUG source=handler.go:116 msg="Beginning probe" module=http_2xx target=prometheus.io probe=http timeout_seconds=119.5
time=2025-09-08T18:22:40.401-04:00 level=DEBUG source=utils.go:61 msg="Resolving target address" module=http_2xx target=prometheus.io target=prometheus.io ip_protocol=ip4
time=2025-09-08T18:22:40.403-04:00 level=DEBUG source=utils.go:96 msg="Resolved target address" module=http_2xx target=prometheus.io target=prometheus.io ip=172.67.201.240
time=2025-09-08T18:22:40.403-04:00 level=DEBUG source=http.go:209 msg="Making HTTP request" module=http_2xx target=prometheus.io url=http://172.67.201.240 host=prometheus.io
time=2025-09-08T18:22:40.558-04:00 level=WARN source=http.go:490 msg="Received redirect" module=http_2xx target=prometheus.io location=https://prometheus.io/
time=2025-09-08T18:22:40.558-04:00 level=DEBUG source=http.go:209 msg="Making HTTP request" module=http_2xx target=prometheus.io url=https://prometheus.io/ host=""
time=2025-09-08T18:22:40.558-04:00 level=DEBUG source=http.go:224 msg="Address does not match first address, not sending TLS ServerName" module=http_2xx target=prometheus.io first=172.67.201.240 address=prometheus.io
time=2025-09-08T18:22:40.916-04:00 level=DEBUG source=http.go:590 msg="Received HTTP response" module=http_2xx target=prometheus.io status_code=200
time=2025-09-08T18:22:41.135-04:00 level=DEBUG source=http.go:721 msg="Response timings for roundtrip" module=http_2xx target=prometheus.io roundtrip=0 start=2025-09-08T18:22:40.403-04:00 dnsDone=2025-09-08T18:22:40.403-04:00 connectDone=2025-09-08T18:22:40.479-04:00 gotConn=2025-09-08T18:22:40.479-04:00 responseStart=2025-09-08T18:22:40.558-04:00 tlsStart=0001-01-01T00:00:00.000Z tlsDone=0001-01-01T00:00:00.000Z end=0001-01-01T00:00:00.000Z
time=2025-09-08T18:22:41.135-04:00 level=DEBUG source=http.go:721 msg="Response timings for roundtrip" module=http_2xx target=prometheus.io roundtrip=1 start=2025-09-08T18:22:40.558-04:00 dnsDone=2025-09-08T18:22:40.559-04:00 connectDone=2025-09-08T18:22:40.629-04:00 gotConn=2025-09-08T18:22:40.740-04:00 responseStart=2025-09-08T18:22:40.916-04:00 tlsStart=2025-09-08T18:22:40.629-04:00 tlsDone=2025-09-08T18:22:40.740-04:00 end=2025-09-08T18:22:41.135-04:00
time=2025-09-08T18:22:41.136-04:00 level=DEBUG source=handler.go:127 msg="Probe succeeded" module=http_2xx target=prometheus.io duration_seconds=0.734697419

Metrics that would have been returned:
```

Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
@tjhop
Copy link
Copy Markdown
Contributor Author

tjhop commented Sep 9, 2025

@electron0zero alright, I think this is ready for a closer look when you have time. Feedback welcome, especially on the docs updates and the probe leveling changes.

As a maintainer, I'll defer to you as to how to handle the release announcement and publishing the breakage/change in behavior. I do see there's a breaking changes section in the changelog template, but unsure if there's other things that should be done as well.

@electron0zero
Copy link
Copy Markdown
Member

I do see there's a breaking changes section in the changelog template, but unsure if there's other things that should be done as well.

@tjhop we just add the breaking change in the change log with the details of what's breaking and how users are impacted during the release, I don't see a breaking change in the past but see prometheus CHANGELOG.md for examples.

In this case end users probably need to know two things:

  • we changed the behaviour of --log.prober to be an independent logger, and they should audit the config and configure it when they upgrade, and we can ask users to check the readme.md.
  • We moved few prober log messages from INFO to DEBUG level, and if they are not seeing the details they want in logs, they can configure the --log.prober to debug and they will get those.

you can add these two things in the PR desc with BREAKING CHANGES heading, and we can grab these from PR when we cut the release, and that should be enough imo.

Copy link
Copy Markdown
Member

@electron0zero electron0zero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change looks good to me, thanks for taking this up 🙏🏼

@electron0zero
Copy link
Copy Markdown
Member

I am going to wait 2-3 weeks before I merge, so other maintainers have time to review and give feedback.

Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
@electron0zero electron0zero merged commit 58af94a into prometheus:master Sep 23, 2025
5 checks passed
@electron0zero
Copy link
Copy Markdown
Member

it's been two weeks, thanks @tjhop, and great work on this 👏🏼 🙏🏼

@jesusvazquez jesusvazquez mentioned this pull request Dec 4, 2025
electron0zero added a commit to electron0zero/blackbox_exporter that referenced this pull request Jan 1, 2026
undo some of the log level changes made in
prometheus#1461

fixes prometheus#1509
electron0zero added a commit to electron0zero/blackbox_exporter that referenced this pull request Jan 1, 2026
undo some of the log level changes made in
prometheus#1461

fixes prometheus#1509

Signed-off-by: Suraj Nath <9503187+electron0zero@users.noreply.github.com>
@tentakle
Copy link
Copy Markdown

Still unclear logging behavior
I don't want to see debug in the application logs, but I want to see debug when executing a curl request with the debug=true option.

curl -sL "http://localhost:9115/probe?target=prometheus.io&module=http_2xx&debug=true"
Logs for the probe:
time=2026-01-16T11:20:15.084Z level=DEBUG source=handler.go:117 msg="Beginning probe" module=http_2xx target=prometheus.io probe=http timeout_seconds=119.5
time=2026-01-16T11:20:15.084Z level=DEBUG source=utils.go:61 msg="Resolving target address" module=http_2xx target=prometheus.io target=prometheus.io ip_protocol=ip4
time=2026-01-16T11:20:15.174Z level=DEBUG source=utils.go:96 msg="Resolved target address" module=http_2xx target=prometheus.io target=prometheus.io ip=104.21.60.220
time=2026-01-16T11:20:15.175Z level=DEBUG source=http.go:209 msg="Making HTTP request" module=http_2xx target=prometheus.io url=http://104.21.60.220 host=prometheus.io
time=2026-01-16T11:20:16.245Z level=WARN source=http.go:490 msg="Received redirect" module=http_2xx target=prometheus.io location=https://prometheus.io/
time=2026-01-16T11:20:16.245Z level=DEBUG source=http.go:209 msg="Making HTTP request" module=http_2xx target=prometheus.io url=https://prometheus.io/ host=""
time=2026-01-16T11:20:16.245Z level=DEBUG source=http.go:224 msg="Address does not match first address, not sending TLS ServerName" module=http_2xx target=prometheus.io first=104.21.60.220 address=prometheus.io
time=2026-01-16T11:20:17.492Z level=DEBUG source=http.go:590 msg="Received HTTP response" module=http_2xx target=prometheus.io status_code=200
time=2026-01-16T11:20:17.516Z level=DEBUG source=http.go:721 msg="Response timings for roundtrip" module=http_2xx target=prometheus.io roundtrip=0 start=2026-01-16T11:20:15.175Z dnsDone=2026-01-16T11:20:15.175Z connectDone=2026-01-16T11:20:16.229Z gotConn=2026-01-16T11:20:16.229Z responseStart=2026-01-16T11:20:16.245Z tlsStart=0001-01-01T00:00:00.000Z tlsDone=0001-01-01T00:00:00.000Z end=0001-01-01T00:00:00.000Z
time=2026-01-16T11:20:17.516Z level=DEBUG source=http.go:721 msg="Response timings for roundtrip" module=http_2xx target=prometheus.io roundtrip=1 start=2026-01-16T11:20:16.246Z dnsDone=2026-01-16T11:20:16.319Z connectDone=2026-01-16T11:20:17.379Z gotConn=2026-01-16T11:20:17.432Z responseStart=2026-01-16T11:20:17.491Z tlsStart=2026-01-16T11:20:17.379Z tlsDone=2026-01-16T11:20:17.432Z end=2026-01-16T11:20:17.516Z
time=2026-01-16T11:20:17.516Z level=DEBUG source=handler.go:128 msg="Probe succeeded" module=http_2xx target=prometheus.io duration_seconds=2.432092579
docker run --rm  --network host   --name blackbox_exporter   -v $(pwd):/config   quay.io/prometheus/blackbox-exporter:latest --config.file=/config/blackbox.yml --log.level=info --log.prober=debug
time=2026-01-16T11:20:09.726Z level=INFO source=main.go:98 msg="Starting blackbox_exporter" version="(version=0.28.0, branch=HEAD, revision=5a059bee8d8ffa4e75947c5055fb0abeefc582e6)"
time=2026-01-16T11:20:09.726Z level=INFO source=main.go:99 msg="(go=go1.25.5, platform=linux/amd64, user=root@967d444a1ba3, date=20251206-13:23:49, tags=unknown)"
time=2026-01-16T11:20:09.727Z level=INFO source=config.go:137 msg="Configuration file change detected, reloading the configuration."
time=2026-01-16T11:20:09.727Z level=WARN source=config.go:164 msg="HTTP/3 is enabled for this module. HTTP targets will be automatically converted to HTTPS during probing. Consider using HTTPS targets directly in your configuration." module=http_3xx
time=2026-01-16T11:20:09.727Z level=INFO source=main.go:111 msg="Loaded config file"
time=2026-01-16T11:20:09.729Z level=INFO source=tls_config.go:354 msg="Listening on" address=[::]:9115
time=2026-01-16T11:20:09.729Z level=INFO source=tls_config.go:357 msg="TLS is disabled." http2=false address=[::]:9115
time=2026-01-16T11:20:15.084Z level=DEBUG source=handler.go:117 msg="Beginning probe" module=http_2xx target=prometheus.io probe=http timeout_seconds=119.5
time=2026-01-16T11:20:15.084Z level=DEBUG source=utils.go:61 msg="Resolving target address" module=http_2xx target=prometheus.io target=prometheus.io ip_protocol=ip4
time=2026-01-16T11:20:15.174Z level=DEBUG source=utils.go:96 msg="Resolved target address" module=http_2xx target=prometheus.io target=prometheus.io ip=104.21.60.220
time=2026-01-16T11:20:15.175Z level=DEBUG source=http.go:209 msg="Making HTTP request" module=http_2xx target=prometheus.io url=http://104.21.60.220 host=prometheus.io
time=2026-01-16T11:20:16.245Z level=WARN source=http.go:490 msg="Received redirect" module=http_2xx target=prometheus.io location=https://prometheus.io/
time=2026-01-16T11:20:16.245Z level=DEBUG source=http.go:209 msg="Making HTTP request" module=http_2xx target=prometheus.io url=https://prometheus.io/ host=""
time=2026-01-16T11:20:16.245Z level=DEBUG source=http.go:224 msg="Address does not match first address, not sending TLS ServerName" module=http_2xx target=prometheus.io first=104.21.60.220 address=prometheus.io
time=2026-01-16T11:20:17.492Z level=DEBUG source=http.go:590 msg="Received HTTP response" module=http_2xx target=prometheus.io status_code=200
time=2026-01-16T11:20:17.516Z level=DEBUG source=http.go:721 msg="Response timings for roundtrip" module=http_2xx target=prometheus.io roundtrip=0 start=2026-01-16T11:20:15.175Z dnsDone=2026-01-16T11:20:15.175Z connectDone=2026-01-16T11:20:16.229Z gotConn=2026-01-16T11:20:16.229Z responseStart=2026-01-16T11:20:16.245Z tlsStart=0001-01-01T00:00:00.000Z tlsDone=0001-01-01T00:00:00.000Z end=0001-01-01T00:00:00.000Z
time=2026-01-16T11:20:17.516Z level=DEBUG source=http.go:721 msg="Response timings for roundtrip" module=http_2xx target=prometheus.io roundtrip=1 start=2026-01-16T11:20:16.246Z dnsDone=2026-01-16T11:20:16.319Z connectDone=2026-01-16T11:20:17.379Z gotConn=2026-01-16T11:20:17.432Z responseStart=2026-01-16T11:20:17.491Z tlsStart=2026-01-16T11:20:17.379Z tlsDone=2026-01-16T11:20:17.432Z end=2026-01-16T11:20:17.516Z
time=2026-01-16T11:20:17.516Z level=DEBUG source=handler.go:128 msg="Probe succeeded" module=http_2xx target=prometheus.io duration_seconds=2.432092579
curl -sL "http://localhost:9115/probe?target=prometheus.io&module=http_2xx&debug=true"
Logs for the probe:
time=2026-01-16T11:21:25.489Z level=WARN source=http.go:490 msg="Received redirect" module=http_2xx target=prometheus.io location=https://prometheus.io/
docker run --rm  --network host   --name blackbox_exporter   -v $(pwd):/config   quay.io/prometheus/blackbox-exporter:latest --config.file=/config/blackbox.yml --log.level=debug --log.prober=info
time=2026-01-16T11:21:19.933Z level=INFO source=main.go:98 msg="Starting blackbox_exporter" version="(version=0.28.0, branch=HEAD, revision=5a059bee8d8ffa4e75947c5055fb0abeefc582e6)"
time=2026-01-16T11:21:19.933Z level=INFO source=main.go:99 msg="(go=go1.25.5, platform=linux/amd64, user=root@967d444a1ba3, date=20251206-13:23:49, tags=unknown)"
time=2026-01-16T11:21:19.933Z level=INFO source=config.go:137 msg="Configuration file change detected, reloading the configuration."
time=2026-01-16T11:21:19.934Z level=WARN source=config.go:164 msg="HTTP/3 is enabled for this module. HTTP targets will be automatically converted to HTTPS during probing. Consider using HTTPS targets directly in your configuration." module=http_3xx
time=2026-01-16T11:21:19.934Z level=INFO source=main.go:111 msg="Loaded config file"
time=2026-01-16T11:21:19.934Z level=DEBUG source=main.go:126 msg=http://jarvis:9115
time=2026-01-16T11:21:19.934Z level=DEBUG source=main.go:140 msg=/
time=2026-01-16T11:21:19.935Z level=INFO source=tls_config.go:354 msg="Listening on" address=[::]:9115
time=2026-01-16T11:21:19.935Z level=INFO source=tls_config.go:357 msg="TLS is disabled." http2=false address=[::]:9115
time=2026-01-16T11:21:25.489Z level=WARN source=http.go:490 msg="Received redirect" module=http_2xx target=prometheus.io location=https://prometheus.io/

@electron0zero
Copy link
Copy Markdown
Member

@tentakle
Copy link
Copy Markdown

I read this section before asking here. None of the flags allow me to achieve what I want: for the application log to only contain errors, while a curl request with the debug=true option outputs a detailed probe log. Moreover, the --log.level flag doesn’t affect the output at all.

@tjhop
Copy link
Copy Markdown
Contributor Author

tjhop commented Jan 28, 2026

I don't want to see debug in the application logs, but I want to see debug when executing a curl request with the debug=true option.

Debug logs for the probe/scrape, you mean? The distinction is important, now that the scrape probe logger is independent from the main application logger. If so, I think the only way to accomplish that would be to also have the scrape probe logger write to a different destination than the main application logger. As mentioned in the commit:

we use the primary
promslog.Config as the basis of the config for the new scrape probe
logger. We override the level field to reflect the level var that
corresponds to the --log.prober flag, and then use that config to
create the scrape probe logger.

When creating the scrape probe logger config, we use the same io.Writer for output as the main application's config, which is os.Stderr. The scrape probe logger that gets created from this config then writes to both os.Stderr as well as a bytes.Buffer for use with retrieving logs with the debug param. If the scrape probe logger could write to another destination, it would be possible to write application logs and scrape prober logs to different destinations (/dev/stderr and /dev/null, for example). Since the scrape probe logger retains logs in the bytes.Buffer, it should still be possible to view them with the debug param.

@electron0zero @SuperQ would you have thoughts on adding a flag like --log.prober-output that can override the default stderr from the main application log config?

@SuperQ
Copy link
Copy Markdown
Member

SuperQ commented Jan 28, 2026

Having a separate output flag seems reasonable.

I'm going to lock this PR so we don't get necro-posting. New question/ issues should go to the community or issue tracking in the case of bugs and feature requests.

@prometheus prometheus locked as resolved and limited conversation to collaborators Jan 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants