Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending histogram data from python via statsd_exporter #569

Open
sheldonsoroco opened this issue Aug 28, 2024 · 1 comment
Open

Sending histogram data from python via statsd_exporter #569

sheldonsoroco opened this issue Aug 28, 2024 · 1 comment

Comments

@sheldonsoroco
Copy link

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))
@matthiasr
Copy link
Contributor

Can you share your configuration? In particular, what is your observer_type and your histogram_options? What is the result on /metrics after you send a few events? You can also run the exporter with the debug log level to observe what exactly happens on the wire.

Note that there is a bit of a terminology and temporality mis-match that you need to keep in mind. While statsd has a "histogram" type, at the protocol level you transfer individual observations. This is an extension of the original protocol but we treat it basically the same as the ms type, without the unit scaling.

In the exporter, you configure the buckets (and/or native histogram scaling factor) and these events are counted into the appropriate bucket. It seems (but I'm not 100% sure from your description) that you are receiving the events, but do not have buckets configured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants