Datadog Metric可以四舍五入到2个小数点

发布于 2025-01-22 11:29:30 字数 1258 浏览 2 评论 0原文

我正在使用Python软件包datadog_api_client将数据发布到DataDog的指标。该代码看起来像:

        now = datetime.datetime.now().timestamp()
        metric_name = 'test.metric.count'
        with ApiClient(configuration) as api_client:
            # Create an instance of the API class
            api_instance = metrics_api.MetricsApi(api_client)
            body = MetricsPayload(
                series=[
                    Series(
                        host="test_tool",
                        interval=20,
                        metric=metric_name,
                        points=[
                            Point([now, float(1127023]),
                        ],
                        tags=metric_tags,
                        type="count",
                    ),
                ],
            )  # MetricsPayload

            try:
                # Submit metrics
                api_response = api_instance.submit_metrics(body)
                print(f"Metric: {metric_name} : {api_response}")
            except ApiException as e:
                raise Exception(f"Exception when calling MetricsApi->submit_metrics: {e}")

当我运行此代码时,DataDog将公制值发布为1.13m,这不是完全准确的。我检查了很多文档,但找不到我缺少的任何属性,这些属性可以添加以删除精度。

有人可以帮我获取数字吗?

I am using a python package datadog_api_client to publish data to a metric to Datadog. The code looks like:

        now = datetime.datetime.now().timestamp()
        metric_name = 'test.metric.count'
        with ApiClient(configuration) as api_client:
            # Create an instance of the API class
            api_instance = metrics_api.MetricsApi(api_client)
            body = MetricsPayload(
                series=[
                    Series(
                        host="test_tool",
                        interval=20,
                        metric=metric_name,
                        points=[
                            Point([now, float(1127023]),
                        ],
                        tags=metric_tags,
                        type="count",
                    ),
                ],
            )  # MetricsPayload

            try:
                # Submit metrics
                api_response = api_instance.submit_metrics(body)
                print(f"Metric: {metric_name} : {api_response}")
            except ApiException as e:
                raise Exception(f"Exception when calling MetricsApi->submit_metrics: {e}")

When I run this piece of code Datadog publishes the metric value as 1.13M which is not completely accurate. I checked a lot of documentation but cannot find any attribute that I am missing which can be added to remove the precision.

Can anyone please help me in getting the numbers?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文