stats: Add optional labels to prometheus metrics 99/40199/4
authorPim van Pelt <pim@ipng.nl>
Mon, 15 Jan 2024 13:46:00 +0000 (14:46 +0100)
committerOle Tr�an <otroan@employees.org>
Tue, 16 Jan 2024 10:05:55 +0000 (10:05 +0000)
commit276cd73b754f861948a2bd8f242a09b4d9fae0dd
treeb898dbab9d989824c6bbfb4d3c139684a43d2ff0
parent66abf322830c2c97e5d9c7710ef7cffcd35fcad8
stats: Add optional labels to prometheus metrics

* Refactor the existing prometheus exporter to function print_metric_v1()
* Add a 'v2' flag which instead uses metric names with labels, example:
  nodes_clocks{node="ip4-lookup",index="0",thread="4"} 30198798628761
  nodes_vectors{node="ip4-lookup",index="0",thread="4"} 298176625181
  nodes_calls{node="ip4-lookup",index="0",thread="4"} 119789874274
  nodes_suspends{node="ip4-lookup",index="0",thread="4"} 0

  interfaces_rx_packets{interface="tap0",index="0",thread="1"} 79582338270
  interfaces_rx_bytes{interface="tap0",index="0",thread="1"} 16265349667188
* For stat names that we don't know, print their v1 equivalent, which
  keeps backwards compatibility.

Details in https://ipng.ch/s/articles/2023/04/09/vpp-stats.html

Type: improvement
Signed-off-by: pim@ipng.nl
Change-Id: I53ed3ede8cc7853eb46c354834d89eb788ece3b1
src/vpp/app/vpp_prometheus_export.c