Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow creating more than one config file per integration #677

Merged
merged 1 commit into from
Dec 9, 2020

Conversation

albertvaka
Copy link
Contributor

What does this PR do?

Allows specifying the name of the config file to be created by datadog_agent::integration, so different config files with different instances can be defined from different places in the code. For example, in the following manifest we define two config files for the postgres integration:

  datadog_agent::integration { 'postgres_dbA':
    integration => 'postgres',
    conf_file => 'dbA',
    instances => [{
      host     => 'localhost',
      dbname   => 'dbA',
      username => 'dbAuser',
      password => 'dbApass',
    }],
  }

  datadog_agent::integration { 'postgres_dbB':
    integration => 'postgres',
    conf_file => 'dbB',
    instances => [{
      host     => 'localhost',
      dbname   => 'dbB',
      username => 'dbBuser',
      password => 'dbBpass',
    }],
  }

which results in a config file being created for each:

$ cat /etc/datadog-agent/conf.d/postgres.d/dbA.yaml 
---
init_config: 
instances:
- host: localhost
  dbname: dbA
  username: dbAuser
  password: dbApass
$ cat /etc/datadog-agent/conf.d/postgres.d/dbB.yaml 
---
init_config: 
instances:
- host: localhost
  dbname: dbB
  username: dbBuser
  password: dbBpass

Motivation

Fixes #147

@albertvaka albertvaka requested a review from a team as a code owner December 4, 2020 12:51
@albertvaka albertvaka mentioned this pull request Dec 4, 2020
@albertvaka albertvaka force-pushed the albertvaka/multiple-integration-config branch from f8a7032 to c25d0c6 Compare December 4, 2020 12:53
@albertvaka albertvaka force-pushed the albertvaka/multiple-integration-config branch from c25d0c6 to f57518f Compare December 4, 2020 12:54
@cdloh
Copy link

cdloh commented Dec 4, 2020

Thanks for the fast PR!

The only issue I see with this is that you lose the logic and defaults from the main class and template. Keeping with the theme of postgres the main postgres class ensures that your custom metrics are acceptable otherwise fails.

This is probably an acceptable loss? The other option would be to make each integration a resource and call those specifically instead of the integration resource itself, however that's a much larger change.

@albertvaka
Copy link
Contributor Author

albertvaka commented Dec 4, 2020

Yes, with this approach we don't check anything, which has cons (eg: typos might go unnoticed) but also pros (eg: it's more flexible for advanced use cases like yours; when there's a new integration or a new config field, this works right away, otherwise the puppet module needs to be updated).

Unfortunately it's a compromise we have to make one way or another, and I prefer leaving the postgres class as it is so it covers the more basic use case, and implement this in the generic integration.

@cdloh
Copy link

cdloh commented Dec 7, 2020

Makes sense!

@albertvaka albertvaka merged commit 204c592 into master Dec 9, 2020
@albertvaka albertvaka deleted the albertvaka/multiple-integration-config branch December 9, 2020 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

revamp of integrations
3 participants