2

I have hundreds of customers and I have several metrics I'd like to keep to each one of them.

Let's say I have a metric orders_count. I have two possibilities:

  • use a label - i.e. order_count{customer=customer_name}
  • have a different counter for every customer - i.e. order_count_customer_name

What is the preferable way and why?

IsaacLevon
  • 2,260
  • 4
  • 41
  • 83

2 Answers2

4

I definitely would not use the customer name as a label, since that would result in a high cardinality and therefore a huge amount of combinations, which will totally kill your prometheus performance. I recommend reading this post for details.

Regarding your metric, not sure if makes sense to have one metric per client, but rather use metrics per e.g: operation, or action, to have an overview about you service behavior.

If you need to get reports about specific data, I would suggest using Grafana and a sql data source. Check Grafana docs for details.

Sergio Santiago
  • 1,316
  • 1
  • 11
  • 19
  • 2
    The thing is that I do want to track each client. Is Prometheus not the right tool for the job? – IsaacLevon Jul 07 '20 at 07:22
  • 3
    So I don't think that prometheus is the tool you want. Prometheus should be used to give an overview of the behaviour of your application, instead a report about your data. Seems you are looking for a BI tool instead, that analyses your data content. – Sergio Santiago Jul 07 '20 at 08:27
  • Can you suggest one? – IsaacLevon Jul 08 '20 at 15:14
  • 4
    I would suggest using Grafana and a sql data source. Check here https://grafana.com/docs/grafana/latest/features/datasources/ – Sergio Santiago Jul 08 '20 at 17:32
-3

I would go with the first one;

order_count{customer=customer_name}

One way of looking at this could be - It is a more scalable approach as let's say in future you wish to add more labels say "customerLocation" too; and you can use any combination of labels to group your data.

Pankaj Saini
  • 1,493
  • 8
  • 13
  • 1
    Please don't do this. Prometheus specifically recommends against using high carinality in labels as each one makes creates its own time-series: https://prometheus.io/docs/practices/naming/#labels – R10t-- Oct 20 '21 at 21:33
  • 1
    Exactly, I linked the blog post from Prometheus maintainers in my answer. https://www.robustperception.io/cardinality-is-key – Sergio Santiago Nov 19 '21 at 20:15