Skip to content

Support runtime log level adjustment on spire-agent#7057

Closed
rausingh-rh wants to merge 1 commit into
spiffe:mainfrom
rausingh-rh:support-agent-logger-api
Closed

Support runtime log level adjustment on spire-agent#7057
rausingh-rh wants to merge 1 commit into
spiffe:mainfrom
rausingh-rh:support-agent-logger-api

Conversation

@rausingh-rh

@rausingh-rh rausingh-rh commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Closes #4986
Implements the Logger API (GetLogger, SetLogLevel, ResetLogLevel) on the agent's admin UDS, bringing the agent to parity with the server. The API already existed in spire-api-sdk (proto/spire/api/agent/logger/v1), this PR adds the service implementation, CLI commands, telemetry, and tests.

Copilot AI review requested due to automatic review settings June 10, 2026 06:11
@rausingh-rh rausingh-rh force-pushed the support-agent-logger-api branch from 5071a1d to e1e2a59 Compare June 10, 2026 06:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new Agent Admin API “Logger” service and supporting CLI tooling to view/change/reset the agent log level at runtime, including connection telemetry for that service.

Changes:

  • Introduces spire.api.agent.logger.v1.Logger gRPC service (GetLogger/SetLogLevel/ResetLogLevel) and registers it on the agent Admin API server.
  • Adds connection metrics emission for Logger API traffic (counter + active connections gauge).
  • Adds spire-agent logger {get,set,reset} CLI commands plus shared OS-specific dial/flag utilities.

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
pkg/common/telemetry/names.go Adds LoggerAPI telemetry namespace constant.
pkg/common/telemetry/agent/adminapi/loggerapi.go Adds helper functions to emit Logger API connection metrics.
pkg/common/api/middleware/names.go Adds agent logger service full name and includes it in tracked service names.
pkg/agent/endpoints/metrics.go Emits connection metrics for the agent logger service.
pkg/agent/endpoints/metrics_test.go Adds coverage ensuring logger service is handled by connection-metrics middleware.
pkg/agent/api/logger/v1/service.go Implements the agent logger Admin API service.
pkg/agent/api/logger/v1/levels.go Adds log level translation maps (logrus ↔ API).
pkg/agent/api/logger/v1/service_test.go Adds unit tests for logger service behaviors and logging.
pkg/agent/api/endpoints.go Registers the logger API on the agent admin endpoints.
pkg/agent/api/config.go Adds RootLog to admin API config for runtime log level control.
pkg/agent/agent.go Wires RootLog into admin endpoints; changes constructor to return an error.
cmd/spire-agent/util/util.go Adds shared CLI adapter + gRPC client helper for agent Admin API.
cmd/spire-agent/util/util_posix.go Adds socket-path flag and unix dialer.
cmd/spire-agent/util/util_windows.go Adds named-pipe flag and Windows named-pipe dialer.
cmd/spire-agent/cli/logger/*.go Implements logger get/set/reset commands + pretty printer.
cmd/spire-agent/cli/logger/*_test.go Adds CLI tests and OS-specific usage expectations.
cmd/spire-agent/cli/cli.go Registers new CLI subcommands.
Comments suppressed due to low confidence (1)

pkg/common/api/middleware/names.go:1

  • The agent logger service is mapped using LoggerServiceShortName, implicitly reusing the same short name as the server logger service. If this pairing is intentional, it would be clearer to introduce an explicit AgentLoggerServiceShortName constant (even if it equals "Logger") or add a brief comment explaining the intentional reuse, to avoid confusion and reduce the chance of future mis-pairing when this list is edited.
package middleware

Comment thread cmd/spire-agent/util/util.go
Comment thread cmd/spire-agent/cli/logger/printers.go
Comment thread pkg/agent/api/logger/v1/service.go
Comment thread pkg/agent/api/logger/v1/service_test.go
Comment thread pkg/common/api/middleware/names.go
Comment thread pkg/common/telemetry/agent/adminapi/loggerapi.go
Comment thread pkg/agent/agent.go
Implements the Logger API (GetLogger, SetLogLevel, ResetLogLevel) on the
agent admin socket, bringing the agent to parity with the server. Adds
CLI commands (spire-agent logger get/set/reset) and connection metrics.
Closes spiffe#4986

Signed-off-by: Raushan Singh <rausingh@redhat.com>
@rausingh-rh rausingh-rh force-pushed the support-agent-logger-api branch from e1e2a59 to f4f67da Compare June 10, 2026 07:16
@sorindumitru

Copy link
Copy Markdown
Member

There's another PR open for this: #7017

@rausingh-rh

Copy link
Copy Markdown
Contributor Author

Hi @sorindumitru thanks for the heads-up! I wasn't aware of #7017 when I opened this. Since your PR covers the same feature, I'll close this in favor of it. Happy to help review or test #7017 if needed.

@sorindumitru

Copy link
Copy Markdown
Member

Hi @sorindumitru thanks for the heads-up! I wasn't aware of #7017 when I opened this. Since your PR covers the same feature, I'll close this in favor of it. Happy to help review or test #7017 if needed.

Yes, if you can help with reviewing, that would be appreciated. Thanks!

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.

Support retuning of log level on spire-agent

4 participants