Reg: optimizing custom exporters using python client libraries

31 views
Skip to first unread message

RAJESH DASARI

unread,
Apr 21, 2021, 8:31:09 AM4/21/21
to promethe...@googlegroups.com
Hi ,

We have implemented a custom exporter by using the python client library.

We have 400 metrics for each ethernet port and we have around 38
ethernet ports.


for index,metric in enumerate(network_snmp_counters):
g = GaugeMetricFamily(metric, 'Per Port Counters', labels=['portNumber'])
for port_name,metrics in port_snmp_counters.items():
g.add_metric(["PORT-"+port_name],metrics[metric])
yield g

per each metric we add portNumber as label and per each metric we add
label values and metric values . so overall we loop for 400(first for
loop)*38(second for loop) times.

with the above logic, we see that per every scraping interval there is
a spike in cpu usage for the exporter process and we see that
add_metric call is causing the spikes in CPU,Is there any way to
optimize our exporter logic by using cpp based exporters or any other
way to avoid nested for loops.

Could someone please help me with this?

Regards,
Rajesh.
Reply all
Reply to author
Forward
0 new messages