Count file upload sizes in app

12 views
Skip to first unread message

Manos Seferidis

unread,
Jun 5, 2020, 1:23:53 PM6/5/20
to Prometheus Users
I'm new to Prometheus and I'm using it in conjunction with Grafana and Django. Simple metrics are easy enough to make without knowing much.

Now I'm having trouble with collecting data about files being uploaded. In my application the user can upload files up to 50MB so it would be nice
if I could have a graph with the total of each file size. Namely 0.5MB, 1MB, 2MB, 5MB .. 50MB.

I tried using a histogram like below

```python
uploaded_file_sizes = Histogram(
    'uploaded_file_sizes',
    'Uploaded file size in bytes',
    buckets=(
        10000,    #   10KB
        100000,   #   100KB
        500000,   #   500KB
        1000000,  #   1MB
        5000000,  #   5MB
        10000000,  #   10MB
        25000000,  #   25MB
        50000000,  #   50MB
    )
)
```

However I have no idea on how to get a graph that represents the amount of 1MB files uploaded for example. Due to the numbers being cumulative,
this seems a bit hard. Currently I made a fast work-around by showing the below graph
Screenshot from 2020-06-05 18-19-47.png












This requires 5 queries for each specific bucket and the graph is still not even intuitive.

How can I avoid this cumulative nature of buckets and instead just show the total files that are closest to a file size (so that no overlapping between buckets occur)?
Reply all
Reply to author
Forward
0 new messages