Search code examples
gunicorndatadog

How to tag gunicorn metrics with proc_name?


I'm pushing gunicorn metrics from multiple applications into datadog from the same host however I cannot find a way to group the statsd metrics using either a tag or proc_name.

Datadog gunicorn integration

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

Datadog agent checks are being updated automatically with the app:proc_name tag. I can use this to group and select the data for a specific service.

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

For the statsd metrics however, I do not see how to assign a tag or proc_name. This is not being done automatically nor do I see a way to specify a tag.

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

Datadog config:

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 config:

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

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

Any ideas on how this might be achieved?

Examples using notebooks:

In this example, I am able to select app:service in either the 'from' or 'avg by' drop downs.

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

For the metrics with the my_namespace prefix I am unable to reference the same application name. Only host and environment related tags are available.

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

Solution

  • Spoke with Datadog support. Very helpful but the short answer is that there is currently no option to add additional tags to specify the specific proc_name in the individual gunicorn.yaml file.

    As a workaround to enable grouping we enabled unique prefixes for each application but the trade-off is that the metrics are no longer sharing the same namespace.

    I've submitted a new feature request on the Github project which will hopefully be considered.

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