Skip to content

[Feature] Add stats API key scope to allow external observability tool access #10957

Open

Description

@louishhy

Hello AstrBot Team!

Feature Description

Add a readonly stats API key scope that allows access to the existing runtime and token usage statistics endpoints:

  • GET /api/v1/stats
  • GET /api/v1/stats/provider-tokens

Currently, these endpoints require dashboard authentication because their system scope is unavailable to developer API keys. The new scope would let external tools retrieve statistics without dashboard credentials.

The scope would require explicit selection and would not grant administrative permissions.

Reference implementation

A reference implementation is provided in PR #10956.

Use Case

Operators running AstrBot alongside external monitoring systems need to collect runtime and token usage statistics for centralized dashboards and monitoring.

As a concrete example, a Prometheus exporter for AstrBot could query these endpoints using an API key with only the stats scope, then convert the JSON responses into monitoring metrics.

The operators can then setup proper monitoring and alert systems for reliability operations, such as alerting when the bot is down, or notifying when token rate exceeds certain threshold.

Checklist

  • I have searched the Issue list for related features and confirmed this feature idea has never been proposed.
  • The feature I am suggesting is related to AstrBot itself, not to a specific plugin.
  • I have read and agree to the project's Code of Conduct.
  • (Optional) I am willing to submit a PR to help implement this feature.

Activity

  1. added
    enhancement
    on Nov 2, 2026
  2. moved this from Todo to In Progress in AstrBot Roadmapon Nov 3, 2026
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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions