如何使用 proc_name 标记 gunicorn 指标?

How to tag gunicorn metrics with proc_name?

我正在将来自多个应用程序的 gunicorn 指标从同一主机推送到 datadog,但是我找不到使用标签或 proc_name.

对 statsd 指标进行分组的方法

Datadog gunicorn 集成

https://app.datadoghq.com/account/settings#integrations/gunicorn

Datadog 代理检查正在使用 app:proc_name 标签自动更新。我可以使用它来分组和 select 特定服务的数据。

https://github.com/DataDog/dd-agent/blob/5.2.x/checks.d/gunicorn.py#L53

然而,对于 statsd 指标,我看不到如何分配标签或 proc_name。这不是自动完成的,我也看不到指定标签的方法。

https://github.com/benoitc/gunicorn/blob/19.6.0/gunicorn/instrument/statsd.py#L90

数据狗配置:

cat /etc/dd-agent/datadog.conf 

[Main]

dd_url: https://app.datadoghq.com
api_key: <KEY>

bind_host: 0.0.0.0
log_level: INFO
statsd_metric_namespace: my_namespace
tags: role:[service, test]

Gunicorn 配置:

# cat /etc/dd-agent/conf.d/gunicorn.yaml

init_config:
instances:
-   proc_name: service
-   proc_name: another_service

关于如何实现这一点有什么想法吗?

使用笔记本的示例:

在此示例中,我可以在 'from' 或 'avg by' 下拉菜单中 select app:service

Timeseries - `gunicorn.workers` - from `app:service`

对于带有 my_namespace 前缀的指标,我无法引用相同的应用程序名称。只有主机和环境相关的标签可用。

Timeseries - `my_namespace.gunicorn.workers` - from "Not available"
Timeseries - `my_namespace.gunicorn.requests` - from "Not available"

与 Datadog 的支持进行了交谈。非常有帮助,但简短的回答是目前没有选项可以添加额外的标签来指定单个 gunicorn.yaml 文件中的特定 proc_name。

作为启用分组的解决方法,我们为每个应用程序启用了唯一的前缀,但代价是指标不再共享相同的命名空间。

我已经提交了关于 Github 项目的新功能请求,希望能得到考虑。

https://github.com/DataDog/integrations-core/issues/1062