Skip to content

fix(k8s): Add loki.url config key for k8s logs #2651

Closed

Description

@dan-petty

Problem Description

devops k8s logs has no setting for the Loki address. The error text of the kubectl fallback tells the user to "Configure loki.url", but no such setting exists. devops config set loki.url <url> fails with Unknown config key: 'loki.url'. The only other address is the constant DEFAULT_LOKI_URL (http://localhost:3100) in src/devops_cli/config/defaults.py, or the option --loki-url of one command.

The spec configured-service-urls says that the service clients for Qdrant, Tempo, Pyroscope and Vault connect only to configured endpoints or ports that the CLI opened itself. Loki is not on that list. devops k8s logs dials a localhost default that nobody configured, and a user cannot fix the address in the configuration. The text of the spec k8s-logs names the same missing setting (loki.url) in four scenarios.

Reproduction Steps

  1. Run devops config set loki.url http://example.com:3100.
  2. See Unknown config key: 'loki.url'.
  3. Run devops k8s logs '{app=~"x"}' while no Loki answers on localhost:3100.
  4. Read the error: The kubectl fallback supports only label="value" matchers and |= filters. Configure loki.url to evaluate this query.

Expected vs Actual Behavior

Expected: a loki.url setting exists, or the text names the real way to set the address. devops k8s logs and the MCP tool k8s_logs use the configured address, or a port-forward that the CLI opens, and stop with an error that names the setting when neither exists.

Actual: the setting does not exist. The command dials http://localhost:3100 when no --loki-url is given.

Environment Diagnostics

  • DevOps CLI Version: 0.16.1 (main at 9f6ace18)
  • Python Version: 3.14.10
  • OS & Architecture: Linux x86_64
  • Execution Environment: DevContainer

Logs, Traces, or Terminal Output

$ devops config set loki.url http://example.com:3100
Unknown config key: 'loki.url'
Known keys with a similar name: valkey.url

Related: #2635 removes the loki_url option from the MCP tool k8s_logs. That fix leaves the default address as it is, and this issue covers the missing setting.

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Proposed design

Problem statement

The command devops k8s logs tells a user to configure loki.url, but that key does not exist in the config system. The command dials the constant DEFAULT_LOKI_URL (http://localhost:3100) when no --loki-url flag is given. A user cannot set the Loki address in the configuration. The spec k8s-logs names loki.url in four scenarios, and the spec configured-service-urls lists Qdrant, Tempo, Pyroscope and Vault but not Loki. The fix adds the missing loki.url key so the command and the MCP tool k8s_logs read the configured address.

Acceptance criteria

Requirement: loki-url-config-key

The config system SHALL recognize loki.url as a valid key.

Scenario: set-loki-url-succeeds

  • WHEN A user runs devops config set loki.url http://example.com:3100
  • THEN The command exits with code 0 and does not print Unknown config key

Requirement: k8s-logs-uses-configured-address

The command devops k8s logs SHALL connect to the address in the loki.url setting when no --loki-url flag is given.

Scenario: configured-address-is-used

  • WHEN loki.url is set to http://example.com:3100 and devops k8s logs '{app=~"x"}' is run without --loki-url
  • THEN The HTTP request is sent to http://example.com:3100/loki/api/v1/query_range

Requirement: error-names-real-setting

The kubectl fallback error text SHALL name loki.url as the setting to configure.

Scenario: fallback-error-names-loki-url

  • WHEN The kubectl fallback triggers because no Loki answers on the configured or default address
  • THEN The error text contains the string loki.url

Requirement: mcp-tool-uses-configured-address

The MCP tool k8s_logs SHALL connect to the address in the loki.url setting.

Scenario: mcp-uses-configured-address

  • WHEN loki.url is set to http://example.com:3100 and the MCP tool k8s_logs is called with no URL argument
  • THEN The HTTP request is sent to http://example.com:3100/loki/api/v1/query_range

Requirement: default-unchanged

When loki.url is not set, the command SHALL use DEFAULT_LOKI_URL.

Scenario: default-address-when-unset

  • WHEN loki.url is not set and devops k8s logs is run without --loki-url
  • THEN The HTTP request is sent to http://localhost:3100/loki/api/v1/query_range

Existing Tool Considered

No check has run. The need is to add one configuration key to the project's own config system and wire it into two existing call sites. No external tool or library covers this. The project builds and keeps its own config layer in src/devops_cli/config/. The written cost is the tokens to add the key to settings.py, update the two call sites in k8s/logql.py and the MCP tool, update the error text, and add tests, plus the time to keep the key in sync with the spec and the defaults file.

Key questions

  • What is the config key name?: loki.url, matching the existing pattern of qdrant.url, tempo.url, valkey.url and the text in the spec k8s-logs and the error message. (best practice) [sources: src/devops_cli/config/defaults.py, openspec/changes/archive/2026-10-29-2635-k8s-logs-mcp-no-loki-url/proposal.md]
    • Chosen: loki.url. Matches the existing .url pattern and the spec text that names this key in four scenarios.
    • Rejected: loki_url. Does not match the dot-separated pattern used by every other service URL key.
  • What is the default value when the key is not set?: http://localhost:3100, the existing constant DEFAULT_LOKI_URL. [sources: src/devops_cli/config/defaults.py:234]
  • Where is the key registered?: In src/devops_cli/config/settings.py, alongside the other service URL keys such as qdrant.url and tempo.url. (best practice) [sources: src/devops_cli/config/settings.py, openspec/changes/archive/2026-10-29-2635-k8s-logs-mcp-no-loki-url/proposal.md]
  • Does the MCP tool k8s_logs read the setting?: Yes. The issue states the MCP tool SHALL use the configured address. The archived fix(k8s): a loki url that the mcp tool k8s_logs gets from the model reaches private addresses and returns the answer #2635 change removed the loki_url option from the tool, so the setting is the only address source besides the default. (best practice) [sources: openspec/changes/archive/2026-10-29-2635-k8s-logs-mcp-no-loki-url/design.md, openspec/changes/archive/2026-10-29-2635-k8s-logs-mcp-no-loki-url/proposal.md]
  • Does the --loki-url flag still override the setting?: Yes. The flag is an explicit per-invocation override. The setting is the persistent default. The flag takes precedence when both are present. (best practice) [sources: src/devops_cli/k8s/logql.py]
    • Chosen: Flag overrides setting. Standard CLI convention: an explicit flag wins over a stored default. The existing code already gives the flag priority over the constant.
    • Rejected: Setting overrides flag. Breaks the expectation that a flag given on the command line is the most specific instruction.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    status/new
    value/medium
    effort/low
    on Oct 29, 2026
  2. dan-petty commented on Oct 29, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The error message names a config key that does not exist and the command dials a hardcoded localhost default that users cannot override via config.
    • Priority: P2-Medium. The command still works with the --loki-url flag, but the config path is broken and the error text misleads users.
    • Value: Medium. Users who set Loki through config cannot do so and the error text points to a non-existent key.
    • Effort: Low. The fix is to add one config key and wire it into the default, or to correct the error text to name the real option.
    • Related: fix(k8s): a loki url that the mcp tool k8s_logs gets from the model reaches private addresses and returns the answer #2635, which asks for a different change. Both items deal with the Loki address in k8s logs, but #2635 removes the SSRF vector from the MCP tool while this candidate adds a missing config setting or fixes the error text.
  3. added
    priority/p2-medium
    on Oct 29, 2026
  4. added
    scope/k8s
    on Oct 30, 2026
  5. added
    status/ready
    and removed
    status/new
    on Oct 30, 2026
  6. devops-cli-service commented on Oct 30, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 0b7e190 (see proposed design in issue body).

  7. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Staged: branch fix/2651-devops-k8s-logs-names-a-loki, draft pull request #3151. The pull request plans the item and closes no issue.

    The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:

    1. Add loki.url config key to settings: 5687 tokens
    2. Wire loki.url into k8s logs command: 5718 tokens
  8. added 2 commits that reference this issue on Nov 2, 2026
  9. 30 remaining items

  10. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    The runner Job devops-cli-runner-20261104-200132-6b9b ended: succeeded.
    Image digest: sha256:eb2c32f9c27c350eafb35b7f08c274621a0a05b95904b2185c667b9805b0d499

    The last lines of its log:

    Tool call: shell, started: uv run pytest tests/commands/k8s/test_k8s_logs_loki_url.py -v
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run pytest tests/security/test_config_declarations.py::test_the_variables_are_those_before_one_for_each_read_option_that_had_none_and_later_ones -v
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run pytest tests/ai/mcp/test_k8s_logql.py -v
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run pytest tests/config/test_config_keys.py -v -k ...
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run pytest tests/k8s/test_logql.py -v --tb=<masked>
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run pytest tests/config/ -v --tb=<masked> ...
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops docs generate --sync-readme
    Tool call: shell, program uv, ok.
    Tool call: shell, started: grep -n loki.url docs/CONFIGURATION.md
    Tool call: shell, program grep, ok.
    Tool call: shell, started: grep -A 3 -B 3 loki ...
    Tool call: shell, program grep, ok.
    Tool call: shell, started: uv run devops k8s logs --help ...
    Tool call: shell, program uv, refused.
    Tool call: shell, started: uv run devops k8s logs --help
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run pytest tests/config/test_loki_url.py tests/k8s/test_loki_url_setting.py tests/commands/k8s/test_k8s_logs_loki_url.py ...
    Tool call: shell, program uv, ok.
    Tool call: edit_file, ok.
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Tool call: shell, started: find .data/agent/scratch -type f -delete
    Tool call: shell, program find, refused.
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Tool call: shell, started: other
    Tool call: shell, program other, refused.
    Failure class refused_tool. Action left: wait.
    ✓ Took 0 item(s) to a ready pull request, stopped 1.
    Elapsed: 11m 26s
    
  11. added
    status/planned
    and removed
    owner/service
    status/blocked
    on Nov 4, 2026
  12. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Cleared the stop at group 1 by the rule digest: the runner image changed since the stop, from sha256:eb2c32f9c27c350eafb35b7f08c274621a0a05b95904b2185c667b9805b0d499 to sha256:ff7f81f8f5902c5ae4e48ed334bc83f842b51afb639ab71be65cb4240daadf01. The item is Planned again, and the Service takes it in the next round. The Service clears a stop one time for each runner image. A new stop on this image waits for a comment implement: retry.

  13. added
    status/in-progress
    and removed
    status/planned
    on Nov 6, 2026
  14. changed the title [-]fix(k8s): devops k8s logs names a loki.url setting that does not exist and dials a localhost default[/-] [+]fix(k8s): Add loki.url config key for k8s logs[/+] on Nov 6, 2026
  15. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    The job shortened the title of this item. The summary had 90 characters, and the limit is 60. The type and the scope stay.

  16. added
    status/in-review
    and removed
    status/in-progress
    on Nov 6, 2026
  17. removed
    status/in-review
    on Nov 6, 2026
  18. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor
  19. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-06 16:15 UTC

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

    effort/lowpriority/p2-mediumscope/k8ssource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions