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

Add stats information to bucket/collection/record. #360

Open
msathis opened this issue Jan 8, 2016 · 10 comments
Open

Add stats information to bucket/collection/record. #360

msathis opened this issue Jan 8, 2016 · 10 comments
Assignees
Labels
enhancement plugin-idea stale For marking issues as stale. Labeled issues will be closed soon if label is not removed.

Comments

@msathis
Copy link

msathis commented Jan 8, 2016

Stats like no of documents, how much memory it holds etc will be useful.

@leplatrem
Copy link
Contributor

👍

No there isn't, but it's a good idea.

Related #173

@Natim
Copy link
Member

Natim commented Jan 8, 2016

@msathis do you have an idea of how you would like to access this information?

You can already have the number of records in a particular collection doing a head request to it:

http HEAD https://kinto-ota.dev.mozaws.net/v1/buckets/blocklists/collections/certificates/records

ETag: "1450717104423"
Last-Modified: Mon, 21 Dec 2015 16:58:24 GMT
Total-Records: 10

@msathis
Copy link
Author

msathis commented Jan 8, 2016

@Natim
Right now
GET https://kinto-ota.dev.mozaws.net/v1/buckets/mybucket --auth="test:test"
returns data, permissions. Additionally it can return one more property "stats" as well.

The properties i would like to see in stats object

  1. collections_count - (Applicable only for buckets)
  2. records_count - Total records. Not sure whether we need it for bucket stats too.
  3. storage_size - In bytes.
  4. last_write or updated_at - timestamp of last write.
  5. last_read - timestamp of last read. (Not sure about this).
  6. created_at - created timestamp.

@msathis
Copy link
Author

msathis commented Jan 9, 2016

And the data property in the response contains only last_modified property. It can also return created_at timestamp as well.

@Natim
Copy link
Member

Natim commented Jan 10, 2016

Thank you for this it is really interesting 👍

@Natim Natim changed the title Is there an api to get bucket/collection stats ? Add stats information to bucket/collection/record. Jan 10, 2016
@tarekziade
Copy link
Contributor

last_read - timestamp of last read. (Not sure about this).

I don't think that one is easy to implement. When you have a stack with several nodes, you would need to have a complex implementation to be able to have that info. What is your use case for this info ?

@Natim
Copy link
Member

Natim commented Aug 1, 2016

The proposition is to add on collection a readonly stats parameter such as permissions and data which contains:

For buckets

{
    "collections_count": 5,
    "storage_size": "478"
}

For collections

{
    "records_count": "114",
    "storage_size": "83"
}

@tarekziade
Copy link
Contributor

tarekziade commented Aug 1, 2016

Here are the two items I suggest we add in the collection or bucket metadata (and not used for the signing)

  1. items_count
  2. storage_size - In bytes.

Those two fields will be useful to implement a quota feature among other things. I don't think it should be added as a plugin. It sounds like a core feature that can be added without having to deal with plugin indirections, in particular if we have to deal with conflict resolutions at some point.

If we reach the consensus on how those two fields are stored we can do what @leplatrem suggested:

  • On create, sum the bytes, on delete subtracts, on update sum the difference between old/new.

@msathis What is the use case for the created_at field ?

@Natim
Copy link
Member

Natim commented Aug 1, 2016

It is already possible to get the last_write and we can use kinto-changes for that.
Also having the creation date can be achieve with the kinto-history plugin that let you have an full audit trail.

@Natim Natim mentioned this issue Aug 1, 2016
3 tasks
@Natim Natim self-assigned this Aug 1, 2016
@leplatrem
Copy link
Contributor

What's the status of this ? Does the built-in plugin kinto.plugins.quotas covers this already?

BTW created date was later reported in issue #679

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement plugin-idea stale For marking issues as stale. Labeled issues will be closed soon if label is not removed.
Projects
None yet
Development

No branches or pull requests

5 participants