DataDog / integrations-core

Core integrations of the Datadog Agent
BSD 3-Clause "New" or "Revised" License
934 stars 1.4k forks source link

[BUG] Postgres integration "name" config with Azure #16087

Open linceaerian opened 1 year ago

linceaerian commented 1 year ago

Hello Maintainer,

Please find the bug report below.

Agent Version

datadog-agent version
Agent 7.45.0 - Commit: 964e770 - Serialization version: v5.0.81 - Go version: go1.19.9

Additional environment details (Operating System, Cloud provider, etc):

Steps to reproduce the issue:

  1. Create a postgres configuration, add the azure configuration for "single_server"
  2. Restart the agent
  3. Launch a check for postgres "datadog-agent check postgres"

Describe the results you received:

error: py.loader: could not configure check 'postgres (13.5.0)': could not invoke 'postgres' python check constructor. New constructor API returned:
Traceback (most recent call last):
  File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/postgres/postgres.py", line 73, in __init__
    self.set_resource_tags()
  File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/postgres/postgres.py", line 113, in set_resource_tags
    "dd.internal.resource:{}:{}".format(resource_type, self.cloud_metadata.get("azure")["name"])
KeyError: 'name'
Deprecated constructor API returned:
__init__() got an unexpected keyword argument 'agentConfig'
error: Unable to load a check from instance of config 'postgres': JMX Check Loader: check is not a jmx check, or unable to determine if it's so; Python Check Loader: could not configure check instance for python check postgres: could not invoke 'postgres' python check constructor. New constructor API returned:
Traceback (most recent call last):
  File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/postgres/postgres.py", line 73, in __init__
    self.set_resource_tags()
  File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/postgres/postgres.py", line 113, in set_resource_tags
    "dd.internal.resource:{}:{}".format(resource_type, self.cloud_metadata.get("azure")["name"])
KeyError: 'name'
Deprecated constructor API returned:
__init__() got an unexpected keyword argument 'agentConfig'; Core Check Loader: Check postgres not found in Catalog
error: Unable to load the check: unable to load any check from config 'postgres'

Error: could not load postgres:
* JMX Check Loader: check is not a jmx check, or unable to determine if it's so
* Python Check Loader: could not configure check instance for python check postgres: could not invoke 'postgres' python check constructor. New constructor API returned:
Traceback (most recent call last):
  File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/postgres/postgres.py", line 73, in __init__
    self.set_resource_tags()
  File "/opt/datadog-agent/embedded/lib/python3.8/site-packages/datadog_checks/postgres/postgres.py", line 113, in set_resource_tags
    "dd.internal.resource:{}:{}".format(resource_type, self.cloud_metadata.get("azure")["name"])
KeyError: 'name'
Deprecated constructor API returned:
__init__() got an unexpected keyword argument 'agentConfig'
* Core Check Loader: Check postgres not found in Catalog
Error: no valid check found

Describe the results you expected:

Check postgres functional

Additional information you deem important (e.g. issue happens only occasionally):

It seems that the check python expect a parameter "name" as seen in "dd.internal.resource:{}:{}".format(resource_type, self.cloud_metadata.get("azure")["name"]) so I tried to add it.

From:

  azure:
    deployment_type: single_server

To:

  azure:
    deployment_type: single_server
    name: test.postgres.database.azure.com

Then the check execute correctly => but this parameter is not defined in: https://github.com/DataDog/integrations-core/blob/master/postgres/datadog_checks/postgres/data/conf.yaml.example Closest one being: fully_qualified_domain_name but described as optional. I think the integration code is missing some init.

jmisur commented 8 months ago

I solved this by downgrading to datadog/agent:7.44.1