Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide total statistics metrics #39

Closed
jan-di opened this issue Nov 1, 2024 · 4 comments
Closed

Provide total statistics metrics #39

jan-di opened this issue Nov 1, 2024 · 4 comments

Comments

@jan-di
Copy link

jan-di commented Nov 1, 2024

It would be great, if the exporter also provides metrics that represent the statistics from the UI:

grafik
  • Total count of documents/documents that are marked as new/characters
  • Statistics about file extensions
@hansmi
Copy link
Owner

hansmi commented Nov 1, 2024

I had a quick look at what's necessary/possible. Statistics aren't part of the documented REST API.

  • "Documents in inbox" needs the "inbox" flag from tags to be exported, then it can be reproduced in PromQL (sum(paperless_tag_document_count) filtered by inbox flag).

  • "Total documents" is possible via the API. Either by iterating (see below) or requesting /api/documents/ which has the total count (currently not implemented by the client code.

  • "Character count" would require iterating over all documents. The underlying implementation for the statistics is a single SQL query summing the character count from all documents. Depending on the scrape interval and document count the metric would be rather expensive. Would have to be behind a flag.

  • The break-down by document type is also a single SQL query grouping by MIME type. Would require document iteration as well. Not sure how useful the break-down is in metrics.

Implementation:

hansmi added a commit that referenced this issue Nov 6, 2024
Enable reproduction of the "Documents in inbox" count reported on
Paperless-ngx' main page when combined with the document count per tag.

Relates to issue #39.
@hansmi
Copy link
Owner

hansmi commented Nov 6, 2024

The "inbox" tag flag is reported as a metric with df7648d.

"Total documents" will/would require changes to the underlying Paperless-ngx client library. @jan-di, do you have a usecase other than "it would be great"?

@jan-di
Copy link
Author

jan-di commented Nov 12, 2024

No, actually not. Its just for measuring growth as I thought its just an API that can be piped through to metrics.
If its that much work, its not worth it.

I'm instead thinking of providing a docs MR to paperless, maybe the statistics API is already official but just not documented. If its assured that it is stable, this would make this issue much easier.

@hansmi
Copy link
Owner

hansmi commented Jan 22, 2025

@jan-di, inspired by #41 I've added a document count in 071024d. It will be part of the next release.

In summary that makes the implementation of what's done easily without additional documented APIs complete (c.f. #39 (comment)).

@hansmi hansmi closed this as completed Jan 24, 2025
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

No branches or pull requests

2 participants