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

Add schema collection to Postgres integration #15484

Merged
merged 133 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from 129 commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
829e905
first commit
edengorevoy Jul 14, 2023
872a5ac
All schema collection except ordering by metrics
edengorevoy Jul 17, 2023
feb06dc
Ordering tables by relation metrics
edengorevoy Jul 17, 2023
5c62cfe
toast table changes
edengorevoy Jul 18, 2023
6c97b86
Adding some testing, and updating the payload
edengorevoy Jul 18, 2023
3a1a8cd
Add a debug log
edengorevoy Jul 19, 2023
9282551
Updating last_schemas_query at correct time
edengorevoy Jul 19, 2023
4f3bdff
Actually return the metadata from _collect_schema_info
edengorevoy Jul 19, 2023
5c61488
Convert db id from int to str
edengorevoy Jul 19, 2023
d052c9e
Correct json objects for indexes, foreign keys
edengorevoy Jul 20, 2023
5c560bc
Correct json objects for indexes, foreign keys
edengorevoy Jul 20, 2023
1254049
Updating queries and toast table getting
edengorevoy Aug 2, 2023
e1e6905
Config update
edengorevoy Aug 2, 2023
ca3ee13
Updating to include OIDs in return, and don't calculate fk for tables…
edengorevoy Aug 3, 2023
1a5a473
Update some comments
edengorevoy Aug 3, 2023
d380f13
Make test mor specific
edengorevoy Aug 3, 2023
8336f17
Update config to limit columns
edengorevoy Aug 3, 2023
7fd65a0
Formatting
edengorevoy Aug 3, 2023
9a4c7bb
Remove excess warnings and prints
edengorevoy Aug 3, 2023
4e5266b
Fix schema id propagation
edengorevoy Aug 3, 2023
4df28a6
Clean up caching
edengorevoy Aug 3, 2023
c7b9394
Formatting, updating to psycopg3
edengorevoy Aug 3, 2023
864f2ba
Conditionals for postgres version 9, no partitions
edengorevoy Aug 4, 2023
74eb63e
Update table size test
edengorevoy Aug 4, 2023
997c39d
Add log
edengorevoy Aug 4, 2023
0d8f727
Merge branch 'master' into collect-postgres-schemas
edengorevoy Aug 7, 2023
8f51e53
Add files after validation update
edengorevoy Aug 7, 2023
4596e74
reverting some config model files
edengorevoy Aug 7, 2023
5bc63bc
Validating instance file?
edengorevoy Aug 7, 2023
7c9c9b2
Reverting instance.py?
edengorevoy Aug 7, 2023
cbc1acc
Update dependencies with ddev3.3
edengorevoy Aug 7, 2023
0934697
Revert models
edengorevoy Aug 7, 2023
83b3fed
Make manual changes to instance.py
edengorevoy Aug 7, 2023
e949f1b
Update
edengorevoy Aug 7, 2023
d7a541e
Validating after ddev update
edengorevoy Aug 8, 2023
edfd7c8
One more validation update
edengorevoy Aug 8, 2023
059a428
first commit
edengorevoy Jul 14, 2023
7b72f8d
All schema collection except ordering by metrics
edengorevoy Jul 17, 2023
16caa06
Ordering tables by relation metrics
edengorevoy Jul 17, 2023
ad936b0
toast table changes
edengorevoy Jul 18, 2023
106f8df
Adding some testing, and updating the payload
edengorevoy Jul 18, 2023
b0be66e
Add a debug log
edengorevoy Jul 19, 2023
5465928
Updating last_schemas_query at correct time
edengorevoy Jul 19, 2023
7bcf63b
Actually return the metadata from _collect_schema_info
edengorevoy Jul 19, 2023
e2868da
Convert db id from int to str
edengorevoy Jul 19, 2023
249c1b1
Correct json objects for indexes, foreign keys
edengorevoy Jul 20, 2023
b4f5af1
Correct json objects for indexes, foreign keys
edengorevoy Jul 20, 2023
66258d3
Updating queries and toast table getting
edengorevoy Aug 2, 2023
7f3f1ed
Config update
edengorevoy Aug 2, 2023
9a2f6dd
Updating to include OIDs in return, and don't calculate fk for tables…
edengorevoy Aug 3, 2023
2940089
Update some comments
edengorevoy Aug 3, 2023
d405c75
Make test mor specific
edengorevoy Aug 3, 2023
16503a8
Update config to limit columns
edengorevoy Aug 3, 2023
93ec1fe
Formatting
edengorevoy Aug 3, 2023
327a427
Remove excess warnings and prints
edengorevoy Aug 3, 2023
5a97fab
Fix schema id propagation
edengorevoy Aug 3, 2023
3a4f00a
Clean up caching
edengorevoy Aug 3, 2023
584b269
Formatting, updating to psycopg3
edengorevoy Aug 3, 2023
c8b62c8
Conditionals for postgres version 9, no partitions
edengorevoy Aug 4, 2023
20c1f08
Update table size test
edengorevoy Aug 4, 2023
56a1201
Add log
edengorevoy Aug 4, 2023
8f46b54
Add files after validation update
edengorevoy Aug 7, 2023
0e5a132
reverting some config model files
edengorevoy Aug 7, 2023
b5aafc5
Validating instance file?
edengorevoy Aug 7, 2023
447b01c
Reverting instance.py?
edengorevoy Aug 7, 2023
a5ce76d
Update dependencies with ddev3.3
edengorevoy Aug 7, 2023
b9fc330
Revert models
edengorevoy Aug 7, 2023
853f029
Make manual changes to instance.py
edengorevoy Aug 7, 2023
5b7edee
Update
edengorevoy Aug 7, 2023
c2a99d6
Validating after ddev update
edengorevoy Aug 8, 2023
34a40db
One more validation update
edengorevoy Aug 8, 2023
7e712a8
false string for ssl
edengorevoy Aug 8, 2023
0c3c92d
Merge branch 'collect-postgres-schemas' of github.com:DataDog/integra…
edengorevoy Aug 8, 2023
ffd267b
first commit
edengorevoy Jul 14, 2023
5a34859
All schema collection except ordering by metrics
edengorevoy Jul 17, 2023
be39b93
Ordering tables by relation metrics
edengorevoy Jul 17, 2023
e43b14f
toast table changes
edengorevoy Jul 18, 2023
8799fde
Adding some testing, and updating the payload
edengorevoy Jul 18, 2023
9c6af8f
Add a debug log
edengorevoy Jul 19, 2023
85d0aa9
Updating last_schemas_query at correct time
edengorevoy Jul 19, 2023
e167c8a
Actually return the metadata from _collect_schema_info
edengorevoy Jul 19, 2023
523ba0b
Convert db id from int to str
edengorevoy Jul 19, 2023
8d09d7e
Correct json objects for indexes, foreign keys
edengorevoy Jul 20, 2023
d172f6a
Correct json objects for indexes, foreign keys
edengorevoy Jul 20, 2023
b1ee753
Updating queries and toast table getting
edengorevoy Aug 2, 2023
bb428a7
Config update
edengorevoy Aug 2, 2023
c1d4ba3
Updating to include OIDs in return, and don't calculate fk for tables…
edengorevoy Aug 3, 2023
8257e4e
Update some comments
edengorevoy Aug 3, 2023
5337c6f
Make test mor specific
edengorevoy Aug 3, 2023
b831e5f
Update config to limit columns
edengorevoy Aug 3, 2023
6c80b3d
Formatting
edengorevoy Aug 3, 2023
124ac46
Remove excess warnings and prints
edengorevoy Aug 3, 2023
d8e67f8
Fix schema id propagation
edengorevoy Aug 3, 2023
036bdb4
Clean up caching
edengorevoy Aug 3, 2023
40db094
Formatting, updating to psycopg3
edengorevoy Aug 3, 2023
daaecdc
Conditionals for postgres version 9, no partitions
edengorevoy Aug 4, 2023
c8e482e
Update table size test
edengorevoy Aug 4, 2023
12d7baf
Add log
edengorevoy Aug 4, 2023
e1aa5f1
Validating instance file?
edengorevoy Aug 7, 2023
6551a23
Reverting instance.py?
edengorevoy Aug 7, 2023
ce44417
Update dependencies with ddev3.3
edengorevoy Aug 7, 2023
3d77d8a
Revert models
edengorevoy Aug 7, 2023
606c8e5
Make manual changes to instance.py
edengorevoy Aug 7, 2023
df0a256
Update
edengorevoy Aug 7, 2023
a41497a
Validating after ddev update
edengorevoy Aug 8, 2023
a3e6f60
One more validation update
edengorevoy Aug 8, 2023
9485df8
Merge branch 'master' of github.com:DataDog/integrations-core into co…
edengorevoy Aug 8, 2023
627113d
AGGHHHH
edengorevoy Aug 8, 2023
7f0913f
Merge branch 'collect-postgres-schemas' of github.com:DataDog/integra…
edengorevoy Aug 8, 2023
d9cf042
What if we just get rid of the config block?
edengorevoy Aug 8, 2023
e986c38
Merge branch 'collect-postgres-schemas' of github.com:DataDog/integra…
edengorevoy Aug 8, 2023
6c07d4d
Lower bound for wal_fpi instead of exact value
edengorevoy Aug 10, 2023
bd04da2
Address revisions, update documentation
edengorevoy Aug 10, 2023
5147256
Better line in test
edengorevoy Aug 10, 2023
59cac5b
Merge branch 'master' into collect-postgres-schemas
edengorevoy Aug 10, 2023
4c9f4ba
format
edengorevoy Aug 10, 2023
62a9aa6
add changelog line
edengorevoy Aug 10, 2023
fd166db
changelog again
edengorevoy Aug 10, 2023
e99510e
remove debug line and don't skip postgres
edengorevoy Aug 10, 2023
1f3b93d
ah
edengorevoy Aug 11, 2023
5a4be4b
changelog and IPv4->string for json serialization?
edengorevoy Aug 14, 2023
ea59e6f
changelog changes and docs update
edengorevoy Aug 14, 2023
8174326
exclude rds_superuser
edengorevoy Aug 14, 2023
7dfab47
owner->nspowner
edengorevoy Aug 14, 2023
66058a6
Update queries to use OIDs instead of tablenames/schemanames
edengorevoy Aug 14, 2023
b51dd47
Update queries to use OIDs instead of tablenames/schemanames
edengorevoy Aug 14, 2023
c23e468
blindly truncate table limit
edengorevoy Aug 14, 2023
9464c8c
filter tables that don't get metrics collected on them
edengorevoy Aug 15, 2023
105942e
Merge branch 'master' into collect-postgres-schemas
edengorevoy Aug 16, 2023
4af6358
Remove rogue TODO
edengorevoy Aug 16, 2023
842f1f6
Merge branch 'master' of github.com:DataDog/integrations-core into co…
edengorevoy Aug 16, 2023
892f1b8
Fix metadata instance test
edengorevoy Aug 16, 2023
9294111
formatting
edengorevoy Aug 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions postgres/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

***Added***:

* Add schema collection to Postgres integration ([#15484](https://github.com/DataDog/integrations-core/pull/15484))
* Add support for sending `database_instance` metadata ([#15559](https://github.com/DataDog/integrations-core/pull/15559))

## 14.1.0 / 2023-08-10
Expand Down
34 changes: 34 additions & 0 deletions postgres/assets/configuration/spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,40 @@ files:
type: number
example: 600

- name: collect_schemas
description: |
Enable collection of database schemas. In order to collect schemas from all user databases,
enable `database_autodiscovery`. To collect from a single database, set `dbname` to collect
the schema for that database.
Relation metrics must be enabled for schema collection.
options:
- name: enabled
description: |
Enable collection of database schemas. Requires `dbm: true` and relation metrics must be enabled.
value:
type: boolean
example: false
- name: max_tables
description: |
Maximum amount of tables the Agent collects from the instance.
value:
type: number
example: 1000
display_default: 1000
- name: max_columns
description: |
Maximum amount of columns the Agent collects per table.
value:
type: number
example: 50
display_default: 50
- name: collection_interval
description: |
The database schema collection interval (in seconds).
value:
type: number
example: 600

- name: aws
description: |
This block defines the configuration for AWS RDS and Aurora instances.
Expand Down
8 changes: 7 additions & 1 deletion postgres/datadog_checks/postgres/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, instance):
self.max_connections = instance.get('max_connections', 30)
self.tags = self._build_tags(instance.get('tags', []))

ssl = instance.get('ssl', False)
ssl = instance.get('ssl', "false")
if ssl in SSL_MODES:
self.ssl_mode = ssl
else:
Expand Down Expand Up @@ -100,6 +100,12 @@ def __init__(self, instance):
self.pg_stat_activity_view = instance.get('pg_stat_activity_view', 'pg_stat_activity')
self.statement_samples_config = instance.get('query_samples', instance.get('statement_samples', {})) or {}
self.settings_metadata_config = instance.get('collect_settings', {}) or {}
self.schemas_metadata_config = instance.get('collect_schemas', {"enabled": False})
if not self.relations and self.schemas_metadata_config['enabled']:
raise ConfigurationError(
'In order to collect schemas on this database, you must enable relation metrics collection.'
)

self.resources_metadata_config = instance.get('collect_resources', {}) or {}
self.statement_activity_config = instance.get('query_activity', {}) or {}
self.statement_metrics_config = instance.get('query_metrics', {}) or {}
Expand Down
12 changes: 12 additions & 0 deletions postgres/datadog_checks/postgres/config_models/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ class Azure(BaseModel):
fully_qualified_domain_name: Optional[str] = None


class CollectSchemas(BaseModel):
model_config = ConfigDict(
arbitrary_types_allowed=True,
frozen=True,
)
collection_interval: Optional[float] = None
enabled: Optional[bool] = None
max_columns: Optional[float] = None
max_tables: Optional[float] = None


class CollectSettings(BaseModel):
model_config = ConfigDict(
arbitrary_types_allowed=True,
Expand Down Expand Up @@ -154,6 +165,7 @@ class InstanceConfig(BaseModel):
collect_database_size_metrics: Optional[bool] = None
collect_default_database: Optional[bool] = None
collect_function_metrics: Optional[bool] = None
collect_schemas: Optional[CollectSchemas] = None
collect_settings: Optional[CollectSettings] = None
collect_wal_metrics: Optional[bool] = None
custom_queries: Optional[tuple[MappingProxyType[str, Any], ...]] = None
Expand Down
27 changes: 27 additions & 0 deletions postgres/datadog_checks/postgres/data/conf.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,33 @@ instances:
#
# collection_interval: 600

## Enable collection of database schemas. In order to collect schemas from all user databases,
## enable `database_autodiscovery`. To collect from a single database, set `dbname` to collect
## the schema for that database.
## Relation metrics must be enabled for schema collection.
#
# collect_schemas:

## @param enabled - boolean - optional - default: false
## Enable collection of database schemas. Requires `dbm: true` and relation metrics must be enabled.
#
# enabled: false

## @param max_tables - number - optional - default: 1000
## Maximum amount of tables the Agent collects from the instance.
#
# max_tables: 1000

## @param max_columns - number - optional - default: 50
## Maximum amount of columns the Agent collects per table.
#
# max_columns: 50

## @param collection_interval - number - optional - default: 600
## The database schema collection interval (in seconds).
#
# collection_interval: 600

## This block defines the configuration for AWS RDS and Aurora instances.
##
## Complete this section if you have installed the Datadog AWS Integration
Expand Down
Loading
Loading