Fix schema filtering on query relations #3449
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixed the loading of the configuration file (avoid KeyError and check yaml structure).
Fix filtering loop on query_scope to continue on other rows.
Simplify parameter and removed 'relations' as 'relations_config' contains it all.
What does this PR do?
Fix the filtering of the relations queries in the postgres integration. Previously, the filtering would 'return' and abort all metrics if one table was not matching the schema requirement in the configuration file. This was incorrect and the method should have skipped that row (non matching) but continued for the other row in the result to push matching metrics.
This also improved a bit the parsing of the configuration file (avoid KeyError and check for type of object and key present in dict) and removed redundant argument in methods.
Motivation
we have tables with the same name in different schemas in our database, but are only interested in monitoring one schema.table combination, not all. The current datadog would either report both table (wasting metrics and dashboard) or fail to run/report if we forced the schema.
Additional Notes
N/A - first PR :)
Review checklist (to be filled by reviewers)
changelog/
andintegration/
labels attached