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 · 0 comments
Open

Sending histogram data from python via statsd_exporter #569

sheldonsoroco opened this issue Aug 28, 2024 · 0 comments

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))
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

1 participant