Skip to content

Sending histogram data from python via statsd_exporter #569

@sheldonsoroco

Description

@sheldonsoroco

We are using statsd-exporter in our integrations. Is there any way of sending histogram data to grafana from python code?
We are using statsd library in python.

We use statsd-exporter and victoria metrics data store to configure out metrics.

I added the mapping section as mentioned here to our integrations.yaml file.

In python code, I extended the statsd lib to send histograms. "h" here is sending only metric_sum and metric_count similar to timers. I was expecting buckets to be sent for metric name as defined in the mapping. Can someone help me out here.

My end goal is to use histogram_quantile() in grafana, i think this expects buckets to be preprocessed.

from statsd import StatsClient
class CustomStatsClient(StatsClient):
    def histogram(self, stat: str, value: float):
         histogram_message = f"{self.prefix}.{stat}:{value}|h"
         self._send(histogram_message)

    def _send(self, message: str):
         self._sock.sendto(message.encode(), (self.host, self.port))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions