【发布时间】:2020-09-28 19:35:34
【问题描述】:
我尝试使用 DD 代理设置 postgres 检查,但我收到 postgres.py 脚本引发的错误。正如您在屏幕截图中看到的,我正在使用这个简单的查询来获取到数据库的活动连接数。我把它放在 /etc/datadog-agent/conf.d/postgres.d/conf.yaml 中,如下所示:
- metric_prefix: postgresql
query: SELECT datname as db_name, count(pid) as active_connections FROM pg_stat_activity where state = 'active' group by db_name;
columns:
- name: active_connections
type: gauge
- name: db_name
type: tag
我在运行配置检查时遇到的错误如下:
[root@my_box postgres.d]# datadog-agent check postgres | grep -i -A 20 -B 20 active_connections
Error: postgres:953578488181a512 | (postgres.py:398) | non-numeric value `cldtx` for metric column `active_connections` of metric_prefix `postgresql`
如果我理解正确,conf.yaml 文件用于调用带有某些参数的 postgres.py 脚本。 postgres.py 脚本可以在这里找到: https://github.com/DataDog/integrations-core/blob/master/postgres/datadog_checks/postgres/postgres.py
【问题讨论】:
-
这看起来很奇怪。您可能应该联系 support@datadoghq.com 以获取他们的意见。 (您也可以考虑首先通过 yaml linter 运行您的 yaml,以确保没有格式化的东西会影响代理对您的配置的解释,但我真的不认为这会导致这种情况。不过,这是一件快速的事情检查。)
-
谢谢@baldr,我用这个在线验证器验证了 yaml 文件:yamllint.com,它似乎没问题。我还向 Datadog 提出了一张票,正在等待答复。
标签: python postgresql datadog